Skip to content

Instantly share code, notes, and snippets.

@koenbok
Created October 16, 2013 18:25
Show Gist options
  • Save koenbok/7012440 to your computer and use it in GitHub Desktop.
Save koenbok/7012440 to your computer and use it in GitHub Desktop.
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);
@meowgorithm
Copy link

meowgorithm commented Dec 3, 2017

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