Ralph-Assignment-04-GIF
This was an interesting piece for me, as its concept developed further as I felt more comfortable with animating through Processing and programming with Java. As shown in my sketch, I originally intended to create a very simply pattern of movement among lines and dots to keep the work manageable, but as I wrote the code, I started playing for a stronger visual effect. Algorithmic animation always mystified me, but sinking my teeth into the basics gave me a new perspective on this particular art form — both a de-mystification and a new-found respect.
float dx = 20;
float dy = 20;
boolean reverse;
void setup() {
size(600, 600);
}
void draw() {
background(0);
dots();
if (dx == 91) { //line direction change
reverse = true;
}
if (dx == -11) {
reverse = false;
}
if (reverse) { //animate
dx--;
dy--;
}
else {
dx++;
dy++;
}
}
void dots() { //draw dots in a matrix
for (int row = 0; row < 7; row++) {
for (int col = 0; col < 7; col++) {
stroke(255);
strokeWeight(10);
point(col*100, row*100);
cardLines(row, col);
diagLines(row, col);
print(row);
}
}
}
void cardLines(int row, int col) { //draw lines in cardinal direction
for (int line = 0; line < 4; line++) {
pushMatrix();
cardColor(line);
translate(col*100, row*100);
rotate(PI*line/2);
line(dx, 0, dx+20, 0);
popMatrix();
}
}
void diagLines(int row, int col) { //draw lines in diagonals
for (int line = 0; line < 4; line++) {
pushMatrix();
diagColor(line);
translate(col*100, row*100);
rotate(PI*line/2);
line(dx, dy, dx+20, dy+20);
popMatrix();
}
}
void cardColor(int line) {
if (line == 0) {
stroke(255,0,0,122);
}
else if (line == 1) {
stroke(0,255,0,122);
}
else if (line == 2) {
stroke(255,0,0,123);
}
else if (line == 3) {
stroke(0,255,0,123);
}
}
void diagColor(int line) {
if (line == 0) {
stroke(0,0,255,122);
}
else if (line == 1) {
stroke(255,255,0,122);
}
else if (line == 2) {
stroke(0,0,255,123);
}
else if (line == 3) {
stroke(255,255,0,123);
}
}