Skip to content

Instantly share code, notes, and snippets.

View LukeFinch's full-sized avatar

Luke Finch LukeFinch

View GitHub Profile
@LukeFinch
LukeFinch / tokens.json
Created June 21, 2023 10:18
LukesKit - Figma tokens setup for LukeFinch blog
{
"Foundations": {
"blue010": {
"value": "#F6F6FF",
"type": "color"
},
"blue020": {
"value": "#E2E2FF",
"type": "color"
},
@LukeFinch
LukeFinch / font-properties.json
Last active June 14, 2023 11:11
Tokens Studio set up for additional font properties.
{
"weight": {
"100": {
"value": "Thin",
"type": "fontWeights",
"description": "Thin"
},
"200": {
"value": "ExtraLight",
"type": "fontWeights",
@LukeFinch
LukeFinch / BlockText.ts
Last active May 16, 2022 17:17
Text to multiple block lines
let input = figma.currentPage.selection[0] as TextNode
await figma.loadFontAsync(input.fontName as FontName)
let text = input.characters
let frame = figma.createFrame()
frame.fills = []
frame.clipsContent = false
frame.layoutMode = "VERTICAL"
This file has been truncated, but you can view the full file.
{
"host": "fonts.gstatic.com",
"asset_url_pattern": "/s/i/{family}/{icon}/v{version}/{asset}",
"families": [
"Material Icons",
"Material Icons Outlined",
"Material Icons Round",
"Material Icons Sharp",
"Material Icons Two Tone"
],
Initialize engine version: 5.6.7f1 (e80cc3114ac1)
GfxDevice: creating device client; threaded=1
Direct3D:
Version: Direct3D 11.0 [level 11.1]
Renderer: NVIDIA GeForce RTX 3080 (ID=0x2206)
Vendor: NVIDIA
VRAM: 10077 MB
Driver: 27.21.14.6140
Begin MonoManager ReloadAssembly
Platform assembly: F:\SteamLibrary\steamapps\common\Cities_Skylines\Cities_Data\Managed\UnityEngine.dll (this message is harmless)
@LukeFinch
LukeFinch / figma-font-metrics.ts
Created October 1, 2021 17:04
Figma Function to generate font-metrics for use in libraries like SeekOSS Capsize
type FontMetrics = {
capHeight: number,
ascent: number,
descent: number,
lineGap: number,
unitsPerEm: number
}
async function makeMetrics(fontName: FontName, unitsPerEm: number){
@LukeFinch
LukeFinch / zeroResize.js
Created April 8, 2021 17:16
Resizes a node to less than 0.01 px
function zeroResize(node, width, height){
//Workaround to resize a node, if its size is less than 0.01
node.resize(width < 0.01 ? 1 : width,height < 0.01 ? 1 : height)
if(width < 0.01 || height < 0.01){
let dummy = figma.createRectangle()
dummy.resize(width < 0.01 ? 1/width : width,height < 0.01 ? 1/height : height)
let group: GroupNode = figma.group([node,dummy],figma.currentPage)
group.resize(width < 0.01 ? 1 : width,height < 0.01 ? 1 : height)
group.parent.appendChild(node)
group.remove()
@LukeFinch
LukeFinch / rotate-center.js
Created January 6, 2021 11:15
figma plugin to rotate selection around the center of itself.
let angle = 45
let theta = angle * (Math.PI/180) //radians
let sel = figma.currentPage.selection[0]
//cx,cy is the center of the node
let cx = sel.x + sel.width/2
let cy = sel.y + sel.height/2
let newx = Math.cos(theta) * sel.x + sel.y * Math.sin(theta) - cy * Math.sin(theta) - cx * Math.cos(theta) + cx
let newy = - Math.sin(theta) * sel.x + cx * Math.sin(theta) + sel.y * Math.cos(theta) - cy * Math.cos(theta) + cy
@LukeFinch
LukeFinch / Teasers.csv
Created October 6, 2020 09:44
A CSV of 1000 teasers, used for testing purposes. They need to be unescaped when used.
We can make this file beautiful and searchable if this error is corrected: It looks like row 10 should actually have 3 columns, instead of 2. in line 9.
kicker,headline,video
MC-CUFF-EE,Tech%20guru%20John%20McAfee%20arrested%20in%20Spain%20over%20%27multi-million%20dollar%20tax%20evasion%27,false
CARJACK%20HORROR,Boy%2C%20one%2C%20killed%20as%20%27carjacker%20mows%20him%20down%20in%20mother%27s%20arms%27,true
BOTHAM%20AT%20LORDS,England%20cricket%20legend%20Sir%20Ian%20Botham%20sworn%20into%20House%20of%20Lords,true
BURR-FECT%20YOKEL%20TALK%20,Korean%20YouTuber%20to%20visit%20Plymouth%20so%20fans%20can%20hear%20his%20Devon%20accent,true
WILLIAM%27S%20TEARS,Prince%20William%20%27wept%20after%20mum%20Diana%20admitted%20to%20adultery%20on%20TV%27,true
%27RESENTMENT%27,PM%20%27un%ADlikely%20to%20get%20warm%20welcome%20from%20White%20House%20if%20Biden%20wins%20US%20election%27,false
%27WORTHY%20OF%20CELEBRATION%27,Kill%20Bill%20actor%20Clark%20Middleton%20dies%20aged%2063%20from%20%27West%20Nile%20Virus%27,true
NINA%20KEENER%20ON%20LEANER,Model%20Nina%20Adgal%20stuns%20in%20swimwear%20after%20launching%20a%20new%20exercise%20app,false
PAY%20BOOST,Thousands%20on%2
let sel = context.selection
sel.forEach(layer => {
layer.frame = layer.parentArtboard().frame()
if(layer.class() == 'MSTextLayer'){
let txt = layer.stringValue()
layer.stringValue = 'T'
layer.frame().y = layer.frame().y() - (layer.pathInFrame().bounds().origin.y - layer.frame().y())
layer.stringValue = txt
}