Skip to content

Instantly share code, notes, and snippets.

@maxhawkins
Created January 11, 2011 03:30
Show Gist options
  • Save maxhawkins/773969 to your computer and use it in GitHub Desktop.
Save maxhawkins/773969 to your computer and use it in GitHub Desktop.
Processing copy of Georg Nees's classic media art piece Schotter.
// Support Classes
class Vec3f {
float x, y, z;
Vec3f(float x, float y, float z) {
this.x = x;
this.y = y;
this.z = z;
}
void scale(float scale) {
this.x *= scale;
this.y *= scale;
this.z *= scale;
}
void offset(Vec3f offset) {
this.x += offset.x;
this.y += offset.y;
this.z += offset.z;
}
}
class Vec2f {
float x, y;
public Vec2f(float x, float y) {
this.x = x;
this.y = y;
}
}
// Constants
Vec3f DrawingOffset = new Vec3f(50, 50, 0);
Vec2f DrawingDimensions = new Vec2f(12, 23);
Vec3f CubeSize = new Vec3f(25, 25, 0);
float MaxOffsetJitter = 1;
float MaxRotationJitter = 10;
int rand_seed;
void setup() {
size((int) (DrawingOffset.x * 2 + DrawingDimensions.x * CubeSize.x), (int) (DrawingOffset.y * 2 + DrawingDimensions.y * CubeSize.y));
smooth();
noFill();
}
void mouseClicked() {
rand_seed++;
}
void draw() {
randomSeed(rand_seed);
background(255);
color(0);
for (int x = 0; x < DrawingDimensions.x; x++) {
for (int y = 0; y < DrawingDimensions.y; y++) {
pushMatrix();
int cubeNumber = (int) (y * CubeSize.y + x);
float jitterFactor = (float) cubeNumber / (DrawingDimensions.x + DrawingDimensions.y);
Vec3f center = new Vec3f(x * CubeSize.x, y * CubeSize.y, 0 * CubeSize.z);
center.offset(DrawingOffset);
Vec3f offsetJitter = new Vec3f(random(1), random(1), random(1));
offsetJitter.scale(jitterFactor * MaxOffsetJitter);
offsetJitter.z = 0;
center.offset(offsetJitter);
translate(center.x, center.y);
float rotationJitter = (random(1) - 0.5) * jitterFactor * MaxRotationJitter;
rotate(radians(rotationJitter));
rect(0, 0, CubeSize.x, CubeSize.y);
popMatrix();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment