1
0
Fork 0
freesewing/markdown/dev/reference/api/point/rotate/en.md
2022-01-19 11:31:39 +01:00

885 B

title
Point.rotate()

A point's rotate() method returns a new Point that has been rotated by angle degrees around the point (center) that you pass it.

Just like the result of the Point.angle() method, an angle of 0° points right, and the angle increases counterclockwise.

Point.rotate() signature

Point point.rotate(float angle, Point center)

Point.rotate() example

An example of the4Point.rotate() method
let { Point, points, Path, paths, Snippet, snippets } = part.shorthand();

points.sun = new Point(40, 40);
points.moon = new Point(70, 40);
let step = 360 / 36;
for (let i = 1; i < 37; i++) {
  let angle = step * i;
  points[`moon${i}`] = points.moon.rotate(angle, points.sun);
  paths[`moon${i}`] = new Path().move(points.sun).line(points[`moon${i}`]);
}