topical media & game development

talk show tell print

graphic-processing-site-examples-Basics-Structure-Functions-Functions.pde / pde



  
Functions. The drawTarget() function makes it easy to draw many distinct targets. Each call to drawTarget() specifies the position, size, and number of rings for each target.

  
  
  void setup() 
  {
    size(200, 200);
    background(51);
    noStroke();
    smooth();
    noLoop();
  }
  
  void draw() 
  {
    drawTarget(68, 34, 200, 10);
    drawTarget(152, 16, 100, 3);
    drawTarget(100, 144, 80, 5);
  }
  
  void drawTarget(int xloc, int yloc, int size, int num) 
  {
    float grayvalues = 255/num;
    float steps = size/num;
    for(int i=0; i<num; i++) {
      fill(i*grayvalues);
      ellipse(xloc, yloc, size-i*steps, size-i*steps);
    }
  }
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.