Created
January 26, 2022 14:42
-
-
Save jamesvclements/756607fdb4a7012432c50b9a3a96d820 to your computer and use it in GitHub Desktop.
Get the aspect ratio of the current selection with automator.design
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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