Created
September 11, 2012 10:03
-
-
Save jameshibbard/3697359 to your computer and use it in GitHub Desktop.
Function to draw a rectangle on a canvas element
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function clearCanvas(context, canvas) { | |
context.clearRect(0, 0, canvas.width, canvas.height); | |
var w = canvas.width; | |
canvas.width = 1; | |
canvas.width = w; | |
} | |
function highlightRoom(x, y, h, w){ | |
var can = document.getElementsByTagName('canvas')[0]; | |
var ctx = can.getContext('2d'); | |
clearCanvas(ctx, can); | |
ctx.strokeStyle = '#f00'; | |
ctx.lineWidth = 5; | |
ctx.lineJoin = 'round'; | |
ctx.strokeRect(x,y,h,w); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment