-
Notifications
You must be signed in to change notification settings - Fork 0
/
sketch.js
112 lines (82 loc) · 1.96 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
var palettesize = 55;
var platetteGutter;
var redChalk, orangeChalk, yellowChalk, greenChalk, blueChalk, purpleChalk, whiteChalk;
var eraser;
var eraseAll;
var eraseOn = false;
var colorChalk = ["#DC4266", "#EB9554", "#dbc115", "#86C0AB", "#5BADD8", "#8191C9", "#FFFFFF"]
function setup() {
createCanvas(windowWidth, windowHeight);
background(0);
strokeJoin(ROUND)
strokeCap(ROUND)
stroke(colorChalk[6]);
whiteChalk = select('#white');
whiteChalk.mousePressed(whiteColor);
redChalk = select('#red');
redChalk.mousePressed(redColor);
orangeChalk = select('#orange');
orangeChalk.mousePressed(orangeColor);
yellowChalk = select('#yellow');
yellowChalk.mousePressed(yellowColor);
greenChalk = select('#green');
greenChalk.mousePressed(greenColor);
blueChalk = select('#blue');
blueChalk.mousePressed(blueColor);
purpleChalk = select('#purple');
purpleChalk.mousePressed(purpleColor);
eraser = select('#eraser');
eraser.mousePressed(erase);
eraseAll = select('#erase-all');
eraseAll.mousePressed(cleanAll);
}
function touchMoved() {
if (!eraseOn) {
strokeWeight(4)
line(mouseX, mouseY, pmouseX, pmouseY);
return false;
} else {
fill(0, 0, 0, 100);
noStroke();
ellipse(mouseX, mouseY, 100, 100);
return false;
}
}
function whiteColor() {
eraseOn = false;
stroke(colorChalk[6]);
}
function redColor() {
eraseOn = false;
stroke(colorChalk[0]);
}
function orangeColor() {
eraseOn = false;
stroke(colorChalk[1]);
}
function yellowColor() {
eraseOn = false;
stroke(colorChalk[2]);
}
function greenColor() {
eraseOn = false;
stroke(colorChalk[3]);
}
function blueColor() {
eraseOn = false;
stroke(colorChalk[4]);
}
function purpleColor() {
eraseOn = false;
stroke(colorChalk[5]);
}
function erase() {
eraseOn = true;
}
function cleanAll() {
eraseOn = false;
clear();
}
// function windowResized() {
// resizeCanvas(windowWidth, windowHeight);
// }