Very simple rectangular spiral sketch doesnt't work: what's wrong ?
in
Programming Questions
•
2 years ago
Hello,
I want to draw a spiral fitting in a rectangle. So my sketch is very basic.
However it doesn't work. I haven't worked with Processing for a while so I must have forgotten something obvious, but what ?
Thank you in advance for helping.
I want to draw a spiral fitting in a rectangle. So my sketch is very basic.
However it doesn't work. I haven't worked with Processing for a while so I must have forgotten something obvious, but what ?
Thank you in advance for helping.
- int myLength = 0; // initial axis length in number of squares
- int xpos = 0;
- int ypos = 0;
- void setup() {
- size(500, 500, JAVA2D);
- background(128, 128, 128);
- stroke(255, 255, 0);
- fill(255, 255, 0);
- rectMode(CENTER);
- // initial positioning
- xpos = width/2;
- ypos = height/2;
- translate (xpos, ypos);
- }
- void loop() {
- for (int i = 0; i < 50 ; i++) {
- myLength++;
- for (int j = 0; j < myLength; j++) { // units do draw per line extends from step to step
- rect(0, 0, 20, 20);
- translate(20, 0);
- }
- rotate(PI/2.); // rotates 90 degrees before next step
- }
- }
1