programmatically

Programmatically rotate shapes using coordinates

99封情书 提交于 2019-12-02 09:36:15
问题 If I have some shapes defined using arrays of coordinates e.g. [[-30, -30], [-30, 30], [30, 30], [30, -30]] and edges defined using: [[0,1],[0,3],[1,2],[2,3]] to make a square. How do I programmatically tell the shape to rotate *at the center against an angle of 0->359 in javascript? *Or better yet, is there a function which allows me to choose the center of rotation? ** Currently, I've managed to get the shape to circle the canvas using : var x_rotate = Math.sin(angle * Math.PI /180); var y