xxxxxxxxxx
int x;
int y;
int w;
int z;
int a;
int numSpirals = 5;
int gridNum = 5;
float num = 0;
float counter = .01;
float yoff = 0.0;
float xoff = 0;
float angle = 0.0;
float scalar = 2;
float speed = 0.05;
float o;
float p;
// offset
float [] offsetX = new float [numSpirals];
float [] offsetY = new float [numSpirals];
//color b1, b2, c1, c2;
void setup () {
size(500, 500);
stroke(255);
fill(0);
//background(255);
smooth();
// spiral grid using modulo
for (int i = 0; i < numSpirals; i++) {
// this is how video pixels are manupulated. as video stores pixel info as an array, not a pixel grid
// for x = i % 5 draws up to 5 rows of thing; y = i / 5 makes it all the same, while all the xs are the same
// anything divided by that thing moves slower than the whole or modulo, so this way our y increases at a slower rate than our x
// i % gridnum * ___ increases the spaces between the spirals. + ___ offset
offsetX [i] = (i % gridNum)*150 + 120;
offsetY [i] = (i / gridNum)* 150 +50;
}
////colors
//// Define colors
//b1 = color(255);
//b2 = color(0);
//c1 = color(131, 148, 234);
//c2 = color(13, 29, 107);
//variables
x=250;
y=250;
w=100;
z=150;
a=250;
background (30);
}
void draw () {
eyeshape();
//lashes();
waves();
boat();
spirals();
}
void spirals () {
noStroke();
fill (255, 0, 0);
for (int s = 0; s < numSpirals; s++) {
o = offsetX [s] + cos(angle) * scalar;
p = offsetY [s] + sin(angle) * scalar;
ellipse(o, p, 2, 2);
}
// put this outside the for loop to reduce speed
angle += speed;
scalar += speed;
}
void eyeshape () {
fill(210, 0, 0);
ellipse (x, y, w+200, w+50);
//pupil
fill (210);
float pupilX = map(mouseX, 0, width, 250, 250);
float pupilY = map(mouseY, 0, height, 200, 300);
ellipse(pupilX, pupilY, w-50, w-50);
ellipse(pupilX, pupilY, w-50, w-50);
}
void waves () {
fill(0, 0, 0, 60);
beginShape();
float xoff = 20;
for (float x = 0; x <= width; x += 10) {
float y = map(noise(xoff, yoff), 0, 1, 200, 300);
vertex(x, y);
xoff += 0.05;
}
yoff += 0.01;
vertex(width, height);
vertex(0, height);
endShape(CLOSE);
}
void boat () {
float z = sin(num)*100+250;
fill(#493f45);//brownsihpurple
quad(z, a, z+20, a, z+10, a+10, z+4, a+10);
//sail
fill(#c1271f);//red
triangle(z+10, a-10, z+10, a-5, z+15, a-8);
line(z+10, a-5, z+10, a);
num += counter;
}
void mousePressed (){
saveFrame();
}