This file contains 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
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 |