Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Framer Canvas Example
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);

blynx commented Jul 27, 2017

new View( ) is new Layer( ) now. Also mind the indents for coffescript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment