-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpolygon.js
More file actions
35 lines (33 loc) · 915 Bytes
/
Copy pathpolygon.js
File metadata and controls
35 lines (33 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
export default class Polygon {
static serNum = 0;
static hex = (x, y) => [
[x + 0, y + 7],
[x + 7, y + 0],
[x + 14, y + 7],
[x + 14, y + 39],
[x + 7, y + 46],
[x + 0, y + 39],
];
constructor(drawing, x, y, color) {
this.serNum = Polygon.serNum++;
this.drawing = drawing;
this.x = x;
this.y = y;
this.color = color;
this.hexagon();
}
hexagon = () => {
let poly = this.drawing.polygon(Polygon.hex(this.x, this.y));
// poly.on(["mousedown", "touchstart"], (e) => {
// console.log(
// `Clicked! serNum: ${this.serNum}; x=${e.target.points[0].x}; y=${e.target.points[0].y}`
// );
// poly.fill(this.color === "red" ? "white" : "red");
// });
// poly.on(["mouseup", "mouseout", "touchend", "touchcancel"], () =>
// poly.fill(this.color)
// );
poly.fill(this.color);
poly.stroke({ width: 0 });
};
}