xxxxxxxxxx
84
var colorg = 50;
var colorb = 30;
var colorbdir = 1;
var colorgdir = 1;
//
var vertexX = 30;
var vertexY = 100;
var unox = 50;
var unoy = 50;
//ellipse (vertexXSin, height/2, 10,10);
//ellipse (vertexXSin, 5, 10,10);
function setup() {
createCanvas(windowWidth, windowHeight);
}
function draw() {
//SOLVED IT substituded colorbdir =- colorbdir to colorbdir*=-1
background (0,colorg,colorb);
colorg += colorgdir;
colorb += colorbdir;
if (colorb>=255 || colorb<=2){
colorbdir *= -1;
}
if (colorg>=155 || colorg<=5){
colorgdir *= -1;
}
//Hidded drawing unadvertedlly by locking the above in one function
onda (100,0,200,-100,0.001);
onda (200,0,400,-200,0.001);
onda (300,0,600,-200,0.001);
onda (400,0,800,-200,0.001);
onda (500,0,1000,-200,0.001);
mosca(50,50);
// moscaFly(50,50,1,1);
//mosca(150,500);
//moscaFly(150,500,1/2,-1/2);
//mosca(50,100);
//moscaFly(50,100,1/2,-1/2);
//WAVES:Playing with math that I do not get but looks pretty neat the goal is to make waves
function onda(x,y,xsinY,ysinY,slow){
vertexX += 0.5;
vertexY += 1;
fill(0,25,155,60);
beginShape();
vertex(x, windowHeight);
var vertexXSin = map (sin(vertexX * slow), -1, 1, 0, xsinY);
var vertexYSin = map (sin(vertexY * slow), -1, 1, 10, ysinY);
bezierVertex(vertexXSin, mouseX,vertexXSin,vertexYSin ,x,y);
endShape();
}
//INSECTS
function mosca(mX,mY){
mX=mX+1;
fill (0,0,mouseY);
ellipse (mX, mY, 70,30);
beginShape();
vertex(mX, mY);
bezierVertex(mX-250, unoy-120,mX, mY-mouseY, mX, mY);
endShape();
vertex(mX, mY);
bezierVertex(mX-50, unoy-60, mX, mY-mouseY, mX, mY);
endShape();
}
function moscaFly (mX,mY,flyX,flyY) {
mX = mX + flyX;
mY = mY + flyY;
}
}