Example of Method Comments
/*** drawfillbox **************************************
* Purpose: replicate the drawfillbox procedure from *
* Turing *
* Parameters: x1 - top left x coordinate *
* y1 - top left y coordinate *
* x2 - bottom right x coordinate *
* y2 - bottom right y coodinate *
* c - colour of the box *
* Returns: none *
******************************************************/
void drawfillbox(int x1, int y1, int x2, int y2, int c)
{
fill(c);
stroke(c);
rect(x1, y1, x2 - x1, y2 - y1);
}
/*** rollDice *****************************************
* Purpose: Find the sum of the roll of two dice *
* Parameters: none *
* Returns: sum of the two dice *
******************************************************/
int rollDice()
{
int d1, d2; // the two dice
d1 = (int)random(6) + 1;
d2 = (int)random(6) + 1;
return d1 + d2;
}
void setup()
{
size(500,500);
}
void draw()
{
stroke(0);
line(0,100,500,100);
line(100,0,100,500);
drawfillbox(100,100, 200, 200, #ff0000);
noFill();
stroke(0,255,0);
rect(100,200, 200,200);
}