x = 0
y = 0
z = 0
B = 10
a = 10
let slider;
let randomcolor;
let randomcolors
let kleur;
function setup() {
createCanvas(600, 400);
background(255, 255, 255)
slider = createSlider(1, 100, a);
slider.position(10, 10);
slider.style('width', '80px');
randomcolors = ['red', 'blue', 'green', 'black','purple','pink'];
kleur = 'black'
}
function draw() {
a = slider.value();
frameRate(100000)
strokeWeight(1)
stroke(0)
fill("#A9A9A9")
rect(0, 0, 600, 80)
noFill()
fill(255,255,255)
ellipse(570, 25, 40, 40)
fill(0)
textSize(10)
text('Restart', 555,25)
randomcolor = random(randomcolors)
fill(randomcolor)
ellipse(520, 25, 40, 40)
fill('black')
textSize(20)
text('P', 515,30)
fill(0,0,225)
ellipse(470, 25, 40, 40)
fill('black')
textSize(20)
text('B', 465,30)
fill(0, 179, 60)
ellipse(420, 25, 40, 40)
fill('black')
textSize(20)
text('G', 413,30)
fill(255, 255, 0)
ellipse(370, 25, 40, 40)
fill('black')
textSize(20)
text('Y', 363,30)
fill(255, 117, 26)
ellipse(320, 25, 40, 40)
fill('black')
textSize(20)
text('O', 313,30)
fill(255, 0, 0)
ellipse(270, 25, 40, 40)
fill('black')
textSize(20)
text('R', 263,30)
fill(0)
ellipse(220, 25, 40, 40)
fill('white')
textSize(20)
text('Z', 213,30)
noFill()
strokeWeight(1)
fill(255, 255, 255)
ellipse(170, 25, 40, 40)
fill('black')
textSize(12)
text('eraser', 153,25)
noFill()
text(mouseX + "," + mouseY, 20, 40)
strokeWeight(a)
if (mouseIsPressed && mouseY >= 80) {
stroke(x, y, z)
line(mouseX, mouseY, pmouseX, pmouseY)
noFill()
}
if (mouseX > 470 - 20 && mouseX < 470 + 20 && mouseY > 25 - 20 && mouseY < 25 + 20) {
x = 0
y = 0
z = 255
} else if (mouseX > 420 - 20 && mouseX < 420 + 20 && mouseY > 25 - 20 && mouseY < 25 + 20) {
x = 0
y = 179
z = 60
} else if (mouseX > 370 - 20 && mouseX < 370 + 20 && mouseY > 25 - 20 && mouseY < 25 + 20) {
x = 255
y = 255
z = 0
} else if (mouseX > 320 - 20 && mouseX < 320 + 20 && mouseY > 25 - 20 && mouseY < 25 + 20) {
x = 255
y = 117
z = 26
} else if (mouseX > 270 - 20 && mouseX < 270 + 20 && mouseY > 25 - 20&& mouseY < 25+20){
x = 255
y = 0
z = 0
} else if (mouseX > 220 - 20 && mouseX < 220 + 20 && mouseY > 25 - 20 && mouseY < 25 + 20) {
x = 0
y = 0
z = 0
}
if(keyIsPressed){
if (key == 'r')
background(255,255,255)
}
else if (key == 'e'){
x = 255
y = 255
z = 255
}
else if (key == 'p'){
x = random(0,255)
y = random(0,255)
z = random(0,255)
}
}
// je moet op een random letter druken na het erasen, want anders wordt hett niet een kleur, dus wanneer je erased, druk je eerst op z en daarna op de zwarte kleur// de kleur die je wilt. hetzelfde wanneer je een random kleur wilt kiezen, eerst druk je op p en daarna weer op z zodat het een letter is.