Created
September 24, 2015 15:57
-
-
Save robertcdawson/cdbc461cb9d8140bdc2f to your computer and use it in GitHub Desktop.
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
// ref 1: http://toddmotto.com/mastering-the-module-pattern/ | |
// ref 2: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fillText | |
// create basic diagram module (w/ "revealing module" pattern from ref 1) | |
var D_ = (function() { | |
// draw container | |
var draw = function(label) { | |
var canvas = document.getElementById('canvas'); | |
if (canvas.getContext) { | |
var ctx = canvas.getContext('2d'); | |
// x, y, w, h | |
ctx.strokeRect(10, 10, 200, 200); | |
ctx.font = "1rem sans-serif"; | |
// "text", x, y, max width (will squeeze text) | |
ctx.fillText(label, 50, 100, 180); | |
} | |
}; | |
var step = function(label) { | |
draw(label); | |
}; | |
return { | |
step: step | |
}; | |
})(); | |
D_.step('Step 1'); | |
// make copy of D_ | |
// var D1_ = (function(D_){ | |
// var step = D_.step; | |
// return { | |
// step: step | |
// }; | |
// })(D_ || {}); | |
// | |
// D1_.step("Step 2"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment