-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsketch.js
57 lines (44 loc) · 1.18 KB
/
sketch.js
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
49
50
51
52
53
54
55
56
57
function setup() {
createCanvas(400, 400);
noStroke();
clickableObjectProps.pos.x = width * 0.5;
clickableObjectProps.pos.y = height * 0.5;
}
function draw() {
background('#030711');
if (clickableObjectProps.isOn) {
clickableObjectProps.curr_col = clickableObjectProps.col.on;
} else {
clickableObjectProps.curr_col = clickableObjectProps.col.off;
}
clickableObject({
x: clickableObjectProps.pos.x,
y: clickableObjectProps.pos.y
}, {
w: clickableObjectProps.res.w,
h: clickableObjectProps.res.h
},
clickableObjectProps.curr_col);
// buttonBoundsVis();
}
//visualize the bounds of the button - mouse needs to be in these bounds to be true
function buttonBoundsVis() {
strokeWeight(3)
stroke('white')
line(160, 0, 160, height)
line(0, 180, width, 180)
line(0, 220, width, 220)
line(240, 0, 240, height)
}
function mousePressed() {
if (isHovering({
x: clickableObjectProps.pos.x,
y: clickableObjectProps.pos.y
}, {
w: clickableObjectProps.res.w,
h: clickableObjectProps.res.h
})) {
clickableObjectProps.isOn = !clickableObjectProps.isOn;
}
// console.log(clickableObjectProps.isOn)
}