Skip to content

Instantly share code, notes, and snippets.

@jamesvclements
Created January 26, 2022 14:42
Show Gist options
  • Save jamesvclements/756607fdb4a7012432c50b9a3a96d820 to your computer and use it in GitHub Desktop.
Save jamesvclements/756607fdb4a7012432c50b9a3a96d820 to your computer and use it in GitHub Desktop.
Get the aspect ratio of the current selection with automator.design
{
"id": "kyusryaodtnxwdjz49",
"name": "Get / Aspect Ratio",
"description": "",
"color": "blue",
"actions": [
{
"id": "kyussccta00o7d20od9",
"command": {
"name": "getCurrentSelection",
"metadata": {},
"title": "",
"description": ""
},
"actions": [
{
"id": "kyusuhf1h32zrwtle2a",
"command": {
"name": "runScript",
"metadata": {
"script": "function reduce(numerator, denominator) {\n var gcd = function gcd(a, b) {\n return b ? gcd(b, a % b) : a;\n };\n gcd = gcd(numerator, denominator);\n return [numerator / gcd, denominator / gcd];\n}\n\nconst node = figma.currentPage.selection[0];\nconst [numerator, denominator] = reduce(node.width, node.height);\nfigma.closePlugin(`${numerator}:${denominator}`);\n"
},
"title": "",
"description": ""
},
"actions": []
}
]
}
],
"createdAt": 1643156200032
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment