# What difference can the amount of parameters have for stroke()?

**URL:** <https://discourse.processing.org/t/what-difference-can-the-amount-of-parameters-have-for-stroke/12921>\
**Category:** Coding Questions\
**Created:** [July 23, 2019, 5:43pm UTC](https://discourse.processing.org/t/what-difference-can-the-amount-of-parameters-have-for-stroke/12921 "2019-07-23T17:43:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ludmuterol](https://avatars.discourse-cdn.com/v4/letter/l/e47774/32.png) [@Ludmuterol](https://discourse.processing.org/u/Ludmuterol)\
**Post date:** [July 23, 2019, 5:43pm UTC](https://discourse.processing.org/t/what-difference-can-the-amount-of-parameters-have-for-stroke/12921/1 "2019-07-23T17:43:31Z")

</div>

I have a project, which draws lines along Lissajous-like paths.  
Every now and then i want the line to change from one path to a newly generated one. In that moment i let the currentline disappear and the new one appear. every time a Line changes State from currently running to disappearing it jumps like 25 pixels(draw-function-calls) forward. I tested what may cause this and i think it’s because of my stroke() call. because if i change the stroke call to one with 3 parameters it works just fine and isn’t jumping any Pixels… Or if i give the stroke function a static parameter it stops jumping as well…

is it possibly a problem with my understanding of the stroke function? What can i change so it wont happen again?

If i should change my post/question, pls tell me.(First time)

eg:

```auto
static final int NUM_DOTS=350;
static final int NUM_LINES=1;
static final float FACTOR=1;
static final int TIMER=500;
int t=1;
float[] x_a=new float[NUM_LINES]; //a 5 - 50 b 80 - 200 
float[] x_c=new float[NUM_LINES];
float[] y_a=new float[NUM_LINES]; //a 5 - 50 b 80 - 200 
float[] y_c=new float[NUM_LINES];
float[] old= {0,0,0,0};
int curr=0;
void setup(){
  //frameRate(1);
  size(500,500);
  background(20);
  for(int i=0;i<NUM_LINES;i++){
    curr++;
    rerand(curr);
  }
  curr=0;
}
void draw(){
 background(20);
 strokeWeight(2);
 translate(width/2,height/2);
 for(int j=0;j<NUM_LINES;j++){
   if(j!=curr%NUM_LINES){
     for(int i=0;i<NUM_DOTS;i++){ //currently running lines
       stroke(255 - i*255/NUM_DOTS+20);
       point(x(t-i*FACTOR,j),y(t-i*FACTOR,j));
     }
   }else{
      int tmp_dots=(t%TIMER)*NUM_DOTS/TIMER*2;
      for(int i=0;i<tmp_dots&&i<NUM_DOTS;i++){ //current new one (growing)
         int tmp_a=tmp_dots<NUM_DOTS?255-i*255/tmp_dots+20:255-i*255/NUM_DOTS+20;
         
         stroke(tmp_a); //stroke(tmp_a,tmp_a,tmp_a); // ||THIS LINE IS THE ONE I AM TALKING ABOUT ||
         
         point(x(t-i*FACTOR,j),y(t-i*FACTOR,j));
      }  
   }
 }
 for(int i=0;i<NUM_DOTS;i++){
       int stroke=255-(i*255/NUM_DOTS)-(t%TIMER)*2;
       stroke(stroke>=20?stroke:20); //old one disappearing
       point(x(t-i*FACTOR,-1),y(t-i*FACTOR,-1));
     }
 t++;
 if(t%TIMER==0){
   curr++;
   rerand(curr);
 }
}
void rerand(int curr){
    old[0]=x_a[curr%NUM_LINES];
    old[1]=x_c[curr%NUM_LINES];
    old[2]=y_a[curr%NUM_LINES];
    old[3]=y_c[curr%NUM_LINES];
    x_a[curr%NUM_LINES]=random(25,50);
    x_c[curr%NUM_LINES]=random(25,50);
    y_a[curr%NUM_LINES]=random(25,50);
    y_c[curr%NUM_LINES]=random(25,50);
}
float x(float ts,int j){
   if(j>=0){
     return sin(ts/x_a[j]) *100 + sin(ts/x_c[j])*100;
   }
     return sin(ts/old[0]) *100 + sin(ts/old[1])*100;
}
float y(float ts,int j){
  if(j>=0){
     return cos(ts/y_a[j]) *100 + cos(ts/y_c[j])*100; 
  }
     return cos(ts/old[2]) *100 + cos(ts/old[3])*100;
}

```

---

<div class="post-metadata">

**Author:** ![Tiemen](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tiemen/32/5477_2.png) [@Tiemen](https://discourse.processing.org/u/Tiemen)\
**Post date:** [July 23, 2019, 9:22pm UTC](https://discourse.processing.org/t/what-difference-can-the-amount-of-parameters-have-for-stroke/12921/2 "2019-07-23T21:22:21Z")

</div>

When you use a single parameter for stroke() it sets the grayscale value for your lines, while using three parameters turns it into a colour. In the case of **stroke(tmp\_a,tmp\_a,tmp\_a)** it shows a black, grey or white line, since all parameters are the same value.

What _might_ be the issue is that the variable tmp\_a sometimes becomes bigger than 255. By trying out the following code you could see why this would be an issue when using a single parameter for stroke():

```auto
int tmp_a;

void setup() {
  size(500, 500);
  noLoop();
  background(20);
  strokeWeight(2);
}

void draw() {
  tmp_a = 255;
  stroke(tmp_a);
  line(0, 100, width, 100); // white line
  stroke(tmp_a, 0, 0);
  line(0, 200, width, 200); // red line
  
  tmp_a = 500;
  stroke(tmp_a);
  line(0, 300, width, 300); // white line won't be visible
  stroke(tmp_a, 0, 0);
  line(0, 400, width, 400); // red line will be visible
}

```

If you prevent tmp\_a from becoming bigger than 255, does it solve the pixel skip problem?
