const houseC = document.getElementById("House"); const colorC = document.getElementById("color"); const colorPick = document.getElementById("colorPicker"); /*Define dimensions of canvas */ houseC.width = 480; houseC.height = 480; colorC.width = 480; colorC.height = 480; /*Initialize canvas contexts */ const house = houseC.getContext("2d"); const color = colorC.getContext("2d"); /*Define points for house */ const housePoints = [ {x: houseC.width/2, y: houseC.height/3}, {x: houseC.width/3, y: houseC.height/2}, {x: houseC.width/3, y: houseC.height/4*3}, {x: houseC.width/3*2, y: houseC.height/4*3}, {x: houseC.width/3*2, y: houseC.height/2} ]; /*Initialize script */ clearCanvas(); drawHouseOutline(); drawHouse("#ffffff"); drawColors(); colorC.addEventListener("click", chooseColor, false); /*Changes color of the house depending on clicked color on colorCanvas */ function chooseColor(evt) { x = evt.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; //BUG: goes from -1 to 479 y = evt.clientY + document.body.scrollTop + document.documentElement.scrollTop; x -= colorC.offsetLeft; y -=colorC.offsetTop; if (((x>colorC.width/5) && (xcolorC.height/5*2) && (ycolorC.width/5*2) && (xcolorC.height/5*2) && (ycolorC.width/5*3) && (xcolorC.height/5*2) && (y