Lenticular Animation

For my lenticular animation, I thought it would be interesting to work on traditional computational patterns, such as the penrose pattern, generated by an L-system. Printing and having a physical representation of such a pattern is very appealing to me. I started with a simple penrose algorithm and played with different parameters and colors using randomness to derive different patterns. I settled on certain parameters that will make the generated image look like a snow flake.

 

snowflakeg

 

As for my process, I initially had some sketches of different designs and patterns. I found and implemented a few generative algorithms and started varying certain parameters to create patterns I like. Rather than a serial process of drawing a design then implementing, I was constantly sketching different alternatives. Mostly, my sketches were influenced by the output of the algorithms I wrote down. I can’t say that the output was something that I had sketched out initially then implemented, it was a more random and exploratory process. In that sense, the process was largely influenced by the algorithms I was using rather than the other way around.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
 
//===================================================
// Global variables. 
 
int     nFramesInLoop = 30; // for lenticular export, change this to 10!
int     nElapsedFrames;
boolean bRecording; 
 
String  myName = "mayakreidieh";
 
float[][] nse = new float [5000][2];
 
//===================================================
// Penrose pattern generator
String axiom = "[X]++[X]++[X]++[X]++[X]";
String W = "YF++ZF4-XF[-YF4-WF]++";
String X = "+YF--ZF[3-WF--XF]+";
String Y = "-WF++XF[+++YF++ZF]-";
String Z = "--YF++++WF[+ZF++++XF]--XF";
String F = "";
float step_len = 15*30.0;
int steps = 0;
float theta = radians(36); 
String generated = "";
 
void generate() {
  generated = axiom;
  for (int j = 0; j < 3; j++) {
    String temp = "";
    for (int i = 0; i < generated.length(); i++) {
      char step = generated.charAt(i);
      switch(step) {
        case 'W': temp = temp + W; break;
        case 'X': temp = temp + X; break;
        case 'Y': temp = temp + Y; break;
        case 'Z': temp = temp + Z; break;
        case 'F': temp = temp + F; break;
        default: temp = temp + step; break;
      }
    }
    step_len = step_len * 0.5;
    generated = temp;
    println(generated);
  }
}
void render() {
  translate(width/2, height/2);
  int pushes = 0;
  int repeats = 1;
  steps = (steps + 30) % generated.length();          
  for (int i = 0; i < steps; i++) {
    char step = generated.charAt(i);
    switch(step) {
      case 'F':
        strokeWeight(2);
        stroke(random(200), random(0,100), 255, 40);
        for (int j = 0; j < repeats; j++) {
          line(0, 0, 0 , - (step_len*noise(nse[i][1])*5) );
          ellipse(0,0,10*noise(nse[i][0]),4*noise(nse[i][0]));
          noFill();
          translate( 0 , -step_len);
          nse[i][0]+=2;
          nse[i][1]+=0.01;
        }
        repeats = 1; break;
      case '+': 
        for (int j = 0; j < repeats; j++) {
          rotate(theta);
        }
        repeats = 1; break;
      case '-': 
        for (int j =0; j < repeats; j++) {
          rotate(-theta);
        }
        repeats = 1; break;
      case '[': pushes++; pushMatrix(); break;
      case ']': popMatrix(); pushes--; break;
      case '3': repeats = 3; break;
      case '4': repeats = 4; break;
      default: break;
    }
  }
 
  while (pushes > 0) {
    popMatrix();
    pushes--;
  }
}
 
 
//===================================================
void setup() {
  size(500, 500);
  for (int i=0;i&lt;5000;i++){
   nse[i][0] = random(10); 
   nse[i][1] = random(10); 
  }
  generate();
}
 
void keyPressed() { 
  // Press a key to export frames to the output folder
  bRecording = true;
  nElapsedFrames = 0;
}
 
void draw() {
  background(255);
  render();
 
  // If we're recording the output, save the frame to a file. 
  if (bRecording) {
    saveFrame("output/"+ myName + "-loop-" + nf(nElapsedFrames, 4) + ".png");
    nElapsedFrames++; 
    if (nElapsedFrames == nFramesInLoop) {
      bRecording = false;
    }
  }
}