Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This example shows how to use functions around the code of legible and simple shapes blocks (modularization).


Code Block
void setup()
{
  size(300,300);
  smooth();
  stroke(255,255,255);
  noFill();
}
 
void draw()
{
  background(0);
 
  bommel(100,10,140,50);
  bommel(150,10,190,50);
  bommel(200,10,240,50);
}
 
void bommel(int x,int y,int length,int size)
{
  strokeWeight(1);
  line(x,y,x,y+length);
  strokeWeight(5);
  ellipse(x,y+length,size,size);
}

...