# Drawing with lines

**URL:** <https://discourse.processing.org/t/drawing-with-lines/28155>\
**Category:** Gallery\
**Created:** [March 1, 2021, 5:09am UTC](https://discourse.processing.org/t/drawing-with-lines/28155 "2021-03-01T05:09:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [March 1, 2021, 5:09am UTC](https://discourse.processing.org/t/drawing-with-lines/28155/1 "2021-03-01T05:09:33Z")

</div>

```auto
float x, y, angle, c;
variateur v1,v2;
 
void setup(){
  size(640,640);
  x = width/2;y = height/2;
  angle = random(TWO_PI); smooth();
  noFill();stroke(0,51);
  colorMode(HSB);c=random(255);
  background(0); v1=new variateur(1,6, 79); v2=new variateur(1,6, 79);
   
}
 
void draw(){
  c+=random(0.1,0.5);
  if(c>255){c-=255;}
  stroke(c,200,255, 51);
  angle+=random(-0.1,0.1);
  x=constrain(x+cos(angle)*1.5, 0, width);
  y=constrain(y+sin(angle)*1.5, 0, height);
  if((random(100)<2)||x==0||y==0||x==width||y==height){
    angle+=random(-1,1);
  }
  float t1 = v1.avance();
  float t2 = v2.avance();
  float an = atan2(y-height/2, x-width/2);
  float p1x=width/2+(x-width/2)*0.3, p1y=height/2+(y-height/2)*0.3,p2x=width/2+(x-width/2)*0.6 , p2y=height/2+(y-height/2)*0.6;
  beginShape();
  curveVertex(width/2, height/2);
  curveVertex(width/2, height/2);
  curveVertex(p1x+cos(an+PI/2)*t1,p1y+sin(an+PI/2)*t1);
  curveVertex(p2x+cos(an-PI/2)*t2,p2y+sin(an-PI/2)*t2);
  curveVertex(x, y);
  curveVertex(x, y);
   
  endShape();
}
 
class variateur{
  float etat, mini, maxi, pas, ecart,v;
  variateur(float _min, float _max, float _pas){
    ecart=(_max-_min)/2;
    mini=_min+ecart;
    etat = random(-1,1);
    v=random(0.01,0.02);
  }
  float avance(){
    etat+=v;
    return (mini+cos(etat)*ecart);
  }
}

void keyReleased(){
  save("img.png");
}

```

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [March 1, 2021, 5:10am UTC](https://discourse.processing.org/t/drawing-with-lines/28155/2 "2021-03-01T05:10:13Z")

</div>

![Untitled 47](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/0/0ff9f83438e885663b5a85258df5f784424b7839.jpeg)
