We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Simple question about functions
Page Index Toggle Pages: 1
Simple question about functions (Read 323 times)
Simple question about functions
Jul 6th, 2008, 10:54pm
 
Hey I'm new to both programming and Processing and was going through the examples in the 'learning' section and had a question I was hoping someone could answer:

During the learning examples, the two examples involving functions (entitled 'functions', and 'recursion') use commands that aren't listed anywhere in the reference section, these being drawCircle and drawTarget.

Is there part of the reference page I'm just not seeing or what?

Thanks
Re: Simple question about functions
Reply #1 - Jul 6th, 2008, 11:25pm
 
The functions are defined on those learning pages, immediately after they're used...

Quote:
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);
 }
}
Page Index Toggle Pages: 1