Totally deprecated. I recommend paper.js instead. I'll be keeping this page around because I think the documentation is cool. — george
gee.js is a library that makes it quick to start sketching with the HTML5 <canvas>
.
<canvas>
<script type="text/javascript" src="gui.min.js"></script>
<script type="text/javascript">
window.onload = function() {
var g = new GEE
( { fullscreen: true } );
g.draw = function() {
g.ctx.clearRect( 0, 0, g.width, g.height );
g.ctx.fillText( g.frameCount, 10, 10 );
};
g.mousedrag = function() {
g.ctx.beginPath();
g.ctx.moveTo( g.pmouseX, g.pmouseY );
g.ctx.lineTo( g.mouseX, g.mouseY );
g.ctx.stroke();
};
};
</script>
Passing the parameter fullscreen:true
to GEE
's constructor automatically removes padding/margin from the HTML document and appends a <canvas>
to the body that scales with the window.
You can override event properties such as draw
and mousedrag
to implement the behavior of your choosing. A complete list of GEE
's properties are below.
GEE
's constructorvar g = new GEE( { width: 600, height: 480, container: document.body } ); // … does the same thing as … var g = new GEE( { width: 600, height: 480 } ); document.body.appendChild( g.domElement );
var g = new GEE( { width: 200, height: 200, context: 'experimental-webgl', container: document.getElementById( 'canvas-holder' ), fallback: function() { alert( "You don't have WebGL." ) } } );
<canvas>
to the body that scales with the window.If true, ignores following parameters — defaults to false<canvas>
elementIf you don't specify this parameter, you need to manually append the GEE
domElement property to another DOM element on the page.<canvas>
element<canvas>
elementGEE
object// a GEE object has lots of properties. // Some you can set … g.frameRate = 30; g.height = 200; g.mousedown = function() { console.log( 'You pressed the canvas' ) }; g.keydown = function() { console.log( 'You pressed ' + g.key ) }; g.loop = false; g.draw = function() { // Some you just read … if ( g.mouseX > g.width/2 ) { g.ctx.fillRect( g.mouseX, g.mouseY, 10, 10 ); } }
Below is a list of all of GEE
's properties. The indicates that a property is read-only.
<canvas>
element<canvas>
element<canvas>
element<canvas>
is visible<canvas>
<canvas>
<canvas>
<canvas>
<canvas>
<canvas>
<canvas>
element.<canvas>
element.loop
is true by default.