Skip to content

Instantly share code, notes, and snippets.

@iros
Created August 21, 2012 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iros/3417353 to your computer and use it in GitHub Desktop.
Save iros/3417353 to your computer and use it in GitHub Desktop.
Using BonsaiJS in JSFiddle
<div id="stage"></div>
<script>
(function(){
var s="script",
i="code",
n='\n',
d=document,
b=d.getElementsByTagName(s)[2].innerHTML.split(n);
d.write('<' + s + ' type="text/bonsaijs" id="' + i + '">' +
b.slice(2,b.length-3).join(n)+'</'+s+'>')
}
)();
</script>
<script>
$(function() {
var stage = document.getElementById('stage');
bonsai.run(stage, {
code: document.getElementById('code').innerHTML
});
});
</script>
var square = new Rect(0, 0, 100, 100);
square.addTo(stage);
square.fill('red');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment