-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmySketch.js
57 lines (48 loc) · 1001 Bytes
/
mySketch.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
var col = [255, 255, 255];
var bx = 400;
var by = 100;
var boxSizeX = 700;
var boxSizeY = 200;
let overBox = false;
let locked = false;
function setup() {
createCanvas(windowWidth,windowHeight);
stroke(0);
fill(255);
rect(bx,by,boxSizeX,boxSizeY);
}
function draw() {
colorMode(HSB, 360,100,100);
centerX = 200;
centerY = 200;
beginShape(TRIANGLE_FAN);
vertex(200,200);
radius = 50;
noStroke();
for(var angle =0; angle <= 360; angle+=36){
var vx = centerX + cos(radians(angle))* radius;
var vy = centerY + sin(radians(angle))* radius;
vertex(vx, vy);
fill(angle, 100, 100);
}
endShape();
colorMode(RGB);
if ( mouseX > bx && mouseX < bx + boxSizeX && mouseY > by && mouseY < by + boxSizeY ) {
overBox = true;
}
else {
overBox = false;
}
}
function mousePressed() {
if (!overBox) {
col = get(mouseX, mouseY);
//print(col);
}
}
function mouseDragged() {
if (overBox == true) {
fill(col);
rect(mouseX,mouseY,5,5);
}
}