Created
October 12, 2015 00:56
-
-
Save jessherzog/225a6bc28731a41e7b09 to your computer and use it in GitHub Desktop.
code_Sketch4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Use oscillation (sin() and cos()) and loops (for or while) | |
PImage a; | |
float posX = 2; | |
float posY = 2; | |
float sizeX = 0; | |
float sizeY = 0; | |
float time = 0; | |
//float previousMillis = 0; | |
//int interval = 100; | |
color[] colors = new color[2]; | |
int selectedColor; | |
int timer; | |
void setup() { | |
size(421, 421); | |
a = loadImage ("fine.png"); | |
background(a); | |
smooth(); | |
//noStroke(); | |
colors[0] = color(107, 47, 222, 2); | |
colors[1] = color (0, 0, 0, 2); | |
} | |
void draw() { | |
posX = sin(time * 0.001) * 30; | |
posY = -cos(time * 0.001) * 30; | |
sizeX = -sin(time * 0.001) * 220; | |
sizeY = cos(time * 0.001) * 220; | |
for (int i = 0; i < 16; i++) { | |
for (int j = 0; j <= 10; j++) { | |
float offset = 16; | |
float distance = dist(posX + i * offset, posY + j * offset, posX, posY); | |
float s = dist(posX + i * offset, posY + j * offset, posX, posY); | |
pushMatrix(); | |
noFill(); | |
stroke(colors[selectedColor % colors.length]); | |
if (millis() - timer > 2000) { | |
selectedColor++; | |
timer = millis(); | |
} | |
rect(posX + i * offset, posY + j * offset, s/4, s/4); | |
translate(width/2, height/2); | |
tint(2); | |
stroke(222, 47, 88); | |
noFill(); | |
ellipse(posX, posY, sizeX, sizeY); | |
popMatrix(); | |
} | |
time++; | |
} | |
} | |
/* | |
float currentMillis = millis(); | |
if (currentMillis - previousMillis >= interval) { | |
previousMillis = currentMillis; | |
if (time++) { | |
} else { | |
time--; | |
noStroke(); | |
} | |
} */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment