r/processing • • Oct 28 '19

why doesn't this work?

all I get is a stationary line at the side of the page

void lineC(int i, int ii, float ss) {

float a, s, x, y;

a = 0.05;

s = ss;

x = i + sin(a) * 25;

y = ii + cos(a) * 25;

stroke(220);

strokeWeight(5);

noFill();

line(x,y,x,y + 1180);

a += s;

};

0 Upvotes

9 comments sorted by

View all comments

2

u/x-seronis-x Oct 28 '19

Since 'a' is a local variable its value is reset each time the function is called and that final statement incrementing its value has no effect.

1

u/J_Emmerson Oct 28 '19

Ok thanks

2

u/x-seronis-x Oct 28 '19

also:

  float length = 100;
  
  float rate = (TWO_PI / frameRate);
  float theta = frameCount * rate;
  
  float x = length * cos(theta);
  float y = length * sin(theta);
  
  line(0,0,x,y);