-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsketch.js
More file actions
48 lines (41 loc) · 752 Bytes
/
sketch.js
File metadata and controls
48 lines (41 loc) · 752 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
36
37
38
39
40
41
42
43
44
45
46
47
48
let rndCircle, saveButton, loadButton, dl;
function setup() {
createCanvas(640, 400);
dl = new DL();
rndCircle = new RndBox({
x: width / 2,
y: height / 2,
s: 100,
drawInside
})
dl.load((data)=>{
initialize(data);
})
}
const initialize = (data) => {
if(!data) {
rndCircle.setSize(100)
rndCircle.setPos({x: width/2, y: height/2})
} else {
rndCircle.setSize(data.size)
rndCircle.setPos({x: data.pos[0], y: data.pos[1]})
}
}
function mouseReleased() {
dl.save({
pos: rndCircle.getPos(),
size: rndCircle.getSize()
})
}
function draw() {
background(0);
rndCircle.display()
rndCircle.drag()
}
function drawInside({
s
}) {
fill(200, 10, 50)
stroke(0)
circle(0, 0, s)
}