Skip to content

Instantly share code, notes, and snippets.

@sam-g-steel
sam-g-steel / roundRect.js
Created March 13, 2017 23:56
Draws a rounded rectangle using the current state of the canvas
CanvasRenderingContext2D.prototype.roundRect =
/**
* Draws a rounded rectangle using the current state of the canvas.
* If you omit the last three params, it will draw a rectangle
* outline with a 5 pixel border radius
* @param {CanvasRenderingContext2D} ctx
* @param {Number} x The top left x coordinate
* @param {Number} y The top left y coordinate
* @param {Number} width The width of the rectangle
* @param {Number} height The height of the rectangle