@d-healey said in Is there a method to rotate a path?:
@VirtualVirgin Instead of making a function to rotate a path, why not make a function to create a rotated path. You can pass in the data you would have used to create the initial path.
So based on your suggestion I came up with this and it seems to work:
inline function createRotatedPath(pathArray, angle, area) { local rad = Math.toRadians(angle); local cosA = Math.cos(rad); local sinA = Math.sin(rad); local path = Content.createPath(); local rotationCenterX = area[0] + (area[2] * 0.5); local rotationCenterY = area[1] + (area[3] * 0.5); for (i = 0; i < pathArray.length; i++) { local x = pathArray[i][0]; local y = pathArray[i][1]; local newX = (x - rotationCenterX) * cosA - (y - rotationCenterY) * sinA + rotationCenterX; local newY = (x - rotationCenterX) * sinA + (y - rotationCenterY) * cosA + rotationCenterY; if (i == 0) path.startNewSubPath(newX, newY); else path.lineTo(newX, newY); } path.closeSubPath(); return path; }The pathArray is a 2D array of x,y points
i.e.
[[x,y],[x,y] etc..]