Skip to content

Instantly share code, notes, and snippets.

@rodrigo-x
Created October 15, 2012 07:13
Show Gist options
  • Save rodrigo-x/3891164 to your computer and use it in GitHub Desktop.
Save rodrigo-x/3891164 to your computer and use it in GitHub Desktop.
snippet - triângulo canvas..
// Triângulo com Canvas
var NS = NS || {};
NS.Class = (function() {
var Canvas = (function() {
this.canvas = document.getElementById( "canvas" );
this.ctx = canvas.getContext( "2d" );
});
Canvas.prototype.triangulo = (function() {
if( this.ctx ) {
this.ctx.fillStyle = "hsl( 353, 100%, 72% )";
this.ctx.beginPath();
this.ctx.moveTo( 35,50 );
this.ctx.lineTo( 150,100 );
this.ctx.lineTo( 150,15 );
this.ctx.fill();
}
});
return new Canvas();
}( NS.Class ));
NS.Class.triangulo();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment