This is my project of the moon phases!
sketch
// Natalie Koch
// nataliek
// Section A
// The Phases of the Moon
var diam = 300
var value = 255
var canvasX = 600
var canvasY = 450
function setup() {
createCanvas(canvasX, canvasY);
}
function draw() {
background(0);
mouseX = constrain(mouseX,25,575) //motion constraints
mouseY = constrain(mouseY,225,225) //motion constraints
if (width/2-mouseX >= 0) {
diam = mouseX
value = (mouseX/canvasX)*255
} else if (width/2-mouseX < 0) { //size variations as moon moves
diam = width-mouseX}
value = (mouseX/canvasX)*255
fill(255,255,value)
ellipse(mouseX,mouseY,diam,diam) //moon
ellipse(50,30,10,10)
ellipse(100,50,10,10)
ellipse(120,70,10,10)
ellipse(160,30,10,10)
ellipse(200,60,10,10)
ellipse(250,30,10,10) // } stars
ellipse(300,40,10,10)
ellipse(350,20,10,10)
ellipse(400,50,10,10)
ellipse(450,30,10,10)
ellipse(500,60,10,10)
ellipse(550,30,10,10)
fill(0)
ellipse(-75,height/2,400,400) //black circles on sides so moon can crescent
ellipse(675,height/2,400,400)
}