Slow dragon curve fractal
in
Programming Questions
•
7 months ago
Hello all,
I made this program to test the dragon curve formula. I am stuck at a point to where to tell the program to continue drawing instead of drawing everything from the start. I want the animation, like how the fractal is beeing drawn, to speed up.
Is there a easy solution to read out the position and angle, for example?
Thanks!
I made this program to test the dragon curve formula. I am stuck at a point to where to tell the program to continue drawing instead of drawing everything from the start. I want the animation, like how the fractal is beeing drawn, to speed up.
Is there a easy solution to read out the position and angle, for example?
Thanks!
- boolean Bold;
- int lineLength = 3;
- HashMap ref = new HashMap();
- void setup() {
- size(1000, 800);
- background(255);
- for (int f = 0, c = 0; f<27000; f++)
- if ((f & ((f & -f)<<1))==0) ref.put(new Integer(c++), new Integer(0));
- else ref.put(new Integer(c++), new Integer(f));
- }
- void draw() {
- if (frameCount==27000) noLoop();
- translate(mouseX, mouseY);
- for (int i = 0; i<4; i++) {
- rotate(HALF_PI);
- stroke((i*16)+191, (i*32)+128, (i*32)+128);
- pushMatrix();
- for (int f = 0; f<frameCount; f++) {
- pushStyle();
- translate(lineLength, lineLength);
- Object result = ref.get(f);
- rotate((Integer) result == 0 ? -HALF_PI:HALF_PI);
- line(0, 0, lineLength, lineLength);
- popStyle();
- }
- popMatrix();
- }
- }
- void keyPressed() {
- if (key == CODED) {
- if (keyCode==LEFT) println(frameCount);
- if (keyCode==RIGHT) {
- background(255);
- if (Bold = !Bold) strokeWeight(2);
- else strokeWeight(1);
- }
- if (keyCode==UP) {
- background(255);
- lineLength++;
- }
- if (keyCode==DOWN) {
- background(255);
- lineLength--;
- }
- }
- }
- void mouseMoved() {
- background(255);
- }
1