-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.js
More file actions
89 lines (88 loc) · 1.31 KB
/
main.js
File metadata and controls
89 lines (88 loc) · 1.31 KB
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
let rectx = 940;
let recty = 362;
let width = 1880;
let height = 725;
let speedy = 1;
let speedx = 1;
let mincolor;
let r;
let g;
let b;
let rstep = 1;
let bstep = 1;
let gstep = 1;
let sw = 50;
let START = false;
function sliderChangeSW(val) {
sw = parseInt(val)
}
function sliderChangeSY(valy) {
speedy = parseInt(valy)
}
function sliderChangeSX(valx) {
speedx = parseInt(valx)
}
function sliderChangeR(valr) {
r = parseInt(valr);
}
function sliderChangeG(valg) {
g = parseInt(valg);
}
function sliderChangeB(valb) {
b = parseInt(valb);
}
function buttonStart(){
START = true;
}
function buttonStop(){
START = false;
}
console.log("i got here")
function setup(){
mincolor = random(70,155);
width = windowWidth - 40;
createCanvas(width,height);
frameRate(1000);
background(0);
r = random(70,256);
g = random(70,256);
b = random(70,256);
}
function draw(){
if(START){
//rect(x, y, width, height)
fill(r,g,b);
strokeWeight(0);
rect(rectx, recty, sw, sw);
if (rectx>=width-sw||rectx<=0){
speedx = -speedx
}
if (recty>=height-sw||recty<=0){
speedy = -speedy
}
rectx +=speedx;
recty +=speedy;
if (r>=255){
rstep = -1;
}
if (g>=255){
gstep = -1;
}
if (b>=255){
bstep = -1;
}
if (r<=mincolor){
rstep = 1;
}
if (g<=mincolor){
gstep = 1;
}
if (b<=mincolor){
bstep = 1;
}
r = (r+rstep);
g = (g+gstep);
b = (b+bstep);
console.log(r,g,b)
}
}