Skip to content

Instantly share code, notes, and snippets.

@lizzybrooks
Created November 6, 2017 19:11
Show Gist options
  • Save lizzybrooks/13969f8344e9a1fa2687447e89b38823 to your computer and use it in GitHub Desktop.
Save lizzybrooks/13969f8344e9a1fa2687447e89b38823 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,
drawDonut: function(){
ellipse(this.x, this.y, this.diameter, this.diameter);
fill(255);
ellipse(this.x, this.y, this.hole, this.hole);
},
moveDonut: function(){
this.x = this.x+1;
}
};
//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);
donut.drawDonut();
donut.moveDonut();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment