Skip to content

Instantly share code, notes, and snippets.

@joeLepper
Created March 12, 2013 19:53
Show Gist options
  • Save joeLepper/5146391 to your computer and use it in GitHub Desktop.
Save joeLepper/5146391 to your computer and use it in GitHub Desktop.
var rectangle = { x : 0
, y : 0
, w : 10
, h : 10
, hugh : hue // 120
, satch : saturation // '50%'
, lite : light } // '50%'
, drawRec = function(recObj, modifyColor) {
// do some canvas setup stuff, then set the fill color...
if (modifyColor === 'undefined'){
canvasContext.fillStyle = 'hsl(' + recObj.hugh + ',' + recObj.satch + ',' + recObj.lite + ')';
}
else {
var moddedSatch = (parseInt(recObj.satch) + modifyColor ) + '%'
, moddedLite = (parseInt(recObj.satch) + modifyColor ) + '%'
canvasContext.fillStyle = 'hsl(' + recObj.hugh + ',' + moddedSatch + ',' + moddedLite + ')';
}
// draw some stuff
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment