forked from roblarsen/CeeJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Canvas.min.js
29 lines (25 loc) · 7 KB
/
Canvas.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
Canvas JavaScript Library v0.1
some day:
canvasjs.net
for now, visit:
http://htmlcssjavascript.com
Copyright 2012, Rob Larsen
Dual licensed under the MIT or GPL Version 2 licenses.
Date: 2013.1.10
*/
var f=void 0;
(function(q){var p=q.document,x=function(){function n(p){return new n.prototype.h(p)}n.prototype={h:function(n,h){function u(){b.stroke();return this}function q(a,c,d,e){i(a,c);b.strokeRect(a,c,d,e);return this}function y(a){v();w(a.x,a.y+a.a);r(a.x,a.y+a.height-a.a);s(a.x,a.y+a.height,a.x+a.a,a.y+a.height);r(a.x+a.width-a.a,a.y+a.height);s(a.x+a.width,a.y+a.height,a.x+a.width,a.y+a.height-a.a);r(a.x+a.width,a.y+a.a);s(a.x+a.width,a.y,a.x+a.width-a.a,a.y);r(a.x+a.a,a.y);s(a.x,a.y,a.x,a.y+a.a);u();
o({x:a.x,y:a.y,c:a.width,b:a.height});return this}function s(a,c,d,e){i(d,e);b.quadraticCurveTo(a,c,d,e);return this}function w(a,c){b.moveTo(a,c);i(a,c);return this}function r(a,c){b.lineTo(a,c);o({x:a,y:c});i(a,c);return this}function z(a,c,d,e){b.fillRect(a,c,d,e);i(a,c);o({x:a,y:c,c:d,b:e});return this}function A(){b.closePath();return this}function o(a){if(a!==f&&!(a.d!==f&&a.f!==f&&a.e!==f&&a.g!==f)&&!(a.x!==f&&a.y!==f&&a.c!==f&&a.b!==f)&&!(a.j!==f&&a.k!==f&&a.l!==f)&&a.x!==f&&a.y!==f){var b=
i();o({d:a.x,f:a.y,e:b.x,g:b.y})}}function v(){b.beginPath();return this}function B(a){a=a||{};b.arc(g(a.x,l),g(a.y,m),a.a||0,a.start||0,a.end||Math.PI*2,a.p||!1);return this}function g(a,b){return a!==f&&typeof a==="number"?a:b}function i(a,b){a!==f&&b!==f&&typeof a==="number"&&typeof b==="number"&&(l=a,m=b);return{x:l,y:m}}var h=h||{},k;p.getElementById(n)?k=p.getElementById(n):(k=p.createElement("canvas"),k.width=h.width||k.width,k.height=h.height||k.height,k.id=n);if(k.nodeName.toLowerCase()!==
"canvas"){var t=p.createElement("canvas");t.width=k.offsetHeight;t.height=k.offsetWidth;t.id="bigc";k.appendChild(t);b=p.getElementById("bigc");throw"The provided ID wasn't a canvas element. A canvas element with id 'bigc' created as a child of the supplied node.";}var l=0,m=0,b=k.getContext("2d");b.fillStyle=h.fillStyle||b.fillStyle;b.font=h.font||b.font;b.globalAlpha=h.globalAlpha||b.globalAlpha;b.globalCompositeOperation=h.globalCompositeOperation||b.globalCompositeOperation;b.lineCap=h.lineCap||
b.lineCap;b.lineJoin=h.lineJoin||b.lineJoin;b.lineWidth=h.lineWidth||b.lineWidth;b.miterLimit=h.miterLimit||b.miterLimit;b.shadowBlur=h.shadowBlur||b.shadowBlur;b.shadowColor=h.shadowColor||b.shadowColor;b.shadowOffsetX=h.s||b.shadowOffsetX;b.shadowOffsetY=h.shadowOffsetY||b.shadowOffsetY;b.strokeStyle=h.strokeStyle||b.strokeStyle;b.textAlign=h.textAlign||b.textAlign;b.textBaseline=h.textBaseline||b.textBaseline;var x={o:function(a){return 1/Math.sin(a)},r:function(a){return 1/Math.cos(a)},m:function(a){return a*
(Math.PI/180)}};return{arc:B,arcTo:function(a,c,d,e,j){b.arcTo(a,c,d,e,j);i(d,e);return this},beginPath:v,bezierCurveTo:function(a,c,d,e,j,g){b.bezierCurveTo(a,c,d,e,j,g);i(j,g);return this},boundingBox:function(){return _boundingbox()},circle:function(a){var a=a||{},c=g(a.x,l),d=g(a.y,m),e=a.a||10,j=a.fillStyle||!1,a=a.strokeStyle||!1;w(c,d);v();B({x:c,y:d,a:e});if(j)b.fillStyle=j,b.fill();if(a)b.strokeStyle=a,u();A();o({j:c,k:d,l:e});return this},clearRect:function(a){var a=a||{},c=g(a.x,l),d=g(a.y,
m),e=a.width||0,a=a.height||0;b.clearRect(c,d,e,a);o({x:c,y:d,c:e,b:a});return this},clip:function(){b.clip();return this},closePath:A,context:b,container:k,createImageData:function(a,c){return a.data!==f?b.createImageData(a):b.createImageData(a,c)},createLinearGradient:function(a,c,d,e){return b.createLinearGradient(a,c,d,e)},createPattern:function(a,c){return b.createPattern(a,c)},createRadialGradient:function(a,c,d,e,j,g){return b.createRadialGradient(a,c,d,e,j,g)},drawImage:function(a,c,d){if(a.nodeName==
null){var e=new Image;e.src=a;a=e}a.onload=function(){b.drawImage(a,c,d)};c=g(c,l);d=g(d,m);i(c,d);return this},fill:function(){b.fill();return this},fillCircle:function(a){a=a||{};this.i({x:g(a.x,l),y:g(a.y,m),a:a.a||10,fillStyle:a.fillStyle||b.fillStyle,strokeStyle:!1});return this},fillRect:z,fillStyle:function(a){return a!==f?(b.fillStyle=a,this):b.fillStyle},fillText:function(a,c,d,e){e===f?b.fillText(a,c,d):b.fillText(a,c,d,e);i(c,d);return this},font:function(a){return a!==f?(b.font=a,this):
b.font},currentPos:i,getImageData:function(a,c,d,e){i(a,c);return b.getImageData(a,c,d,e)},globalAlpha:function(a){return a!==f?(b.globalAlpha=a,this):b.globalAlpha},globalCompositeOperation:function(a){return a!==f?(b.globalCompositeOperation=a,this):b.globalCompositeOperation},isPointInPath:function(a,c){return b.isPointInPath(a,c)},line:function(a){var a=a||{},c=g(a.x,l),d=g(a.y,m),e=a.q||0,j=x.m(a.n%360||0),a=c+Math.cos(j)*e,e=d+Math.sin(j)*e;b.moveTo(c,d);b.lineTo(a,e);i(a,e);o({d:c,f:d,e:a,
g:e});return this},lineCap:function(a){return a!==f?(b.lineCap=a,this):b.lineCap},lineJoin:function(a){return a!==f?(b.lineJoin=a,this):b.lineJoin},lineTo:r,lineWidth:function(a){return a!==f?(b.lineWidth=a,this):b.lineWidth},miterLimit:function(a){return a!==f?(b.miterLimit=a,this):b.miterLimit},measureText:function(a){return b.measureText(a)},moveTo:w,putImageData:function(a,c,d,e,g,h,k){i(c,d);b.putImageData(a,c,d,e,g,h,k);return this},quadraticCurveTo:s,rect:function(a,c,d,e){i(a,c);b.rect(a,
c,d,e);o({x:a,y:c,c:d,b:e});return this},rectangle:function(a){var a=a||{},c,d,e,j;if(a.d!==f&&a.f!==f&&a.e!==f&&a.g!==f)c=g(a.d,l),d=g(a.f,m),e=Math.abs(c-a.e),j=Math.abs(d-a.g);else if(a.x!==f&&a.y!==f&&a.width!==f&&a.height!==f)c=g(a.x,l),d=g(a.y,m),e=g(a.width,0),j=g(a.height,0);else return this;var h=a.fillStyle||!1;if(a=a.lineWidth||!1)b.lineWidth=a;h?(b.fillStyle=h,z(c,d,e,j)):q(c,d,e,j);o({x:c,y:d,c:e,b:j});return this},reset:function(){k.width=k.width;i(0,0);return this},restore:function(){b.restore();
return this},rotate:function(a){b.rotate(a);return this},roundedRectangle:y,roundedRect:y,save:function(){b.save();return this},scale:function(a,c){b.scale(a,c);return this},setTransform:function(a,c,d,e,g,h){b.setTransform(a,c,d,e,g,h);return this},shadowBlur:function(a){return a!==f?(b.shadowBlur=a,this):b.shadowBlur},shadowColor:function(a){return a!==f?(b.shadowColor=a,this):b.shadowColor},shadowOffset:function(a,c){return a!==f?(b.shadowOffsetX=a,b.shadowOffsetY=c!==f?c:a,this):{x:b.shadowOffsetX,
y:b.shadowOffsetY}},shadowOffsetX:function(a){return a!==f?(b.shadowOffsetX=a,this):b.shadowOffsetX},shadowOffsetY:function(a){return a!==f?(b.shadowOffsetY=a,this):b.shadowOffsetY},stroke:u,strokeCircle:function(a){a=a||{};this.i({x:g(a.x,l),y:g(a.y,m),a:a.a||10,fillStyle:!1,strokeStyle:a.strokeStyle||b.strokeStyle});return this},strokeStyle:function(a){return a!==f?(b.strokeStyle=a,this):b.strokeStyle},strokeText:function(a,c,d,e){i(c,d);b.strokeText(a,c,d,e);return this},strokeRect:q,textAlign:function(a){return a!==
f?(b.textAlign=a,this):b.textAlign},textBaseline:function(a){return a!==f?(b.textBaseline=a,this):b.textBaseline},transform:function(a,c,d,e,g,h){i(g,h);b.transform(a,c,d,e,g,h);return this},translate:function(a,c){i(a,c);b.translate(a,c);return this}}}};n.prototype.h.prototype=n.prototype;return n}();q.Canvas=x})(window);