Skip to content

Instantly share code, notes, and snippets.

Created August 30, 2017 00:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/60c565b742edadae23762b2e6a55ed0a to your computer and use it in GitHub Desktop.
Save anonymous/60c565b742edadae23762b2e6a55ed0a to your computer and use it in GitHub Desktop.
/**
* This function draws maths counters
* Those little things from school used to learn to count
* It takes 2 parameters (x and y) which define
* the position of the target that is drawn.
* x: the distance in pixels from the top left
* y: the distance in pixels from the top right
**/
void drawMathCounter(float x, float y) {
// CReate a loop that causes about 10 circles to be drawn
for (int i = 0; i < 100; i = i + 11) {
if (i%2 == 0) { // this line says "if i is an even number then..."
stroke(0, 100);
fill( 0, 100 ); // fill in white
} else { // otherwise
float r = random(255);
float g = random(255);
float b = random(255);
strokeWeight(4);
stroke(r,g,b, 100);
fill(r,g,b, 140 ); // fill in black
}
ellipse(random(100) + x, random(100) +y, i, i);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment