2021-10-17 18:26:00 +02:00
|
|
|
---
|
|
|
|
title: rotate()
|
|
|
|
---
|
2021-08-25 16:09:31 +02:00
|
|
|
|
|
|
|
```js
|
|
|
|
Point point.rotate(float angle, Point center)
|
2021-10-17 18:26:00 +02:00
|
|
|
```
|
2021-08-25 16:09:31 +02:00
|
|
|
|
|
|
|
Rotates a point the number of degrees you pass it around the point you pass it.
|
|
|
|
|
|
|
|
<Example
|
2021-10-17 18:26:00 +02:00
|
|
|
part="point_rotate"
|
|
|
|
caption="An example of the Point.rotate() method"
|
2021-08-25 16:09:31 +02:00
|
|
|
/>
|
|
|
|
|
|
|
|
```js
|
|
|
|
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}`]);
|
|
|
|
}
|
|
|
|
```
|