xxxxxxxxxx
107
let colorBite = 0;
let colorBite2 = 0;
let colorBite3 = 0;
let x = 0;
var r;
var g;
var b;
var a;
function setup() {
createCanvas(400, 400);
noStroke();
frameRate(15);
}
function draw() {
background(0);
let color = map(mouseX, 0, width, 100, 400);
let color2 = map(mouseX, width, 0, 100, 400);
let color3 = map(mouseY, 0, width, 100, 400);
//change of the origin
translate(width/2,height/2)
//star--------------------->>>
var bk = {
locationX : random(-200,200),
locationY : random(-200,200),
size : random(1,20)
}
//Star size -------------->>
ellipse(bk.locationX, bk.locationY, bk.size, bk.size);
fill(255,211,0)
//----------------popsicle stick---------->
fill('#E3C794')
rect(-10.5,-150,30,330,30,30,30,30)
//----------------popsicle body----------->
fill(color3,100,44)
rect(-65,2,140,79,0,0,20,20)
fill(209,color2,240)
rect(-65,-77,140,79)
fill(color,195,15)
rect(-65,-156,140,79,80,80,0,0)
//----------------posicle shape----------->
fill(250,250,250,150)
rect(-50.5,-125,40,184,50,50)
fill(250,250,250,150)
rect(19.5,-125,40,184,50,50)
//----- bites-------->>>>>
fill(0,colorBite)
ellipse(-40,-135,120,120)
ellipse(-2,-145,120,120)
ellipse(-2,-145,120,120)
ellipse(40,-145,100,100)
fill(0,colorBite2)
ellipse(-50,-50,120,120);
ellipse(32,-60,130,130)
fill(0,colorBite3);
ellipse(-50,40,120,120);
ellipse(32,26,130,130);
//-------text----->>>
r = random(200,215,15);
g = random(100,200);
b = random(100);
a = random(100,200,200);
fill(r,g,b,a);
textSize(20)
text('PRESS KEY 1 2 3 4',-74,-173)
}
//bites ---------------->>>>>>
function keyTyped (){
if(key === '1'){
colorBite = colorBite + 255
}
else if (key === '2'){
colorBite2 = colorBite2 + 255
}
else if (key === '3'){
colorBite3 = colorBite3 + 255
}
else if (key === '4') {
colorBite = colorBite - 255
colorBite2 = colorBite2 - 255
colorBite3 = colorBite3 - 255
}
}