Animate Rectangle Through Noise Field
in
Programming Questions
•
1 year ago
Hello,
I've been working on this sketch in which a rectangle is animated across the screen while rotating at angles determined using random noise. I like the results however I'm looking to take it a step further. Currently, a single rectangle is animated to move across the screen and then return to the left after it completes a row to begin a new row- similar to a typewriter. This results in random rotation along it's path and each row is not related to the one above or below it. How can I pass the rectangle through a noise field rather than just applying noise to the rotation angles as it moves along the path? I'm looking for rotation angles to change across the field of sketch rather than only the linear path. Please take a look at the sketch to understand what I mean. Any feedback would be greatly appreciated. Thank you!!!!
- float xoff = 0.0;
- float x,y, xspeed, yspeed, angA;
- void setup() {
- size(600,400);
- background(255);
- }
- void draw() {
- noiseDetail(2,0.87);
- x += 3;
- xoff = xoff + .01;
- float n = noise(xoff) * width;
- pushMatrix();
- stroke(0);
- //noFill();
- //fill(n);
- //if (n*1.5 >= 180) {
- // fill(15);
- // } else {
- // fill(255);
- // }
- translate(x,y);
- rotate(radians(n*1.4));
- rectMode(CENTER);
- fill(255);
- rect(0,0,30,60);
- //box(60,30,3);
- popMatrix();
- //line(n, 0, n, height);
- if (x >= width+100) {
- x = 0;
- y+= 20;
- }
- if (y>= height) {
- y = 0;
- }
- }
- //void keyPressed() {
- // saveFrame("surface####.jpg");
- //}
1