/*! * jQuery Canvas - v0.1.0 - 2012-08-07 * https://github.com/fiveisprime/jquery.canvas * Copyright (c) 2012 Matt Hernandez; Licensed MIT, GPL */ !function(a,b){"use strict";var c=function(a,c){this.canvas=a,this.context=this.canvas.getContext("2d"),this.animating=!1,this.width=this.canvas.width,this.height=this.canvas.height,this._timeInterval=0,this._frame=0,this._options=c,this.context.globalAlpha=this._options.alpha,this.context.shadowColor=this._options.shadowColor,this.context.shadowBlur=this._options.shadowBlur,this.context.shadowOffsetX=this._options.shadowOffsetX,this.context.shadowOffsetY=this._options.shadowOffsetY,b.AnimationFrame=function(a){return b.requestAnimationFrame||b.webkitRequestAnimationFrame||b.mozRequestAnimationFrame||b.oRequestAnimationFrame||b.msRequestAnimationFrame||function(a){b.setTimeout(a,1e3/60)}}()};c.prototype={addCircle:function(a,b,c,d,e){return this.context.beginPath(),this.context.arc(a.x,a.y,b,0,2*Math.PI,!1),this.context.fillStyle=c||"cyan",this.context.fill(),this.context.lineWidth=d||2,this.context.strokeStyle=e||"black",this.context.stroke(),this},addSquare:function(a,b,c,d,e){return typeof b=="number"&&(b={height:b,width:b}),this.context.beginPath(),this.context.rect(a.x,a.y,b.width,b.height),this.context.fillStyle=c||"cyan",this.context.fill(),this.context.lineWidth=d||2,this.context.strokeStyle=e||"black",this.context.stroke(),this},addTriangle:function(a,b,c,d,e){typeof b=="number"&&(b={height:b,width:b}),this.context.beginPath(),this.context.moveTo(a.x,a.y),this.context.lineTo(a.x+b.width/2,a.y+b.height),this.context.lineTo(a.x-b.width/2,a.y+b.height),this.context.closePath(),this.context.fillStyle=c||"cyan",this.context.fill(),this.context.lineWidth=d||2,this.context.strokeStyle=e||"black",this.context.stroke()},animationLoop:function(){var a=this,c=(new Date).getTime();return this._frame++,this._timeInterval=c-this.lastTime,this.lastTime=c,this.anim&&this.anim(),this.animating&&b.AnimationFrame(function(){a.animationLoop()}),this},setAnim:function(a){return this.anim=a,this},clear:function(){return this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this},startAnim:function(){return this.animating=!0,this.startTime=(new Date).getTime(),this.lastTime=this.startTime,this.anim&&this.anim(),this.animationLoop(),this},stopAnim:function(){return this.animating=!1,this}},a.fn.canvas=function(b){return this.each(function(){var d=a(this),e=d.data("canvas"),f=a.extend({},a.fn.canvas.defaults,typeof b=="object"&&b);if(!d.is("canvas"))throw new Error("requires a canvas element");e||d.data("canvas",e=new c(this,f))})},a.fn.canvas.defaults={alpha:1,shadowBlur:0,shadowColor:"gray",shadowOffsetX:0,shadowOffsetY:0},a.fn.canvas.constructor=c}(jQuery,window);