-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain3.js
92 lines (79 loc) · 2.03 KB
/
main3.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
function setup(){
createCanvas(600,600);
frameRate(30); //changes the framerate
}
let lines = [];
let currentThickness = 1;
const rSlider = document.getElementById("r");
const gSlider = document.getElementById("g");
const bSlider = document.getElementById("b");
function draw(){ //draw by default is 60 fps
background(255); //set the background to rgb(200,200,200)
//lines[]
//line = [point,point]
//mousex
//mousey
//pmousex previous mousex
//pmousey previous mousey
background("white");
noFill();
strokeWeight(5);
stroke("black");
rect(0,0,600,600);
strokeWeight(1);
lines.forEach(linePoints =>{
const [
[px,py],
[mx,my],
thickness,
[r,g,b]
] = linePoints;
stroke(r,g,b);
strokeWeight(thickness);
line(px,py,mx,my);
});
if (mouseIsPressed && (pmouseX !== mouseX || pmouseY !== mouseY))
lines.push([
[pmouseX,pmouseY],
[mouseX,mouseY],
currentThickness,
[+rSlider.value, +gSlider.value, +bSlider.value]
]);
}
//rectMode(CENTER);
//rect(200,200,100,100);
//ellipse(400,200,100,100);
//circle(600,600,100);
//triangle(100,100,200,100,400,300);
//quad(100,200,100,500,200,500,200,400);
//beginShape();
//vertex(240,240);
//list of vertices
//endShape(CLOSE);
//FILL (color)
//STROKE (color and weight)
//rectMode(CENTER);
//fill("bisque");
//rect(300,300,100,100);
/*function mouseMoved(){
lines.push([
[pmouseX, pmouseY],
[mouseX, mouseY]
])
}*/
function keyPressed(){
if (key === "t"){
currentThickness +=1 ;
}
if(key === "r"){
currentThickness -= 1;
}
currentThickness = constrain(currentThickness,1,25);
if(key == "c"){
lines = [];
}
}
//function mousePressed(){
//
// stroke(0);
//}