Skip to content

Instantly share code, notes, and snippets.

//paste all your code
// make sure you don't forget the top or the bottom of your code. if you do that, it won't work.
//This sketch draws a row of pink donuts.
//donut object
var donut = {
x:70,
y:200,
diameter:100,
hole:40
};
@lizzybrooks
lizzybrooks / imageButton.js
Created November 3, 2017 20:41
How to make a button that is an image in p5.js
// To use an image as a button, replace the createButton() function with createImage() and attach the same functionality to the image as you would to the button.
// You must include the dom library in this sketch.
// This is adapted from the button example in the p5 dom library. https://p5js.org/reference/#/p5/createButton
var button;
function setup() {
//This sketch draws a pink donut that moves across the screen.
//donut object
var donut = {
x:70,
y:200,
diameter:100,
hole:40
};
//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(){
var person = {
x: 100,
y: 100,
drawPerson: function(){
fill(200);
stroke(200);
ellipse(this.x,this.y,50,50);
line(this.x,this.y,this.x,this.y+200);
},
//uses p5.speech.js
var myVoice;
var sayThis = "Oh hello. I am a computer talking to you.";
function setup(){
createCanvas(400, 400);
var button;
function setup() {
createCanvas(400, 400);
background(0);
button = createButton('click me');
button.position(19, 19);
//object.mousePressed(function() { yourFunction(yourInputs);});
button.mousePressed(function() {makeCircle(random(0,400),random(0,400));});
}
//make room for a person, person1, in this sketch.
let person1;
function setup() {
createCanvas(400, 400);
person1 = new Person(); //create person1 from the Person class
}
function draw(){
//create an empty array called people
let people = [];
function setup() {
createCanvas(400, 400);
}
function draw(){