Created
October 16, 2013 18:25
-
-
Save koenbok/7012440 to your computer and use it in GitHub Desktop.
Framer Canvas Example
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
var myCanvasView = new View({ | |
x:100, y:100, | |
width:200, height:200 | |
}) | |
// Add a nice background color so we see it | |
myCanvasView.style.backgroundColor = "rgba(255,0,0,.5)" | |
// This is the tricky bit, we create a canvas element (so we have a reference to it) and insert it into the view | |
myCanvas = document.createElement("canvas"); | |
myCanvasView._element.appendChild(myCanvas); | |
// Now we get a context to draw in | |
myCanvasContext = myCanvas.getContext("2d"); | |
myCanvasContext.fillStyle= "green"; | |
myCanvasContext.fillRect(0, 0, 100, 100); | |
The above is actually JavaScript, however if you remove the var
keyword, fix the indent on line 3 and change //
to #
it will pass as CoffeeScript.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
new View( )
isnew Layer( )
now. Also mind the indents for coffescript.