-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdot.js
More file actions
30 lines (25 loc) · 694 Bytes
/
dot.js
File metadata and controls
30 lines (25 loc) · 694 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
import { getRandomSpawn } from './helper';
class Dot {
constructor(ctx, canvas) {
this.ctx = ctx;
this.canvas = canvas;
this.parameters = {
x: getRandomSpawn(550, 120),
y: getRandomSpawn(550, 120),
radius: 10
}
}
drawDot() {
let { x, y, radius } = this.parameters;
this.ctx.beginPath();
this.ctx.arc(x, y, radius, 0, Math.PI*2);
this.ctx.fillStyle = "blue";
this.ctx.fill();
this.ctx.closePath();
};
reposition() {
this.parameters.x = getRandomSpawn(550, 120);
this.parameters.y = getRandomSpawn(550, 120);
}
}
export default Dot;