Spiral generation
in
Programming Questions
•
5 months ago
Hello all,
I trying to draw something similar a tree section:
To do this I drawing a spiral and using a vertical line as a brush that rotates to the spiral direction while it is being generate.
Here is my code:
- float dist = 1, radius = dist/2, alpha = 0, speed = 50;
- float px, py, x, y, k;
- float puntoFijoY =30;
- void setup() {
- size(1024, 768);
- background(255);
- smooth();
- frameRate(25);
- }
- void draw() {
- k = speed/radius;
- alpha += k;
- radius += (dist+puntoFijoY)/(360/k);
- x = radius*cos(radians(alpha));
- y = -radius*sin(radians(alpha));
- float dx = x - width/2;
- float dy = x - height/2;
- float radianes = atan2(dy,dx);
- pushMatrix();
- translate(width/2, height/2);
- translate(x,y);
- rotate(abs(radianes *180/PI));
- stroke(153,51,50);
- //rect(x,y,10,5);
- line(0, 0, 0, 10);
- popMatrix();
- }
Do you know how to do this.
Salutations,
G
1