made with requirebin
Created
December 22, 2015 19:54
-
-
Save marcelroed/7e44448353436cdb5b56 to your computer and use it in GitHub Desktop.
requirebin sketch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var e2d = require('e2d'); | |
var r = e2d.Renderer.create(800, 600); | |
var dk = new e2d.Img(); | |
dk.src = 'http://archive.kontek.net/smashbros.planets.gamespy.com/images2/ssbmdonkeykong6.jpg'; | |
dk.on('load', function() { r.ready() }); | |
var frame = -1, | |
clickFrame = 0, | |
lastMouseState = 'up'; | |
r.on('frame', function() { | |
frame += 1; | |
if (frame > 360) { | |
frame = 0; | |
} | |
clickFrame -= 1; | |
if (clickFrame < 0) { | |
clickFrame = 0; | |
} | |
if (lastMouseState === 'up' && r.mouseData.state === 'down' && r.mouseData.activeRegions.indexOf('dk') !== -1) { | |
//dk was clicked! | |
clickFrame = 10; | |
} | |
lastMouseState = r.mouseData.state; | |
return r.render( | |
e2d.clearRect(800, 600), | |
e2d.translate(400, 300, | |
e2d.rotate(Math.PI * 2 * frame / 360, | |
e2d.scale(0.03 * clickFrame / 10, | |
e2d.translate(-dk.width * 0.5, -dk.height * 0.5, | |
e2d.drawImage(dk), | |
e2d.hitRect('dk', dk.width, dk.height) | |
) | |
) | |
) | |
) | |
); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){function EventEmitter(){this._events=this._events||{};this._maxListeners=this._maxListeners||undefined}module.exports=EventEmitter;EventEmitter.EventEmitter=EventEmitter;EventEmitter.prototype._events=undefined;EventEmitter.prototype._maxListeners=undefined;EventEmitter.defaultMaxListeners=10;EventEmitter.prototype.setMaxListeners=function(n){if(!isNumber(n)||n<0||isNaN(n))throw TypeError("n must be a positive number");this._maxListeners=n;return this};EventEmitter.prototype.emit=function(type){var er,handler,len,args,i,listeners;if(!this._events)this._events={};if(type==="error"){if(!this._events.error||isObject(this._events.error)&&!this._events.error.length){er=arguments[1];if(er instanceof Error){throw er}throw TypeError('Uncaught, unspecified "error" event.')}}handler=this._events[type];if(isUndefined(handler))return false;if(isFunction(handler)){switch(arguments.length){case 1:handler.call(this);break;case 2:handler.call(this,arguments[1]);break;case 3:handler.call(this,arguments[1],arguments[2]);break;default:len=arguments.length;args=new Array(len-1);for(i=1;i<len;i++)args[i-1]=arguments[i];handler.apply(this,args)}}else if(isObject(handler)){len=arguments.length;args=new Array(len-1);for(i=1;i<len;i++)args[i-1]=arguments[i];listeners=handler.slice();len=listeners.length;for(i=0;i<len;i++)listeners[i].apply(this,args)}return true};EventEmitter.prototype.addListener=function(type,listener){var m;if(!isFunction(listener))throw TypeError("listener must be a function");if(!this._events)this._events={};if(this._events.newListener)this.emit("newListener",type,isFunction(listener.listener)?listener.listener:listener);if(!this._events[type])this._events[type]=listener;else if(isObject(this._events[type]))this._events[type].push(listener);else this._events[type]=[this._events[type],listener];if(isObject(this._events[type])&&!this._events[type].warned){var m;if(!isUndefined(this._maxListeners)){m=this._maxListeners}else{m=EventEmitter.defaultMaxListeners}if(m&&m>0&&this._events[type].length>m){this._events[type].warned=true;console.error("(node) warning: possible EventEmitter memory "+"leak detected. %d listeners added. "+"Use emitter.setMaxListeners() to increase limit.",this._events[type].length);if(typeof console.trace==="function"){console.trace()}}}return this};EventEmitter.prototype.on=EventEmitter.prototype.addListener;EventEmitter.prototype.once=function(type,listener){if(!isFunction(listener))throw TypeError("listener must be a function");var fired=false;function g(){this.removeListener(type,g);if(!fired){fired=true;listener.apply(this,arguments)}}g.listener=listener;this.on(type,g);return this};EventEmitter.prototype.removeListener=function(type,listener){var list,position,length,i;if(!isFunction(listener))throw TypeError("listener must be a function");if(!this._events||!this._events[type])return this;list=this._events[type];length=list.length;position=-1;if(list===listener||isFunction(list.listener)&&list.listener===listener){delete this._events[type];if(this._events.removeListener)this.emit("removeListener",type,listener)}else if(isObject(list)){for(i=length;i-->0;){if(list[i]===listener||list[i].listener&&list[i].listener===listener){position=i;break}}if(position<0)return this;if(list.length===1){list.length=0;delete this._events[type]}else{list.splice(position,1)}if(this._events.removeListener)this.emit("removeListener",type,listener)}return this};EventEmitter.prototype.removeAllListeners=function(type){var key,listeners;if(!this._events)return this;if(!this._events.removeListener){if(arguments.length===0)this._events={};else if(this._events[type])delete this._events[type];return this}if(arguments.length===0){for(key in this._events){if(key==="removeListener")continue;this.removeAllListeners(key)}this.removeAllListeners("removeListener");this._events={};return this}listeners=this._events[type];if(isFunction(listeners)){this.removeListener(type,listeners)}else{while(listeners.length)this.removeListener(type,listeners[listeners.length-1])}delete this._events[type];return this};EventEmitter.prototype.listeners=function(type){var ret;if(!this._events||!this._events[type])ret=[];else if(isFunction(this._events[type]))ret=[this._events[type]];else ret=this._events[type].slice();return ret};EventEmitter.listenerCount=function(emitter,type){var ret;if(!emitter._events||!emitter._events[type])ret=0;else if(isFunction(emitter._events[type]))ret=1;else ret=emitter._events[type].length;return ret};function isFunction(arg){return typeof arg==="function"}function isNumber(arg){return typeof arg==="number"}function isObject(arg){return typeof arg==="object"&&arg!==null}function isUndefined(arg){return arg===void 0}},{}],2:[function(require,module,exports){if(typeof Object.create==="function"){module.exports=function inherits(ctor,superCtor){ctor.super_=superCtor;ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:false,writable:true,configurable:true}})}}else{module.exports=function inherits(ctor,superCtor){ctor.super_=superCtor;var TempCtor=function(){};TempCtor.prototype=superCtor.prototype;ctor.prototype=new TempCtor;ctor.prototype.constructor=ctor}}},{}],3:[function(require,module,exports){(function(process){function normalizeArray(parts,allowAboveRoot){var up=0;for(var i=parts.length-1;i>=0;i--){var last=parts[i];if(last==="."){parts.splice(i,1)}else if(last===".."){parts.splice(i,1);up++}else if(up){parts.splice(i,1);up--}}if(allowAboveRoot){for(;up--;up){parts.unshift("..")}}return parts}var splitPathRe=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;var splitPath=function(filename){return splitPathRe.exec(filename).slice(1)};exports.resolve=function(){var resolvedPath="",resolvedAbsolute=false;for(var i=arguments.length-1;i>=-1&&!resolvedAbsolute;i--){var path=i>=0?arguments[i]:process.cwd();if(typeof path!=="string"){throw new TypeError("Arguments to path.resolve must be strings")}else if(!path){continue}resolvedPath=path+"/"+resolvedPath;resolvedAbsolute=path.charAt(0)==="/"}resolvedPath=normalizeArray(filter(resolvedPath.split("/"),function(p){return!!p}),!resolvedAbsolute).join("/");return(resolvedAbsolute?"/":"")+resolvedPath||"."};exports.normalize=function(path){var isAbsolute=exports.isAbsolute(path),trailingSlash=substr(path,-1)==="/";path=normalizeArray(filter(path.split("/"),function(p){return!!p}),!isAbsolute).join("/");if(!path&&!isAbsolute){path="."}if(path&&trailingSlash){path+="/"}return(isAbsolute?"/":"")+path};exports.isAbsolute=function(path){return path.charAt(0)==="/"};exports.join=function(){var paths=Array.prototype.slice.call(arguments,0);return exports.normalize(filter(paths,function(p,index){if(typeof p!=="string"){throw new TypeError("Arguments to path.join must be strings")}return p}).join("/"))};exports.relative=function(from,to){from=exports.resolve(from).substr(1);to=exports.resolve(to).substr(1);function trim(arr){var start=0;for(;start<arr.length;start++){if(arr[start]!=="")break}var end=arr.length-1;for(;end>=0;end--){if(arr[end]!=="")break}if(start>end)return[];return arr.slice(start,end-start+1)}var fromParts=trim(from.split("/"));var toParts=trim(to.split("/"));var length=Math.min(fromParts.length,toParts.length);var samePartsLength=length;for(var i=0;i<length;i++){if(fromParts[i]!==toParts[i]){samePartsLength=i;break}}var outputParts=[];for(var i=samePartsLength;i<fromParts.length;i++){outputParts.push("..")}outputParts=outputParts.concat(toParts.slice(samePartsLength));return outputParts.join("/")};exports.sep="/";exports.delimiter=":";exports.dirname=function(path){var result=splitPath(path),root=result[0],dir=result[1];if(!root&&!dir){return"."}if(dir){dir=dir.substr(0,dir.length-1)}return root+dir};exports.basename=function(path,ext){var f=splitPath(path)[2];if(ext&&f.substr(-1*ext.length)===ext){f=f.substr(0,f.length-ext.length)}return f};exports.extname=function(path){return splitPath(path)[3]};function filter(xs,f){if(xs.filter)return xs.filter(f);var res=[];for(var i=0;i<xs.length;i++){if(f(xs[i],i,xs))res.push(xs[i])}return res}var substr="ab".substr(-1)==="b"?function(str,start,len){return str.substr(start,len)}:function(str,start,len){if(start<0)start=str.length+start;return str.substr(start,len)}}).call(this,require("_process"))},{_process:4}],4:[function(require,module,exports){var process=module.exports={};process.nextTick=function(){var canSetImmediate=typeof window!=="undefined"&&window.setImmediate;var canMutationObserver=typeof window!=="undefined"&&window.MutationObserver;var canPost=typeof window!=="undefined"&&window.postMessage&&window.addEventListener;if(canSetImmediate){return function(f){return window.setImmediate(f)}}var queue=[];if(canMutationObserver){var hiddenDiv=document.createElement("div");var observer=new MutationObserver(function(){var queueList=queue.slice();queue.length=0;queueList.forEach(function(fn){fn()})});observer.observe(hiddenDiv,{attributes:true});return function nextTick(fn){if(!queue.length){hiddenDiv.setAttribute("yes","no")}queue.push(fn)}}if(canPost){window.addEventListener("message",function(ev){var source=ev.source;if((source===window||source===null)&&ev.data==="process-tick"){ev.stopPropagation();if(queue.length>0){var fn=queue.shift();fn()}}},true);return function nextTick(fn){queue.push(fn);window.postMessage("process-tick","*")}}return function nextTick(fn){setTimeout(fn,0)}}();process.title="browser";process.browser=true;process.env={};process.argv=[];function noop(){}process.on=noop;process.addListener=noop;process.once=noop;process.off=noop;process.removeListener=noop;process.removeAllListeners=noop;process.emit=noop;process.binding=function(name){throw new Error("process.binding is not supported")};process.cwd=function(){return"/"};process.chdir=function(dir){throw new Error("process.chdir is not supported")}},{}],5:[function(require,module,exports){module.exports=function isBuffer(arg){return arg&&typeof arg==="object"&&typeof arg.copy==="function"&&typeof arg.fill==="function"&&typeof arg.readUInt8==="function"}},{}],6:[function(require,module,exports){(function(process,global){var formatRegExp=/%[sdj%]/g;exports.format=function(f){if(!isString(f)){var objects=[];for(var i=0;i<arguments.length;i++){objects.push(inspect(arguments[i]))}return objects.join(" ")}var i=1;var args=arguments;var len=args.length;var str=String(f).replace(formatRegExp,function(x){if(x==="%%")return"%";if(i>=len)return x;switch(x){case"%s":return String(args[i++]);case"%d":return Number(args[i++]);case"%j":try{return JSON.stringify(args[i++])}catch(_){return"[Circular]"}default:return x}});for(var x=args[i];i<len;x=args[++i]){if(isNull(x)||!isObject(x)){str+=" "+x}else{str+=" "+inspect(x)}}return str};exports.deprecate=function(fn,msg){if(isUndefined(global.process)){return function(){return exports.deprecate(fn,msg).apply(this,arguments)}}if(process.noDeprecation===true){return fn}var warned=false;function deprecated(){if(!warned){if(process.throwDeprecation){throw new Error(msg)}else if(process.traceDeprecation){console.trace(msg)}else{console.error(msg)}warned=true}return fn.apply(this,arguments)}return deprecated};var debugs={};var debugEnviron;exports.debuglog=function(set){if(isUndefined(debugEnviron))debugEnviron=process.env.NODE_DEBUG||"";set=set.toUpperCase();if(!debugs[set]){if(new RegExp("\\b"+set+"\\b","i").test(debugEnviron)){var pid=process.pid;debugs[set]=function(){var msg=exports.format.apply(exports,arguments);console.error("%s %d: %s",set,pid,msg)}}else{debugs[set]=function(){}}}return debugs[set]};function inspect(obj,opts){var ctx={seen:[],stylize:stylizeNoColor};if(arguments.length>=3)ctx.depth=arguments[2];if(arguments.length>=4)ctx.colors=arguments[3];if(isBoolean(opts)){ctx.showHidden=opts}else if(opts){exports._extend(ctx,opts)}if(isUndefined(ctx.showHidden))ctx.showHidden=false;if(isUndefined(ctx.depth))ctx.depth=2;if(isUndefined(ctx.colors))ctx.colors=false;if(isUndefined(ctx.customInspect))ctx.customInspect=true;if(ctx.colors)ctx.stylize=stylizeWithColor;return formatValue(ctx,obj,ctx.depth)}exports.inspect=inspect;inspect.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]};inspect.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"};function stylizeWithColor(str,styleType){var style=inspect.styles[styleType];if(style){return"["+inspect.colors[style][0]+"m"+str+"["+inspect.colors[style][1]+"m"}else{return str}}function stylizeNoColor(str,styleType){return str}function arrayToHash(array){var hash={};array.forEach(function(val,idx){hash[val]=true});return hash}function formatValue(ctx,value,recurseTimes){if(ctx.customInspect&&value&&isFunction(value.inspect)&&value.inspect!==exports.inspect&&!(value.constructor&&value.constructor.prototype===value)){var ret=value.inspect(recurseTimes,ctx);if(!isString(ret)){ret=formatValue(ctx,ret,recurseTimes)}return ret}var primitive=formatPrimitive(ctx,value);if(primitive){return primitive}var keys=Object.keys(value);var visibleKeys=arrayToHash(keys);if(ctx.showHidden){keys=Object.getOwnPropertyNames(value)}if(isError(value)&&(keys.indexOf("message")>=0||keys.indexOf("description")>=0)){return formatError(value)}if(keys.length===0){if(isFunction(value)){var name=value.name?": "+value.name:"";return ctx.stylize("[Function"+name+"]","special")}if(isRegExp(value)){return ctx.stylize(RegExp.prototype.toString.call(value),"regexp")}if(isDate(value)){return ctx.stylize(Date.prototype.toString.call(value),"date")}if(isError(value)){return formatError(value)}}var base="",array=false,braces=["{","}"];if(isArray(value)){array=true;braces=["[","]"]}if(isFunction(value)){var n=value.name?": "+value.name:"";base=" [Function"+n+"]"}if(isRegExp(value)){base=" "+RegExp.prototype.toString.call(value)}if(isDate(value)){base=" "+Date.prototype.toUTCString.call(value)}if(isError(value)){base=" "+formatError(value)}if(keys.length===0&&(!array||value.length==0)){return braces[0]+base+braces[1]}if(recurseTimes<0){if(isRegExp(value)){return ctx.stylize(RegExp.prototype.toString.call(value),"regexp")}else{return ctx.stylize("[Object]","special")}}ctx.seen.push(value);var output;if(array){output=formatArray(ctx,value,recurseTimes,visibleKeys,keys)}else{output=keys.map(function(key){return formatProperty(ctx,value,recurseTimes,visibleKeys,key,array)})}ctx.seen.pop();return reduceToSingleString(output,base,braces)}function formatPrimitive(ctx,value){if(isUndefined(value))return ctx.stylize("undefined","undefined");if(isString(value)){var simple="'"+JSON.stringify(value).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return ctx.stylize(simple,"string")}if(isNumber(value))return ctx.stylize(""+value,"number");if(isBoolean(value))return ctx.stylize(""+value,"boolean");if(isNull(value))return ctx.stylize("null","null")}function formatError(value){return"["+Error.prototype.toString.call(value)+"]"}function formatArray(ctx,value,recurseTimes,visibleKeys,keys){var output=[];for(var i=0,l=value.length;i<l;++i){if(hasOwnProperty(value,String(i))){output.push(formatProperty(ctx,value,recurseTimes,visibleKeys,String(i),true))}else{output.push("")}}keys.forEach(function(key){if(!key.match(/^\d+$/)){output.push(formatProperty(ctx,value,recurseTimes,visibleKeys,key,true))}});return output}function formatProperty(ctx,value,recurseTimes,visibleKeys,key,array){var name,str,desc;desc=Object.getOwnPropertyDescriptor(value,key)||{value:value[key]};if(desc.get){if(desc.set){str=ctx.stylize("[Getter/Setter]","special")}else{str=ctx.stylize("[Getter]","special")}}else{if(desc.set){str=ctx.stylize("[Setter]","special")}}if(!hasOwnProperty(visibleKeys,key)){name="["+key+"]"}if(!str){if(ctx.seen.indexOf(desc.value)<0){if(isNull(recurseTimes)){str=formatValue(ctx,desc.value,null)}else{str=formatValue(ctx,desc.value,recurseTimes-1)}if(str.indexOf("\n")>-1){if(array){str=str.split("\n").map(function(line){return" "+line}).join("\n").substr(2)}else{str="\n"+str.split("\n").map(function(line){return" "+line}).join("\n")}}}else{str=ctx.stylize("[Circular]","special")}}if(isUndefined(name)){if(array&&key.match(/^\d+$/)){return str}name=JSON.stringify(""+key);if(name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)){name=name.substr(1,name.length-2);name=ctx.stylize(name,"name")}else{name=name.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'");name=ctx.stylize(name,"string")}}return name+": "+str}function reduceToSingleString(output,base,braces){var numLinesEst=0;var length=output.reduce(function(prev,cur){numLinesEst++;if(cur.indexOf("\n")>=0)numLinesEst++;return prev+cur.replace(/\u001b\[\d\d?m/g,"").length+1},0);if(length>60){return braces[0]+(base===""?"":base+"\n ")+" "+output.join(",\n ")+" "+braces[1]}return braces[0]+base+" "+output.join(", ")+" "+braces[1]}function isArray(ar){return Array.isArray(ar)}exports.isArray=isArray;function isBoolean(arg){return typeof arg==="boolean"}exports.isBoolean=isBoolean;function isNull(arg){return arg===null}exports.isNull=isNull;function isNullOrUndefined(arg){return arg==null}exports.isNullOrUndefined=isNullOrUndefined;function isNumber(arg){return typeof arg==="number"}exports.isNumber=isNumber;function isString(arg){return typeof arg==="string"}exports.isString=isString;function isSymbol(arg){return typeof arg==="symbol"}exports.isSymbol=isSymbol;function isUndefined(arg){return arg===void 0}exports.isUndefined=isUndefined;function isRegExp(re){return isObject(re)&&objectToString(re)==="[object RegExp]"}exports.isRegExp=isRegExp;function isObject(arg){return typeof arg==="object"&&arg!==null}exports.isObject=isObject;function isDate(d){return isObject(d)&&objectToString(d)==="[object Date]"}exports.isDate=isDate;function isError(e){return isObject(e)&&(objectToString(e)==="[object Error]"||e instanceof Error)}exports.isError=isError;function isFunction(arg){return typeof arg==="function"}exports.isFunction=isFunction;function isPrimitive(arg){return arg===null||typeof arg==="boolean"||typeof arg==="number"||typeof arg==="string"||typeof arg==="symbol"||typeof arg==="undefined"}exports.isPrimitive=isPrimitive;exports.isBuffer=require("./support/isBuffer");function objectToString(o){return Object.prototype.toString.call(o)}function pad(n){return n<10?"0"+n.toString(10):n.toString(10)}var months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function timestamp(){var d=new Date;var time=[pad(d.getHours()),pad(d.getMinutes()),pad(d.getSeconds())].join(":");return[d.getDate(),months[d.getMonth()],time].join(" ")}exports.log=function(){console.log("%s - %s",timestamp(),exports.format.apply(exports,arguments))};exports.inherits=require("inherits");exports._extend=function(origin,add){if(!add||!isObject(add))return origin;var keys=Object.keys(add);var i=keys.length;while(i--){origin[keys[i]]=add[keys[i]]}return origin};function hasOwnProperty(obj,prop){return Object.prototype.hasOwnProperty.call(obj,prop)}}).call(this,require("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./support/isBuffer":5,_process:4,inherits:2}],7:[function(require,module,exports){exports=module.exports=function(searchInput){if(searchInput&&"object"===typeof searchInput){var hasKeyCode=searchInput.which||searchInput.keyCode||searchInput.charCode;if(hasKeyCode)searchInput=hasKeyCode}if("number"===typeof searchInput)return names[searchInput];var search=String(searchInput);var foundNamedKey=codes[search.toLowerCase()];if(foundNamedKey)return foundNamedKey;var foundNamedKey=aliases[search.toLowerCase()];if(foundNamedKey)return foundNamedKey;if(search.length===1)return search.charCodeAt(0);return undefined};var codes=exports.code=exports.codes={backspace:8,tab:9,enter:13,shift:16,ctrl:17,alt:18,"pause/break":19,"caps lock":20,esc:27,space:32,"page up":33,"page down":34,end:35,home:36,left:37,up:38,right:39,down:40,insert:45,"delete":46,command:91,"right click":93,"numpad *":106,"numpad +":107,"numpad -":109,"numpad .":110,"numpad /":111,"num lock":144,"scroll lock":145,"my computer":182,"my calculator":183,";":186,"=":187,",":188,"-":189,".":190,"/":191,"`":192,"[":219,"\\":220,"]":221,"'":222};var aliases=exports.aliases={windows:91,"⇧":16,"⌥":18,"⌃":17,"⌘":91,ctl:17,control:17,option:18,pause:19,"break":19,caps:20,"return":13,escape:27,spc:32,pgup:33,pgdn:33,ins:45,del:46,cmd:91};for(i=97;i<123;i++)codes[String.fromCharCode(i)]=i-32;for(var i=48;i<58;i++)codes[i-48]=i;for(i=1;i<13;i++)codes["f"+i]=i+111;for(i=0;i<10;i++)codes["numpad "+i]=i+96;var names=exports.names=exports.title={};for(i in codes)names[codes[i]]=i;for(var alias in aliases){codes[alias]=aliases[alias]}},{}],8:[function(require,module,exports){module.exports=function(point,vs){var x=point[0],y=point[1];var inside=false;for(var i=0,j=vs.length-1;i<vs.length;j=i++){var xi=vs[i][0],yi=vs[i][1];var xj=vs[j][0],yj=vs[j][1];var intersect=yi>y!=yj>y&&x<(xj-xi)*(y-yi)/(yj-yi)+xi;if(intersect)inside=!inside}return inside}},{}],9:[function(require,module,exports){"use strict";function Canvas(width,height){var Renderer=require("./Renderer");this.renderer=new Renderer(width,height,window.document.createElement("div"));this.fillPattern=null;this._skipPatternCreation=false;Object.seal(this)}Canvas.prototype.render=function render(children){var result=[],i;for(i=0;i<arguments.length;i++){result.push(arguments[i])}this.renderer.render(result);if(!this._skipPatternCreation){this.fillPattern=this.renderer.ctx.createPattern(this.renderer.canvas,"no-repeat")}};Canvas.prototype.style=function style(){var defs=[];for(var i=0;i<arguments.length;i++){defs.push(arguments[i])}this.renderer.style.apply(this.renderer,defs);return this};Canvas.prototype.toImage=function toImage(imageID){return this.renderer.toImage()};Canvas.prototype.resize=function resize(width,height){this.renderer.resize(+width,+height);return this};Object.defineProperty(Canvas.prototype,"height",{get:function(){return this.renderer.canvas.width},enumerable:true,configurable:false});Object.defineProperty(Canvas.prototype,"skipPatternCreation",{get:function(){return this._skipPatternCreation},set:function(value){this._skipPatternCreation=value}});Object.defineProperty(Canvas.prototype,"width",{get:function(){return this.renderer.canvas.width},enumerable:true,configurable:false});Canvas.cache={};Canvas.cachable=[];Canvas.create=function create(width,height,id){return new Canvas(width,height,id)};Object.seal(Canvas);Object.seal(Canvas.prototype);module.exports=Canvas},{"./Renderer":12}],10:[function(require,module,exports){"use strict";var path=require("path"),events=require("events"),util=require("util");util.inherits(Img,events.EventEmitter);function Img(){events.EventEmitter.call(this);this.imageElement=null;this.imagePattern=null;this.imagePatternRepeat=null;Object.seal(this)}Object.defineProperty(Img.prototype,"src",{set:function(val){var element=new Image;this.imageElement=element;element.src=val;if(element.complete){setTimeout(this.imageLoad.bind(this),0)}else{element.onload=this.imageLoad.bind(this)}},get:function(){return this.imageElement.src}});Img.prototype.imageLoad=function imageLoad(){var ctx=window.document.createElement("canvas").getContext("2d");this.imagePattern=ctx.createPattern(this.imageElement,"no-repeat");this.imagePatternRepeat=ctx.createPattern(this.imageElement,"repeat");return this.emit("load",this)};Object.defineProperty(Img.prototype,"width",{enumerable:true,get:function(){return this.imageElement.width},set:function(value){this.imageElement.width=value}});Object.defineProperty(Img.prototype,"height",{enumerable:true,get:function(){return this.imageElement.height},set:function(value){this.imageElement.height=value}});Object.seal(Img);Object.seal(Img.prototype);module.exports=Img},{events:1,path:3,util:6}],11:[function(require,module,exports){"use strict";function Instruction(type,props){this.type=type;this.props=props;Object.seal(this)}Object.seal(Instruction);Object.seal(Instruction.prototype);module.exports=Instruction},{}],12:[function(require,module,exports){"use strict";var createLinearGradient=require("./createLinearGradient"),createRadialGradient=require("./createRadialGradient"),events=require("events"),util=require("util"),keycode=require("keycode"),transformPoints=require("./transformPoints"),pointInPolygon=require("point-in-polygon"),identity=new Float64Array([1,0,0,1,0,0]);util.inherits(Renderer,events.EventEmitter);function Renderer(width,height,parent,worker){events.EventEmitter.call(this);this.transformStack=[identity];this.fillStyleStack=[];this.strokeStyleStack=[];this.lineStyleStack=[];this.textStyleStack=[];this.shadowStyleStack=[];this.globalAlphaStack=[];this.imageSmoothingEnabledStack=[];this.globalCompositeOperationStack=[];this.pi2=Math.PI*2;this.isReady=false;this.mouseState="up";this.mouseData={x:0,y:0,state:this.mouseState,activeRegions:[]};this.lastMouseEvent=null;this.ranMouseEvent=false;this.mouseRegions=[];this.activeRegions=[];this.styleQueue=[];this.keyData={};if(parent&&parent.nodeType===1){this.parent=parent}else{this.parent=window.document.createElement("div");this.parent.style.margin="0 auto";this.parent.style.width=width+"px";this.parent.style.height=height+"px";window.document.body.appendChild(this.parent)}if(!width||width<=0){width=window.innerWidth}if(!height||height<=0){height=window.innerHeight}this.canvas=window.document.createElement("canvas");this.canvas.tabIndex=1;this.ctx=this.canvas.getContext("2d");this.canvas.width=width;this.canvas.height=height;this.parent.appendChild(this.canvas);this.hookMouseEvents();this.hookKeyboardEvents();this.boundHookRenderFunction=this.hookRender.bind(this);Object.seal(this)}Renderer.prototype.render=function render(args){var i,len,child,props,type,cache,matrix,sinr,cosr,ctx=this.ctx,children=[],concat=children.concat;this.transformStack.splice(0,this.transformStack.length,identity);this.fillStyleStack.splice(0,this.fillStyleStack.length);this.strokeStyleStack.splice(0,this.strokeStyleStack.length);this.lineStyleStack.splice(0,this.lineStyleStack.length);this.textStyleStack.splice(0,this.textStyleStack.length);this.shadowStyleStack.splice(0,this.shadowStyleStack.length);this.globalCompositeOperationStack.splice(0,this.globalCompositeOperationStack.length);this.globalAlphaStack.splice(0,this.globalAlphaStack.length);this.imageSmoothingEnabledStack.splice(0,this.imageSmoothingEnabledStack.length);for(i=0,len=arguments.length;i<len;i++){children.push(arguments[i])}for(i=0,len=children.length;i<len;i++){child=children[i];if(child&&child.constructor===Array){children=concat.apply([],children);child=children[i];while(child&&child.constructor===Array){children=concat.apply([],children);child=children[i]}len=children.length}if(!child){continue}props=child.props;type=child.type;if(type==="transform"){cache=this.transformStack[this.transformStack.length-1];matrix=new Float64Array([cache[0]*props[0]+cache[2]*props[1],cache[1]*props[0]+cache[3]*props[1],cache[0]*props[2]+cache[2]*props[3],cache[1]*props[2]+cache[3]*props[3],cache[0]*props[4]+cache[2]*props[5]+cache[4],cache[1]*props[4]+cache[3]*props[5]+cache[5]]);this.transformStack.push(matrix);ctx.setTransform(matrix[0],matrix[1],matrix[2],matrix[3],matrix[4],matrix[5]);continue}if(type==="setTransform"){matrix=new Float64Array(props);this.transformStack.push(matrix);ctx.setTransform(matrix[0],matrix[1],matrix[2],matrix[3],matrix[4],matrix[5]);continue}if(type==="scale"){matrix=new Float64Array(this.transformStack[this.transformStack.length-1]);matrix[0]*=props.x;matrix[1]*=props.x;matrix[2]*=props.y;matrix[3]*=props.y;this.transformStack.push(matrix);ctx.setTransform(matrix[0],matrix[1],matrix[2],matrix[3],matrix[4],matrix[5]);continue}if(type==="translate"){matrix=new Float64Array(this.transformStack[this.transformStack.length-1]);matrix[4]+=matrix[0]*props.x+matrix[2]*props.y;matrix[5]+=matrix[1]*props.x+matrix[3]*props.y;this.transformStack.push(matrix);ctx.setTransform(matrix[0],matrix[1],matrix[2],matrix[3],matrix[4],matrix[5]);continue}if(type==="rotate"){cosr=Math.cos(props.r);sinr=Math.sin(props.r);cache=this.transformStack[this.transformStack.length-1];matrix=new Float64Array(cache);matrix[0]=cache[0]*cosr+cache[2]*sinr;matrix[1]=cache[1]*cosr+cache[3]*sinr;matrix[2]=cache[0]*-sinr+cache[2]*cosr;matrix[3]=cache[1]*-sinr+cache[3]*cosr;this.transformStack.push(matrix);ctx.setTransform(matrix[0],matrix[1],matrix[2],matrix[3],matrix[4],matrix[5]);continue}if(type==="restore"){this.transformStack.pop();matrix=this.transformStack[this.transformStack.length-1];ctx.setTransform(matrix[0],matrix[1],matrix[2],matrix[3],matrix[4],matrix[5]);continue}if(type==="fillRect"){ctx.fillRect(props.x,props.y,props.width,props.height);continue}if(type==="strokeRect"){ctx.strokeRect(props.x,props.y,props.width,props.height);continue}if(type==="clearRect"){ctx.clearRect(props.x,props.y,props.width,props.height);continue}if(type==="rect"){ctx.rect(props.x,props.y,props.width,props.height);continue}if(type==="fillStyle"){this.fillStyleStack.push(ctx.fillStyle);ctx.fillStyle=props.value;continue}if(type==="strokeStyle"){this.strokeStyleStack.push(ctx.strokeStyle);ctx.strokeStyle=props.value;continue}if(type==="endFillStyle"){ctx.fillStyle=this.fillStyleStack.pop();continue}if(type==="endStrokeStyle"){ctx.strokeStyle=this.strokeStyleStack.pop();continue}if(type==="lineStyle"){this.lineStyleStack.push({lineWidth:ctx.lineWidth,lineCap:ctx.lineCap,lineJoin:ctx.lineJoin,miterLimit:ctx.miterLimit,lineDash:ctx.getLineDash(),lineDashOffset:ctx.lineDashOffset});if(props.lineWidth!==null){ctx.lineWidth=props.lineWidth}if(props.lineCap!==null){ctx.lineCap=props.lineCap}if(props.lineJoin!==null){ctx.lineJoin=props.lineJoin}if(props.miterLimit!==null){ctx.miterLimit=props.miterLimit}if(props.lineDash.length>0){ctx.setLineDash(props.lineDash)}if(props.lineDashOffset!==null){ctx.lineDashOffset=props.lineDashOffset}continue}if(type==="endLineStyle"){cache=this.lineStyleStack.pop();ctx.lineWidth=cache.lineWidth;ctx.lineCap=cache.lineCap;ctx.lineJoin=cache.lineJoin;ctx.miterLimit=cache.miterLimit;ctx.setLineDash(cache.lineDash);ctx.lineDashOffset=cache.lineDashOffset;continue}if(type==="textStyle"){this.textStyleStack.push({font:ctx.font,textAlign:ctx.textAlign,textBaseline:ctx.textBaseline,direction:ctx.direction});if(props.font!==null){ctx.font=props.font}if(props.textAlign!==null){ctx.textAlign=props.textAlign}if(props.textBaseline!==null){ctx.textBaseline=props.textBaseline}if(props.lineJoin!==null){ctx.direction=props.direction}continue}if(type==="endTextStyle"){cache=this.textStyleStack.pop();ctx.font=cache.font;ctx.textAlign=cache.textAlign;ctx.textBaseline=cache.textBaseline;ctx.direction=cache.direction;continue}if(type==="shadowStyle"){this.shadowStyleStack.push({shadowBlur:ctx.shadowBlur,shadowColor:ctx.shadowColor,shadowOffsetX:ctx.shadowOffsetX,shadowOffsetY:ctx.shadowOffsetY});if(props.shadowBlur!==null){ctx.shadowBlur=props.shadowBlur}if(props.shadowColor!==null){ctx.shadowColor=props.shadowColor}if(props.shadowOffsetX!==null){ctx.shadowOffsetX=props.shadowOffsetX}if(props.shadowOffsetY!==null){ctx.shadowOffsetY=props.shadowOffsetY}continue}if(type==="endShadowStyle"){cache=this.shadowStyleStack.pop();ctx.shadowBlur=cache.shadowBlur;ctx.shadowColor=cache.shadowColor;ctx.shadowOffsetX=cache.shadowOffsetX; | |
ctx.shadowOffsetY=cache.shadowOffsetY;continue}if(type==="strokeText"){if(props.maxWidth){ctx.strokeText(props.text,props.x,props.y,props.maxWidth);continue}ctx.strokeText(props.text,props.x,props.y);continue}if(type==="fillText"){if(props.maxWidth){ctx.fillText(props.text,props.x,props.y,props.maxWidth);continue}ctx.fillText(props.text,props.x,props.y);continue}if(type==="text"){if(props.maxWidth!==0){if(props.fill){ctx.fillText(props.text,props.x,props.y,props.maxWidth)}if(props.stroke){ctx.strokeText(props.text,props.x,props.y,props.maxWidth)}continue}if(props.fill){ctx.fillText(props.text,props.x,props.y)}if(props.stroke){ctx.strokeText(props.text,props.x,props.y)}continue}if(type==="drawImage"){if(!props.img){continue}ctx.drawImage(props.img.imageElement||new Image,props.dx,props.dy);continue}if(type==="drawImageSize"){if(!props.img){continue}ctx.drawImage(props.img.imageElement||new Image,props.dx,props.dy,props.dWidth,props.dHeight);continue}if(type==="drawImageSource"){if(!props.img){continue}ctx.drawImage(props.img.imageElement||new Image,props.sx,props.sy,props.sWidth,props.sHeight,props.dx,props.dy,props.dWidth,props.dHeight);continue}if(type==="fillImagePattern"){if(!props.img){continue}ctx.fillStyle=props.img.imagePatternRepeat;ctx.translate(props.dx,props.dy);ctx.fillRect(0,0,props.dWidth,props.dHeight);ctx.restore();continue}if(type==="fillImage"){if(!props.img){continue}cache=props.img.imageElement;ctx.save();ctx.fillStyle=props.img.imagePattern;ctx.translate(props.dx,props.dy);ctx.fillRect(0,0,cache.width,cache.height);ctx.restore();continue}if(type==="fillImageSize"){if(!props.img){continue}cache=props.img.imageElement;ctx.save();ctx.fillStyle=props.img.imagePattern;ctx.translate(props.dx,props.dy);ctx.scale(props.dWidth/cache.width,props.dHeight/cache.height);ctx.fillRect(0,0,cache.width,cache.height);ctx.restore();continue}if(type==="fillImageSource"){if(!props.img){continue}ctx.save();ctx.fillStyle=props.img.imagePattern;ctx.translate(props.dx,props.dy);ctx.scale(props.dWidth/props.sWidth,props.dHeight/props.sHeight);ctx.translate(-props.sx,-props.sy);ctx.fillRect(props.sx,props.sy,props.sWidth,props.sHeight);ctx.restore();continue}if(type==="fillCanvas"){if(!props.img){continue}cache=props.img;ctx.save();ctx.fillStyle=cache.fillPattern;ctx.translate(props.dx,props.dy);ctx.fillRect(0,0,cache.width,cache.height);ctx.restore();continue}if(type==="fillCanvasSize"){if(!props.img){continue}cache=props.img;ctx.save();ctx.fillStyle=cache.fillPattern;ctx.translate(props.dx,props.dy);ctx.scale(props.dWidth/cache.width,props.dHeight/cache.height);ctx.fillRect(0,0,cache.width,cache.height);ctx.restore();continue}if(type==="fillCanvasSource"){if(!props.img){continue}ctx.save();ctx.fillStyle=props.img.fillPattern;ctx.translate(props.dx,props.dy);ctx.scale(props.dWidth/props.sWidth,props.dHeight/props.sHeight);ctx.translate(-props.sx,-props.sy);ctx.fillRect(props.sx,props.sy,props.sWidth,props.sHeight);ctx.restore();continue}if(type==="drawCanvas"){if(!props.img){continue}ctx.drawImage(props.img.renderer.canvas,props.dx,props.dy);continue}if(type==="drawCanvasSize"){if(!props.img){continue}ctx.drawImage(props.img.renderer.canvas,props.dx,props.dy,props.dWidth,props.dHeight);continue}if(type==="drawCanvasSource"){if(!props.img){continue}ctx.drawImage(props.img.renderer.canvas,props.sx,props.sy,props.sWidth,props.sHeight,props.dx,props.dy,props.dWidth,props.dHeight);continue}if(type==="strokeArc"){ctx.beginPath();ctx.arc(props.x,props.y,props.r,props.startAngle,props.endAngle);ctx.closePath();ctx.stroke();continue}if(type==="strokeArc-counterclockwise"){ctx.beginPath();ctx.arc(props.x,props.y,props.r,props.startAngle,props.endAngle,true);ctx.closePath();ctx.stroke();continue}if(type==="fillArc"){ctx.beginPath();ctx.arc(props.x,props.y,props.r,props.startAngle,props.endAngle);ctx.closePath();ctx.fill();continue}if(type==="fillArc-counterclockwise"){ctx.beginPath();ctx.arc(props.x,props.y,props.r,props.startAngle,props.endAngle,true);ctx.closePath();ctx.fill();continue}if(type==="moveTo"){ctx.moveTo(props.x,props.y);continue}if(type==="lineTo"){ctx.lineTo(props.x,props.y);continue}if(type==="bezierCurveTo"){ctx.bezierCurveTo(props.cp1x,props.cp1y,props.cp2x,props.cp2y,props.x,props.y);continue}if(type==="quadraticCurveTo"){ctx.quadraticCurveTo(props.cpx,props.cpy,props.x,props.y);continue}if(type==="anticlockwise-arc"){ctx.arc(props.x,props.y,props.r,props.startAngle,props.endAngle,true);continue}if(type==="arc"){ctx.arc(props.x,props.y,props.r,props.startAngle,props.endAngle);continue}if(type==="full-arc"){ctx.arc(props.x,props.y,props.r,0,this.pi2);continue}if(type==="quick-arc"){ctx.arc(0,0,props.r,0,this.pi2);continue}if(type==="arcTo"){ctx.arcTo(props.x1,props.y1,props.x2,props.y2,props.r);continue}if(type==="anticlockwise-ellipse"){this.save();this.translate(props.x,props.y);this.rotate(props.rotation);this.scale(props.radiusX,props.radiusY);this.arc(0,0,1,props.startAngle,props.endAngle,true);this.restore();continue}if(type==="ellipse"){this.save();this.translate(props.x,props.y);this.rotate(props.rotation);this.scale(props.radiusX,props.radiusY);this.arc(0,0,1,props.startAngle,props.endAngle);this.restore();continue}if(type==="full-ellipse"){this.save();this.translate(props.x,props.y);this.rotate(props.rotation);this.scale(props.radiusX,props.radiusY);this.arc(0,0,1,0,this.pi2);this.restore();continue}if(type==="quick-ellipse"){this.save();this.translate(props.x,props.y);this.scale(props.radiusX,props.radiusY);this.arc(0,0,1,0,this.pi2);this.restore();continue}if(type==="globalCompositeOperation"){this.globalCompositeOperationStack.push(ctx.globalCompositeOperation);ctx.globalCompositeOperation=props.value;continue}if(type==="endGlobalCompositeOperation"){ctx.globalCompositeOperation=this.globalCompositeOperationStack.pop();continue}if(type==="fill"){ctx.fill();continue}if(type==="stroke"){ctx.stroke();continue}if(type==="beginClip"){ctx.save();ctx.beginPath();continue}if(type==="clip"){ctx.clip();continue}if(type==="endClip"){ctx.restore();continue}if(type==="beginPath"){ctx.beginPath();continue}if(type==="closePath"){ctx.closePath();continue}if(type==="globalAlpha"){this.globalAlphaStack.push(ctx.globalAlpha);ctx.globalAlpha*=props.value;continue}if(type==="endGlobalAlpha"){ctx.globalAlpha=this.globalAlphaStack.pop();continue}if(type==="hitRegion"){this.mouseRegions.push({id:props.id,points:transformPoints(props.points,this.transformStack[this.transformStack.length-1])});continue}if(type==="imageSmoothingEnabled"){this.imageSmoothingEnabledStack.push(ctx.imageSmoothingEnabled);ctx.imageSmoothingEnabled=props.value;continue}if(type==="endImageSmoothingEnabled"){ctx.imageSmoothingEnabled=this.imageSmoothingEnabledStack.pop();continue}}return this.applyStyles()};Renderer.create=function create(width,height,parent,worker){if(arguments.length>2){return new Renderer(width,height,parent,worker)}if(arguments.length===2){return new Renderer(width,height)}return new Renderer};Renderer.prototype.resize=function(width,height){if(this.canvas.width.toString()!==width.toString()){this.canvas.width=width}if(this.canvas.height.toString()!==height.toString()){this.canvas.height=height}};Renderer.prototype.toImage=function toImage(){var Img=require("./Img");var img=new Img;img.src=this.canvas.toDataURL("image/png");return img};Renderer.prototype.hookRender=function hookRender(){if(this.isReady){if(this.lastMouseEvent&&!this.ranMouseEvent){this.mouseMove(this.lastMouseEvent)}this.fireFrame()}return window.requestAnimationFrame(this.boundHookRenderFunction)};Renderer.prototype.hookMouseEvents=function hookMouseEvents(){window.document.addEventListener("mousemove",this.mouseMove.bind(this));this.canvas.addEventListener("mousedown",this.mouseDown.bind(this));return window.document.addEventListener("mouseup",this.mouseUp.bind(this))};Renderer.prototype.mouseMove=function mouseMove(evt){var rect=this.canvas.getBoundingClientRect(),mousePoint=[0,0],region;this.lastMouseEvent=evt;this.ranMouseEvent=true;mousePoint[0]=evt.clientX-rect.left;mousePoint[1]=evt.clientY-rect.top;for(var i=0;i<this.mouseRegions.length;i++){region=this.mouseRegions[i];if(pointInPolygon(mousePoint,region.points)){this.activeRegions.push(region.id);this.mouseRegions.splice(this.mouseRegions.indexOf(region),1);i-=1}}this.mouseData.x=mousePoint[0];this.mouseData.y=mousePoint[1];this.mouseData.state=this.mouseState;this.mouseData.activeRegions=this.activeRegions;evt.preventDefault();return false};Renderer.prototype.mouseDown=function mouseMove(evt){this.mouseState="down";this.canvas.focus();return this.mouseMove(evt)};Renderer.prototype.mouseUp=function mouseMove(evt){this.mouseState="up";return this.mouseMove(evt)};Renderer.prototype.hookKeyboardEvents=function hookMouseEvents(){for(var name in keycode.code){if(keycode.code.hasOwnProperty(name)){this.keyData[name]="up"}}this.canvas.addEventListener("keydown",this.keyDown.bind(this));return window.document.addEventListener("keyup",this.keyUp.bind(this))};Renderer.prototype.keyChange=function keyChange(evt){evt.preventDefault();return false};Renderer.prototype.keyDown=function keyDown(evt){this.keyData[keycode(evt.keyCode)]="down";return this.keyChange(evt)};Renderer.prototype.keyUp=function keyUp(evt){this.keyData[keycode(evt.keyCode)]="up";return this.keyChange(evt)};Renderer.prototype.fireFrame=function(){this.mouseRegions.splice(0,this.mouseRegions.length);this.emit("frame",{});this.activeRegions.splice(0,this.activeRegions.length);this.ranMouseEvent=false;return this};Renderer.prototype.style=function style(){var children=[],styles=[],concat=children.concat,len,i,child,name;for(i=0,len=arguments.length;i<len;i++){children.push(arguments[i])}for(i=0,len=children.length;i<len;i++){child=children[i];if(child&&child.constructor===Array){children=concat.apply([],children);child=children[i];while(child&&child.constructor===Array){children=concat.apply([],children);child=children[i]}len=children.length}if(child){styles.push(child)}}for(i=0;i<styles.length;i++){this.styleQueue.push(styles[i])}};Renderer.prototype.applyStyles=function applyStyles(){var styleVal,value;for(var i=0;i<this.styleQueue.length;i++){styleVal=this.styleQueue[i];for(var name in styleVal){if(styleVal.hasOwnProperty(name)){this.canvas.style[name]=styleVal[name]}}}this.styleQueue.splice(0,this.styleQueue.length)};Renderer.prototype.ready=function ready(){this.isReady=true;this.fireFrame();return window.requestAnimationFrame(this.hookRender.bind(this))};Renderer.prototype.measureText=function measureText(font,text){var oldFont=this.ctx.font,result;this.ctx.font=font;result=this.ctx.measureText(text);this.ctx.font=oldFont;return result};Object.defineProperty(Renderer.prototype,"height",{get:function(){return this.canvas.width},enumerable:true,configurable:false});Object.defineProperty(Renderer.prototype,"width",{get:function(){return this.canvas.width},enumerable:true,configurable:false});Object.seal(Renderer);Object.seal(Renderer.prototype);module.exports=Renderer},{"./Img":10,"./createLinearGradient":23,"./createRadialGradient":24,"./transformPoints":63,events:1,keycode:7,"point-in-polygon":8,util:6}],13:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");function addColorStop(offset,color){return new Instruction("addColorStop",{offset:offset,color:color})}module.exports=addColorStop},{"./Instruction":11}],14:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");function arc(x,y,r,startAngle,endAngle,anticlockwise){if(arguments.length>5){return new Instruction(anticlockwise?"anticlockwise-arc":"arc",{x:x,y:y,r:r,startAngle:startAngle,endAngle:endAngle})}if(arguments.length===5){return new Instruction("arc",{x:x,y:y,r:r,startAngle:startAngle,endAngle:endAngle})}if(arguments.length>=3){return new Instruction("full-arc",{x:x,y:y,r:r})}if(arguments.length>=1){return new Instruction("quick-arc",{r:x})}return new Instruction("quick-arc",{r:1})}module.exports=arc},{"./Instruction":11}],15:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");function arcTo(x1,y1,x2,y2,r){return new Instruction("arcTo",{x1:x1,y1:y1,x2:x2,y2:y2,r:r})}module.exports=arcTo},{"./Instruction":11}],16:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");function beginPath(){return new Instruction("beginPath")}module.exports=beginPath},{"./Instruction":11}],17:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");function bezierCurveTo(cp1x,cp1y,cp2x,cp2y,x,y){return new Instruction("bezierCurveTo",{cp1x:cp1x,cp1y:cp1y,cp2x:cp2x,cp2y:cp2y,x:x,y:y})}module.exports=bezierCurveTo},{"./Instruction":11}],18:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");function fillRect(x,y,width,height){if(arguments.length>2){return new Instruction("clearRect",{x:x,y:y,width:width,height:height})}else{return new Instruction("clearRect",{x:0,y:0,width:x,height:y})}}module.exports=fillRect},{"./Instruction":11}],19:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");function clip(path,children){var result=[new Instruction("beginClip"),path,new Instruction("clip")];for(var i=1;i<arguments.length;i++){result.push(arguments[i])}result.push(new Instruction("endClip"));return result}module.exports=clip},{"./Instruction":11}],20:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");function clipPath(){return new Instruction("clipPath")}module.exports=clipPath},{"./Instruction":11}],21:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");function closePath(){return new Instruction("closePath")}module.exports=closePath},{"./Instruction":11}],22:[function(require,module,exports){"use strict";var concat=[].concat;function createClass(){var args=[],i;for(i=0;i<arguments.length;i++){args.push(arguments[i])}for(i=0;i<args.length;i++){while(args[i]&&args[i].constructor===Array){args=concat.apply([],args)}if(args[i]&&args[i].type==="placeholder"){break}}return function(){var start=args,end=start.splice(i+1,args.length);start.pop();return function createdClass(){var children=[],i;for(i=0;i<arguments.length;i++){children.push(arguments[i])}return[start,children,end]}}()}module.exports=createClass},{}],23:[function(require,module,exports){"use strict";function createLinearGradient(x0,y0,x1,y1,children){var ctx=window.document.createElement("canvas").getContext("2d"),grd=ctx.createLinearGradient(x0,y0,x1,y1);for(var i=0;i<children.length;i++){var colorStop=children[i];grd.addColorStop(colorStop.props.offset,colorStop.props.color)}return grd}module.exports=createLinearGradient},{}],24:[function(require,module,exports){"use strict";function createRadialGradient(x0,y0,r0,x1,y1,r1,children){var ctx=window.document.createElement("canvas").getContext("2d"),grd=ctx.createRadialGradient(x0,y0,r0,x1,y1,r1);for(var i=0;i<children.length;i++){var colorStop=children[i];grd.addColorStop(colorStop.props.offset,colorStop.props.color)}return grd}module.exports=createRadialGradient},{}],25:[function(require,module,exports){"use strict";function createRegularPolygon(radius,position,sides){radius=+radius||1;position[0]=+position[0]||0;position[1]=+position[1]||0;sides=+sides||3;var polygon=[];for(var i=0;i<sides;i++){polygon.push([position[0]+radius*Math.cos(Math.PI*2*i/sides),position[1]+radius*Math.sin(Math.PI*2*i/sides)])}return polygon}module.exports=createRegularPolygon},{}],26:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");function drawCanvas(canvas,sx,sy,sWidth,sHeight,dx,dy,dWidth,dHeight){if(arguments.length===9){return new Instruction("drawCanvasSource",{img:canvas,sx:sx,sy:sy,sWidth:sWidth,sHeight:sHeight,dx:dx,dy:dy,dWidth:dWidth,dHeight:dHeight})}if(arguments.length>=5){return new Instruction("drawCanvasSize",{img:canvas,dx:sx,dy:sy,dWidth:sWidth,dHeight:sHeight})}if(arguments.length>=3){return new Instruction("drawCanvas",{img:canvas,dx:sx,dy:sy})}return new Instruction("drawCanvas",{img:canvas,dx:0,dy:0})}module.exports=drawCanvas},{"./Instruction":11}],27:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");function drawImage(img,sx,sy,sWidth,sHeight,dx,dy,dWidth,dHeight){if(arguments.length===9){return new Instruction("drawImageSource",{img:img,sx:sx,sy:sy,sWidth:sWidth,sHeight:sHeight,dx:dx,dy:dy,dWidth:dWidth,dHeight:dHeight})}if(arguments.length>=5){return new Instruction("drawImageSize",{img:img,dx:sx,dy:sy,dWidth:sWidth,dHeight:sHeight})}if(arguments.length>=3){return new Instruction("drawImage",{img:img,dx:sx,dy:sy})}return new Instruction("drawImage",{img:img,dx:0,dy:0})}module.exports=drawImage},{"./Instruction":11}],28:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");function ellipse(x,y,radiusX,radiusY,rotation,startAngle,endAngle,anticlockwise){if(arguments.length>7){return new Instruction(anticlockwise?"anticlockwise-ellipse":"ellipse",{x:x,y:y,radiusX:radiusX,radiusY:radiusY,startAngle:startAngle,endAngle:endAngle})}if(arguments.length===7){return new Instruction("ellipse",{x:x,y:y,radiusX:radiusX,radiusY:radiusY,rotation:rotation,startAngle:startAngle,endAngle:endAngle})}if(arguments.length>=5){return new Instruction("full-ellipse",{x:x,y:y,radiusX:radiusX,radiusY:radiusY,rotation:rotation})}if(arguments.length===4){return new Instruction("quick-ellipse",{x:x,y:y,radiusX:radiusX,radiusY:radiusY})}return new Instruction("quick-ellipse",{x:0,y:0,radiusX:x,radiusY:y})}module.exports=ellipse},{"./Instruction":11}],29:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");function fill(){return new Instruction("fill")}module.exports=fill},{"./Instruction":11}],30:[function(require,module,exports){"use strict";var Instruction=require("./Instruction"),pi2=Math.PI*2;function fillArc(x,y,r,startAngle,endAngle,counterclockwise){if(arguments.length>=6&&counterclockwise){return new Instruction("fillArc-counterclockwise",{x:x,y:y,r:r,startAngle:startAngle,endAngle:endAngle})}if(arguments.length>3){return new Instruction("fillArc",{x:x,y:y,r:r,startAngle:startAngle,endAngle:endAngle})}if(arguments.length>1){return new Instruction("fillArc",{x:x,y:y,r:r,startAngle:0,endAngle:pi2})}return new Instruction("fillArc",{x:0,y:0,r:x,startAngle:0,endAngle:pi2})}module.exports=fillArc},{"./Instruction":11}],31:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");function fillImage(img,sx,sy,sWidth,sHeight,dx,dy,dWidth,dHeight){if(arguments.length===9){return new Instruction("fillCanvasSource",{img:img,sx:sx,sy:sy,sWidth:sWidth,sHeight:sHeight,dx:dx,dy:dy,dWidth:dWidth,dHeight:dHeight})}if(arguments.length>=5){return new Instruction("fillCanvasSize",{img:img,dx:sx,dy:sy,dWidth:sWidth,dHeight:sHeight})}if(arguments.length>=3){return new Instruction("fillCanvas",{img:img,dx:sx,dy:sy})}return new Instruction("fillCanvas",{img:img,dx:0,dy:0})}module.exports=fillImage},{"./Instruction":11}],32:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");function fillImage(img,sx,sy,sWidth,sHeight,dx,dy,dWidth,dHeight){if(arguments.length===9){return new Instruction("fillImageSource",{img:img,sx:sx,sy:sy,sWidth:sWidth,sHeight:sHeight,dx:dx,dy:dy,dWidth:dWidth,dHeight:dHeight})}if(arguments.length>=5){return new Instruction("fillImageSize",{img:img,dx:sx,dy:sy,dWidth:sWidth,dHeight:sHeight})}if(arguments.length>=3){return new Instruction("fillImage",{img:img,dx:sx,dy:sy})}return new Instruction("fillImage",{img:img,dx:0,dy:0})}module.exports=fillImage},{"./Instruction":11}],33:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");function fillImagePattern(img,dx,dy,dWidth,dHeight){if(arguments.length>=5){return new Instruction("fillImagePattern",{img:img,dx:dx,dy:dy,dWidth:dWidth,dHeight:dHeight})}if(arguments.length>=3){return new Instruction("fillImagePattern",{img:img,dx:0,dy:0,dWidth:dx,dHeight:dy})}return new Instruction("fillImagePattern",{img:img,dx:0,dy:0,dWidth:0,dHeight:0})}module.exports=fillImagePattern},{"./Instruction":11}],34:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");function fillRect(x,y,width,height){if(arguments.length>=4){return new Instruction("fillRect",{x:x,y:y,width:width,height:height})}else{return new Instruction("fillRect",{x:0,y:0,width:x,height:y})}}module.exports=fillRect},{"./Instruction":11}],35:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");function fillStyle(value,children){var result=[new Instruction("fillStyle",{value:value})];for(var i=1;i<arguments.length;i++){result.push(arguments[i])}result.push(new Instruction("endFillStyle"));return result}module.exports=fillStyle},{"./Instruction":11}],36:[function(require,module,exports){var Instruction=require("./Instruction");module.exports=function fillText(text,x,y,maxWidth){if(arguments.length<4){maxWidth=null}if(arguments.length<3){x=0;y=0}return new Instruction("fillText",{text:text,x:x,y:y,maxWidth:maxWidth})}},{"./Instruction":11}],37:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");function globalAlpha(alpha,children){var result=[new Instruction("globalAlpha",{value:alpha})];for(var i=1;i<arguments.length;i++){result.push(arguments[i])}result.push(new Instruction("endGlobalAlpha"));return result}module.exports=globalAlpha},{"./Instruction":11}],38:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");function globalCompositeOperation(operationType,children){var result=[new Instruction("globalCompositeOperation",{value:operationType})];if(arguments.length===0){return[]}for(var i=1;i<arguments.length;i++){result.push(arguments[i])}result.push(new Instruction("endGlobalCompositeOperation"));return result}module.exports=globalCompositeOperation},{"./Instruction":11}],39:[function(require,module,exports){"use strict";var Instruction=require("./Instruction"),hitRegion=require("./hitRegion");function hitRect(id,x,y,width,height){if(arguments.length<=3){width=x;height=y;x=0;y=0}var points=[[x,y],[x,y+height],[x+width,y+height],[x+width,y]];return hitRegion(id,points)}module.exports=hitRect},{"./Instruction":11,"./hitRegion":40}],40:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");function hitRegion(id,points){return new Instruction("hitRegion",{id:id,points:points})}module.exports=hitRegion},{"./Instruction":11}],41:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");module.exports=function imageSmoothingEnabled(val,children){children=[];for(var i=1;i<arguments.length;i++){children.push(arguments[i])}return[new Instruction("imageSmoothingEnabled",{value:Boolean(val)})].concat(children).concat(new Instruction("endImageSmoothingEnabled"))}},{"./Instruction":11}],42:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");function lineStyle(value,children){value=value||{};var result={lineWidth:null,lineCap:null,lineJoin:null,miterLimit:null,lineDash:[],lineDashOffset:null};if(typeof value.lineWidth!=="undefined"){result.lineWidth=value.lineWidth}if(typeof value.lineCap!=="undefined"){result.lineCap=value.lineCap}if(typeof value.lineJoin!=="undefined"){result.lineJoin=value.lineJoin}if(typeof value.miterLimit!=="undefined"){result.miterLimit=value.miterLimit}if(typeof value.lineDash!=="undefined"){result.lineDash=value.lineDash}if(typeof value.lineDashOffset!=="undefined"){result.lineDashOffset=value.lineDashOffset}var tree=[new Instruction("lineStyle",result)];for(var i=1;i<arguments.length;i++){tree.push(arguments[i])}tree.push(new Instruction("endLineStyle"));return tree}module.exports=lineStyle},{"./Instruction":11}],43:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");function lineTo(x,y){if(arguments.length===0){return new Instruction("lineTo",{x:0,y:0})}return new Instruction("lineTo",{x:x,y:y})}module.exports=lineTo},{"./Instruction":11}],44:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");function moveTo(x,y){if(arguments.length===0){return new Instruction("moveTo",{x:0,y:0})}return new Instruction("moveTo",{x:x,y:y})}module.exports=moveTo},{"./Instruction":11}],45:[function(require,module,exports){"use strict";var moveTo=require("./moveTo"),lineTo=require("./lineTo");function moveToLineTo(point,index){return index===0?moveTo(point[0],point[1]):lineTo(point[0],point[1])}module.exports=moveToLineTo},{"./lineTo":43,"./moveTo":44}],46:[function(require,module,exports){"use strict";var beginPath=require("./beginPath"),closePath=require("./closePath");function path(children){var result=[beginPath()];for(var i=0;i<arguments.length;i++){result.push(arguments[i])}result.push(closePath());return result}module.exports=path},{"./beginPath":16,"./closePath":21}],47:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");module.exports=function placeHolder(){return new Instruction("placeholder")}},{"./Instruction":11}],48:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");function quadraticCurveTo(cpx,cpy,x,y){return new Instruction("quadraticCurveTo",{cpx:cpx,cpy:cpy,x:x,y:y})}module.exports=quadraticCurveTo},{"./Instruction":11}],49:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");function rect(x,y,width,height){if(arguments.length>2){return new Instruction("rect",{x:x,y:y,width:width,height:height})}else{return new Instruction("rect",{x:0,y:0,width:x,height:y})}}module.exports=rect},{"./Instruction":11}],50:[function(require,module,exports){"use strict";var setTransform=require("./setTransform");module.exports=function resetTransform(){var args=[];for(var i=0;i<arguments.length;i++){args.push(arguments[i])}return setTransform([1,0,0,1,0,0],args)}},{"./setTransform":53}],51:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");function rotate(r,children){r=+r;var result=[new Instruction("rotate",{r:r})];for(var i=1;i<arguments.length;i++){result.push(arguments[i])}result.push(new Instruction("restore"));return result}module.exports=rotate},{"./Instruction":11}],52:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");function scale(x,y,children){var i=2;if(typeof y!=="number"){y=x;i=1}children=children||[];var result=[new Instruction("scale",{x:x,y:y})],child;for(;i<arguments.length;i++){result.push(arguments[i])}result.push(new Instruction("restore"));return result}module.exports=scale},{"./Instruction":11}],53:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");module.exports=function(matrix,children){var result=[new Instruction("setTransform",matrix)];for(var i=1;i<arguments.length;i++){result.push(arguments[i])}result.push(new Instruction("restore"));return result}},{"./Instruction":11}],54:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");function shadowStyle(value,children){value=value||{};var result={shadowBlur:null,shadowColor:null,shadowOffsetX:null,shadowOffsetY:null};if(typeof value.shadowBlur!=="undefined"){result.shadowBlur=value.shadowBlur}if(typeof value.shadowColor!=="undefined"){result.shadowColor=value.shadowColor}if(typeof value.shadowOffsetX!=="undefined"){result.shadowOffsetX=value.shadowOffsetX}if(typeof value.direction!=="undefined"){result.shadowOffsetY=value.shadowOffsetY}var tree=[new Instruction("shadowStyle",value)];for(var i=1;i<arguments.length;i++){tree.push(arguments[i])}tree.push(new Instruction("endShadowStyle"));return tree}module.exports=shadowStyle},{"./Instruction":11}],55:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");function stroke(){return new Instruction("stroke")}module.exports=stroke},{"./Instruction":11}],56:[function(require,module,exports){"use strict";var Instruction=require("./Instruction"),pi2=Math.PI*2;function strokeArc(x,y,r,startAngle,endAngle,counterclockwise){if(arguments.length>=6&&counterclockwise){return new Instruction("strokeArc-counterclockwise",{x:x,y:y,r:r,startAngle:startAngle,endAngle:endAngle})}if(arguments.length>3){return new Instruction("strokeArc",{x:x,y:y,r:r,startAngle:startAngle,endAngle:endAngle})}if(arguments.length>1){return new Instruction("strokeArc",{x:x,y:y,r:r,startAngle:0,endAngle:pi2})}return new Instruction("strokeArc",{x:0,y:0,r:x,startAngle:0,endAngle:pi2})}module.exports=strokeArc},{"./Instruction":11}],57:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");function strokeRect(x,y,width,height){if(arguments.length>2){return new Instruction("strokeRect",{x:x,y:y,width:width,height:height})}else{return new Instruction("strokeRect",{x:0,y:0,width:x,height:y})}}module.exports=strokeRect},{"./Instruction":11}],58:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");function fillStyle(value,children){var result=[new Instruction("strokeStyle",{value:value})];for(var i=1;i<arguments.length;i++){result.push(arguments[i])}result.push(new Instruction("endStrokeStyle"));return result}module.exports=fillStyle},{"./Instruction":11}],59:[function(require,module,exports){var Instruction=require("./Instruction");module.exports=function strokeText(text,x,y,maxWidth){if(arguments.length<4){maxWidth=null}if(arguments.length<3){x=0;y=0}return new Instruction("strokeText",{text:text,x:x,y:y,maxWidth:maxWidth})}},{"./Instruction":11}],60:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");function text(str,x,y,fill,stroke,maxWidth){if(arguments.length===6){return new Instruction("text",{x:x,y:y,fill:fill,stroke:stroke,text:str,maxWidth:maxWidth})}if(arguments.length===5){return new Instruction("text",{x:x,y:y,fill:fill,stroke:stroke,text:str,maxWidth:0})}if(arguments.length===4){return new Instruction("text",{x:x,y:y,fill:fill,stroke:false,text:str,maxWidth:0})}if(arguments.length===3){return new Instruction("text",{x:x,y:y,fill:true,stroke:false,text:str,maxWidth:0})}return new Instruction("text",{x:0,y:0,fill:true,stroke:false,text:str,maxWidth:0})}module.exports=text},{"./Instruction":11}],61:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");function textStyle(value,children){value=value||{};var result={font:null,textAlign:null,textBaseline:null,direction:null};if(typeof value.font!=="undefined"){result.font=value.font}if(typeof value.textAlign!=="undefined"){result.textAlign=value.textAlign}if(typeof value.textBaseline!=="undefined"){result.textBaseline=value.textBaseline}if(typeof value.direction!=="undefined"){result.direction=value.direction}var tree=[new Instruction("textStyle",value)];for(var i=1;i<arguments.length;i++){tree.push(arguments[i])}tree.push(new Instruction("endTextStyle"));return tree}module.exports=textStyle},{"./Instruction":11}],62:[function(require,module,exports){"use strict";var Instruction=require("./Instruction");function transform(values,children){var transformResult=[new Instruction("transform",new Float64Array(values))];for(var i=1,len=arguments.length;i<len;i++){transformResult.push(arguments[i])}transformResult.push(new Instruction("restore"));return transformResult}module.exports=transform},{"./Instruction":11}],63:[function(require,module,exports){"use strict";function transformPoints(points,matrix){var result=[],len=points.length,point;for(var i=0;i<len;i++){point=points[i];result.push([matrix[0]*point[0]+matrix[2]*point[1]+matrix[4],matrix[1]*point[0]+matrix[3]*point[1]+matrix[5]])}return result}module.exports=transformPoints},{}],64:[function(require,module,exports){"use strict";var Instruction=require("./Instruction"); | |
function translate(x,y,children){var result=[new Instruction("translate",{x:x,y:y})];var val;for(var i=2;i<arguments.length;i++){val=arguments[i];if(Array.isArray(val)){result=result.concat(val);continue}result.push(arguments[i])}result.push(new Instruction("restore"));return result}module.exports=translate},{"./Instruction":11}],e2d:[function(require,module,exports){"use strict";module.exports={addColorStop:require("./src/addColorStop"),arc:require("./src/arc"),arcTo:require("./src/arcTo"),beginPath:require("./src/beginPath"),bezierCurveTo:require("./src/bezierCurveTo"),Canvas:require("./src/Canvas"),clearRect:require("./src/clearRect"),clip:require("./src/clip"),clipPath:require("./src/clipPath"),closePath:require("./src/closePath"),createClass:require("./src/createClass"),createLinearGradient:require("./src/createLinearGradient"),createRadialGradient:require("./src/createRadialGradient"),createRegularPolygon:require("./src/createRegularPolygon"),drawCanvas:require("./src/drawCanvas"),drawImage:require("./src/drawImage"),ellipse:require("./src/ellipse"),fill:require("./src/fill"),fillArc:require("./src/fillArc"),fillCanvas:require("./src/fillCanvas"),fillImage:require("./src/fillImage"),fillImagePattern:require("./src/fillImagePattern"),fillRect:require("./src/fillRect"),fillStyle:require("./src/fillStyle"),fillText:require("./src/fillText"),globalAlpha:require("./src/globalAlpha"),globalCompositeOperation:require("./src/globalCompositeOperation"),hitRect:require("./src/hitRect"),hitRegion:require("./src/hitRegion"),imageSmoothingEnabled:require("./src/imageSmoothingEnabled"),Img:require("./src/Img"),Instruction:require("./src/Instruction"),lineStyle:require("./src/lineStyle"),lineTo:require("./src/lineTo"),moveTo:require("./src/moveTo"),moveToLineTo:require("./src/moveToLineTo"),path:require("./src/path"),placeHolder:require("./src/placeHolder"),quadraticCurveTo:require("./src/quadraticCurveTo"),rect:require("./src/rect"),Renderer:require("./src/Renderer"),resetTransform:require("./src/resetTransform"),rotate:require("./src/rotate"),scale:require("./src/scale"),setTransform:require("./src/setTransform"),shadowStyle:require("./src/shadowStyle"),stroke:require("./src/stroke"),strokeArc:require("./src/strokeArc"),strokeRect:require("./src/strokeRect"),strokeStyle:require("./src/strokeStyle"),strokeText:require("./src/strokeText"),text:require("./src/text"),textStyle:require("./src/textStyle"),transform:require("./src/transform"),transformPoints:require("./src/transformPoints"),translate:require("./src/translate")}},{"./src/Canvas":9,"./src/Img":10,"./src/Instruction":11,"./src/Renderer":12,"./src/addColorStop":13,"./src/arc":14,"./src/arcTo":15,"./src/beginPath":16,"./src/bezierCurveTo":17,"./src/clearRect":18,"./src/clip":19,"./src/clipPath":20,"./src/closePath":21,"./src/createClass":22,"./src/createLinearGradient":23,"./src/createRadialGradient":24,"./src/createRegularPolygon":25,"./src/drawCanvas":26,"./src/drawImage":27,"./src/ellipse":28,"./src/fill":29,"./src/fillArc":30,"./src/fillCanvas":31,"./src/fillImage":32,"./src/fillImagePattern":33,"./src/fillRect":34,"./src/fillStyle":35,"./src/fillText":36,"./src/globalAlpha":37,"./src/globalCompositeOperation":38,"./src/hitRect":39,"./src/hitRegion":40,"./src/imageSmoothingEnabled":41,"./src/lineStyle":42,"./src/lineTo":43,"./src/moveTo":44,"./src/moveToLineTo":45,"./src/path":46,"./src/placeHolder":47,"./src/quadraticCurveTo":48,"./src/rect":49,"./src/resetTransform":50,"./src/rotate":51,"./src/scale":52,"./src/setTransform":53,"./src/shadowStyle":54,"./src/stroke":55,"./src/strokeArc":56,"./src/strokeRect":57,"./src/strokeStyle":58,"./src/strokeText":59,"./src/text":60,"./src/textStyle":61,"./src/transform":62,"./src/transformPoints":63,"./src/translate":64}]},{},[]);var e2d=require("e2d");var r=e2d.Renderer.create(800,600);var dk=new e2d.Img;dk.src="http://archive.kontek.net/smashbros.planets.gamespy.com/images2/ssbmdonkeykong6.jpg";dk.on("load",function(){r.ready()});var frame=-1,clickFrame=0,lastMouseState="up";r.on("frame",function(){frame+=1;if(frame>360){frame=0}clickFrame-=1;if(clickFrame<0){clickFrame=0}if(lastMouseState==="up"&&r.mouseData.state==="down"&&r.mouseData.activeRegions.indexOf("dk")!==-1){clickFrame=10}lastMouseState=r.mouseData.state;return r.render(e2d.clearRect(800,600),e2d.translate(400,300,e2d.rotate(Math.PI*2*frame/360,e2d.scale(.03*clickFrame/10,e2d.translate(-dk.width*.5,-dk.height*.5,e2d.drawImage(dk),e2d.hitRect("dk",dk.width,dk.height))))))}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "requirebin-sketch", | |
"version": "1.0.0", | |
"dependencies": { | |
"e2d": "3.0.4" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- contents of this file will be placed inside the <body> --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- contents of this file will be placed inside the <head> --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment