xxxxxxxxxx
109
let x = 0; //x position
let y = 0; //y position
let z = 0; //angle
let h = 0.9; //angle offset
let p = 0; //pulse
let d = 0; //distance from mouse position
function setup() {
//creating setup
createCanvas(600, 600);
noStroke();
}
function draw() {
background(0);
x1=mouseX; //defining x-position
y1=mouseY; //defining y-position
let r = map(mouseX, 0, width, 0, 450); //red value
let g = map(mouseY, 0, height, 450,0); //green value
let b = map(mouseX+mouseY, 0, width+height, 0, 450); //blue value
col= color(r,g,b); //colour of stroke
stroke(col); //defining stroke colour
noStroke();
if(p>21){ //frame 21
d=70; //distance
p=0; //pulse animation reset
}
if(p>20){ //frame 20
d=85;
}
if(p>19){ //frame 19
d=95;
}
if(p>18){ //frame 18
d=100;
}
if(p>17){ //frame 17
d=95;
}
if(p>16){ //frame 16
d=85;
}
if(p>15){ //frame 15
d=70;
}
else{ //other frames
d=50;
}
push();
fill(r,g,b,255*1.0); //colour and opacity
x = mouseX+cos(z)*d; //x position of ellipse
y = mouseY+sin(z)*d; //y position of ellipse
ellipse(x,y,30);
pop();
push();
fill(r,g,b,255*0.8);
x = mouseX+cos(z-h)*d;
y = mouseY+sin(z-h)*d;
ellipse(x,y,30);
pop();
push();
fill(r,g,b,255*0.6);
x = mouseX+cos(z-h*2)*d;
y = mouseY+sin(z-h*2)*d;
ellipse(x,y,30);
pop();
push();
fill(r,g,b,255*0.4);
x = mouseX+cos(z-h*3)*d;
y = mouseY+sin(z-h*3)*d;
ellipse(x,y,30);
pop();
push();
fill(r,g,b,255*0.2);
x = mouseX+cos(z-h*4)*d;
y = mouseY+sin(z-h*4)*d;
ellipse(x,y,30);
pop();
push();
fill(r,g,b,255*0.0);
x = mouseX+cos(z-h*5)*d;
y = mouseY+sin(z-h*5)*d;
ellipse(x,y,30);
pop();
push();
fill(col);
x = mouseX+cos(z-h*6)*d;
y = mouseY+sin(z-h*6)*d;
ellipse(x,y,30);
pop();
z=z+0.1; //angle increment addivtive
p=p+1; //pulse timer
}