Created
September 12, 2011 14:53
-
-
Save jaredwilli/1211461 to your computer and use it in GitHub Desktop.
Ideas to include in Canvas.js
This file contains hidden or 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
1. Context method - enables you to restore specific contexts saved throughout the app so that you can pass in a variable that contains it and return the context restoration. | |
2. renderToCanvas - method that is reusable for doing off-screen rendering of images and slower performing tasks so they can be returned and drawn to the main context easily. | |
var renderToCanvas = function (width, height, renderFunction) { | |
var buffer = document.createElement('canvas'); | |
buffer.width = width; | |
buffer.height = height; | |
renderFunction(buffer.getContext('2d')); | |
return buffer; | |
}; | |
Easier Methods For Canvas Drawing Goodness | |
ctx.circle() | |
ctx.ring() | |
ctx.timer() or ctx.clock() | |
ctx.animate() | |
ctx.update() | |
ctx.gradient() | |
ctx. | |
ctx. | |
ctx. | |
ctx. | |
ctx. | |
Use This Pattern? | |
/* Author: | |
Isobar | |
*/ | |
ISOBAR = { | |
init: function(){ | |
} | |
} | |
UTIL = { | |
fire : function(func,funcname, args){ | |
var namespace = ISOBAR; // indicate your obj literal namespace here | |
funcname = (funcname === undefined) ? 'init' : funcname; | |
if (func !== '' && namespace[func] && typeof namespace[func][funcname] == 'function'){ | |
namespace[func][funcname](args); | |
} | |
}, | |
loadEvents : function(){ | |
var bodyId = document.body.id; | |
// hit up common first. | |
UTIL.fire('common'); | |
// do all the classes too. | |
$.each(document.body.className.split(/\s+/),function(i,classnm){ | |
UTIL.fire(classnm); | |
UTIL.fire(classnm,bodyId); | |
}); | |
UTIL.fire('common','finalize'); | |
} | |
}; | |
// kick it all off here | |
$(document).ready(UTIL.loadEvents); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment