Add Initial commit
This commit is contained in:
24
CM2030 Graphics Programming/Topic 1/1.5.1/sketch.js
Normal file
24
CM2030 Graphics Programming/Topic 1/1.5.1/sketch.js
Normal file
@ -0,0 +1,24 @@
|
||||
let state = false;
|
||||
let locX = 200;
|
||||
let locY = 200;
|
||||
let w = 200;
|
||||
let h = 100;
|
||||
|
||||
function setup() {
|
||||
createCanvas(900, 600);
|
||||
}
|
||||
|
||||
function draw()
|
||||
{
|
||||
background(220);
|
||||
if(state == true) fill (255);
|
||||
else fill(0);
|
||||
|
||||
rect(locX, locY, w, h);
|
||||
}
|
||||
|
||||
function mousePressed()
|
||||
{
|
||||
if(mouseX > locX && mouseX < locX + w && mouseY > locY && mouseY < locY + h)
|
||||
state = !state;
|
||||
}
|
||||
Reference in New Issue
Block a user