Skip to content

Instantly share code, notes, and snippets.

@lizzybrooks
Last active November 6, 2017 18:57
Show Gist options
  • Save lizzybrooks/e49d5951b1bcb9ad9b4f70462edaea0a to your computer and use it in GitHub Desktop.
Save lizzybrooks/e49d5951b1bcb9ad9b4f70462edaea0a to your computer and use it in GitHub Desktop.
//This sketch draws a row of pink donuts.
//donut object
var donut = {
x:70,
y:200,
diameter:100,
hole:40
};
//pink color object
var pink = {
r : 200,
g : 0,
b : 100
};
function setup() {
createCanvas(1000, 600);
//draw 8 donuts
for (var i=0; i<6; i++) {
fill(pink.r,pink.g,pink.b); //here I can make my donut a color
drawDonut();
donut.x = donut.x+120;
}
}
function draw() {
}
// my donut function
// notice I can remove the inputs because I now set those via the donut object at the top of the sketch.
function drawDonut(){
ellipse(donut.x, donut.y, donut.diameter, donut.diameter);
fill(255);
ellipse(donut.x, donut.y, donut.hole, donut.hole);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment