Skip to content

Instantly share code, notes, and snippets.

@lizzybrooks
Created November 6, 2017 19:02
Show Gist options
  • Save lizzybrooks/3bb9c3513926234afb3be130d90116cd to your computer and use it in GitHub Desktop.
Save lizzybrooks/3bb9c3513926234afb3be130d90116cd to your computer and use it in GitHub Desktop.
//This sketch draws a pink donut that moves across the screen.
//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);
fill(pink.r,pink.g,pink.b); //here I can make my donut a color
}
function draw() {
background(255);
drawDonut();
moveDonut();
}
//my donut function
function drawDonut(){
ellipse(donut.x, donut.y, donut.diameter, donut.diameter);
fill(255);
ellipse(donut.x, donut.y, donut.hole, donut.hole);
}
//function that moves the donut across the screen
function moveDonut(){
donut.x = donut.x+1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment