xxxxxxxxxx
void setup() {
size(480, 480);
}
int tick;
void eWave(type, r, g, b) {
strokeWeight(5);
fill(r, g, b);
if (type == "sine") {
for (int x = -width * 5; x <= width; x += 20) {
stroke(0, 200, 200 + cos(x) * 5);
ellipse((x + cos(tick / 10)) + tick % 1800, (height / 2) + sin((tick + x) / 10) * (mouseY - height / 2), 15, 15);
}
} else if (type == "cosine") {
for (int x = -width * 5; x <= width; x += 20) {
stroke(0, 200 + sin(x) * 5, 200);
ellipse((x + sin(tick / 10)) + tick % 1800, (height / 2) + cos((tick + x) / 10) * (mouseY - height / 2), 15, 15);
}
} else {
print("Not an ewave.")
}
}
void bonds() {
for (int x = -width * 5; x <= width; x += 20) {
stroke(0, 200, 200 + sin(tick + x) * 5);
line((x + cos(tick / 10)) + tick % 1800, (height / 2) + sin((tick + x) / 10) * (mouseY - height / 2),
(x + sin(tick / 10)) + tick % 1800, (height / 2) + cos((tick + x) / 10) * (mouseY - height / 2));
}
}
void draw() {
background(50);
eWave("sine", 200, 60, 60);
eWave("cosine", 60, 200, 60);
bonds();
tick++;
}