Skip to content

Instantly share code, notes, and snippets.

@geezyx
Created October 14, 2017 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geezyx/079157651d0a0c57de759feec438fa68 to your computer and use it in GitHub Desktop.
Save geezyx/079157651d0a0c57de759feec438fa68 to your computer and use it in GitHub Desktop.
Processing scarf code
int[] rules = { 0, 1, 0, 1, 1, 0, 1, 0 };
int gen = 1;
color on = color(255);
color off = color(0);
void setup() {
size(98, 1090);
background(0);
set(11, 0, on);
set(43, 0, on);
set(80, 0, on);
set(87, 0, on);
set(93, 0, on);
}
void draw() {
for (int i=1; i < width - 1; i++) {
int left = get(i - 1, gen - 1);
int me = get(i, gen - 1);
int right = get(i + 1, gen - 1);
if (rules(left, me, right) == 1) {
set(i, gen, on);
}
}
gen++;
if (gen > height - 1) {
noLoop();
}
save("knityak_rule90_325.tif");
}
int rules(color a, color b, color c) {
if ((a == on) && (b == on) && (c == on)) {
return rules[0];
}
if ((a == on) && (b == on) && (c == off)) {
return rules[1];
}
if ((a == on) && (b == off) && (c == on)) {
return rules[2];
}
if ((a == on) && (b == off) && (c == off)) {
return rules[3];
}
if ((a == off) && (b == on) && (c == on)) {
return rules[4];
}
if ((a == off) && (b == on) && (c == off)) {
return rules[5];
}
if ((a == off) && (b == off) && (c == on)) {
return rules[6];
}
if ((a == off) && (b == off) && (c == off)) {
return rules[7];
}
return 0;
}
@geezyx
Copy link
Author

geezyx commented Oct 14, 2017

  1. Download processing
  2. Paste code and run!

JPEG compressed output:
knityak_rule90_325

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment