Skip to content

Instantly share code, notes, and snippets.

@mpaltun
Created December 8, 2012 18:02
Show Gist options
  • Save mpaltun/4241186 to your computer and use it in GitHub Desktop.
Save mpaltun/4241186 to your computer and use it in GitHub Desktop.
/* built with Studio Sketchpad:
* http://sketchpad.cc
*
* observe the evolution of this sketch:
* http://sketchpad.cc/sp/pad/view/ro.VNh0DUzwa1U/rev.390
*
* authors:
* mustafa
* tayfun
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* http://creativecommons.org/licenses/by-sa/3.0/
*/
/* built with Studio Sketchpad:
* http://sketchpad.cc
*
* observe the evolution of this sketch:
* http://sketchpad.cc/sp/pad/view/ro.VNh0DUzwa1U/rev.204
*
* authors:
* mustafa
* tayfun
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* http://creativecommons.org/licenses/by-sa/3.0/
*/
// Pressing Control-R will render this sketch.
dim = 10;
world = [];
for(x = 0; x < dim; x++) {
row = [];
for(y = 0; y < dim; y++){
row[y] = Math.random() < 0.5 ? 0 : 1;
}
world[x] = row;
}
void setup() { // this is run once.
// set the background color
background(255);
// canvas size (Integers only, please.)
size(400, 400);
// smooth edges
smooth();
// limit the number of frames per second
frameRate(1);
// set the width of the line.
strokeWeight(0);
fill(204, 102, 0);
}
void draw_sphere(x, y) {
sphere(x, y);
}
void draw() { // this is run repeatedly.
// set the color
//stroke(random(50), random(255), random(255), 100);
rect_size = 40
/*
x = y = 0
rect(x * rect_size, y * rect_size, rect_size, rect_size);
*/
for (x in world) {
row = world[x];
for (y in row) {
cell = row[y];
if (cell == 1)
rect(x * rect_size, y * rect_size, rect_size, rect_size);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment