Event mouse-click

function setup(  )
{
    createCanvas(1366, 700)
    background(0)
}

function draw (  )
{
    fill('green')
    rect ( 100,100,300,300 )
}

function mouseClicked()
{
    background(255)
}

How to change the background color by clicking only on the square ?

Answers

Sign In or Register to comment.