From a6ef09a09d8032097514eabe796b679096f9c3db Mon Sep 17 00:00:00 2001 From: Nikos M Date: Tue, 13 Dec 2022 18:15:14 +0200 Subject: [PATCH] v.0.9.5 * user-defined tween.fps * properly stop/restart tween animation * fix match_shapes * tween.framesPerSecond() --- beeld.config | 52 ++++++++++++++--------------- build/Geometrize.js | 73 +++++++++++++++++++++++++++++++++-------- build/Geometrize.min.js | 5 ++- src/Tween.js | 69 +++++++++++++++++++++++++++++++------- 4 files changed, 146 insertions(+), 53 deletions(-) diff --git a/beeld.config b/beeld.config index 200dad2..433030e 100644 --- a/beeld.config +++ b/beeld.config @@ -67,30 +67,30 @@ tasks =[{}] out = ./build/Geometrize.js @ - #minify =[{}] - # - # src =[] - # ./build/Geometrize.js - # @ - # - # # Minify the Package (map of lists) - # minify ={} - # # Options for Node UglifyJS Compiler (if used, default), (mangle and compress) - # uglifyjs =[] - # -m -c - # @ - # - # # Options for Java Closure Compiler (if used) - # closure =[] - # "--language_in=ECMASCRIPT5_STRICT" - # @ - # - # # Options for Java YUI Compressor Compiler (if used) - # yui =[] - # --preserve-semi - # @ - # @ - # - # out = ./build/Geometrize.min.js - #@ + minify =[{}] + + src =[] + ./build/Geometrize.js + @ + + # Minify the Package (map of lists) + minify ={} + # Options for Node UglifyJS Compiler (if used, default), (mangle and compress) + uglifyjs =[] + -m -c + @ + + # Options for Java Closure Compiler (if used) + closure =[] + "--language_in=ECMASCRIPT5_STRICT" + @ + + # Options for Java YUI Compressor Compiler (if used) + yui =[] + --preserve-semi + @ + @ + + out = ./build/Geometrize.min.js + @ @ diff --git a/build/Geometrize.js b/build/Geometrize.js index 1d8bbb9..706a609 100644 --- a/build/Geometrize.js +++ b/build/Geometrize.js @@ -2,14 +2,14 @@ * Geometrize * computational geometry and rendering library for JavaScript * -* @version 0.9.5 (2022-12-13 15:01:12) +* @version 0.9.5 (2022-12-13 18:11:08) * https://github.com/foo123/Geometrize * **//** * Geometrize * computational geometry and rendering library for JavaScript * -* @version 0.9.5 (2022-12-13 15:01:12) +* @version 0.9.5 (2022-12-13 18:11:08) * https://github.com/foo123/Geometrize * **/ @@ -4349,7 +4349,7 @@ function prepare_tween(tween, fps) var t = { duration: null == tween.duration ? 1000 : (tween.duration || 0), delay: tween.delay || 0, - fps: fps, + fps: clamp(null != tween.fps ? Num(tween.fps) : fps, 1, fps), nframes: 0, keyframes: null, kf: 0, @@ -4482,10 +4482,9 @@ function prepare_tween(tween, fps) t.keyframes.forEach(function(_, i) { if (i+1 < t.keyframes.length) { - // forward direction match_shapes(t.keyframes[i], t.keyframes[i+1], 0, 1); - maxCurves = stdMath.max(maxCurves, t.keyframes[i].shape[0].length); } + maxCurves = stdMath.max(maxCurves, t.keyframes[i].shape[0].length); }); t.keyframes.forEach(function(kf, i) { add_curves(kf.shape[0], maxCurves); @@ -4647,7 +4646,7 @@ function next_frame(tween) var Tween = makeClass(Primitive, { constructor: function Tween(tween) { var self = this, run = false, - fps = 60, dt = 0, + fps = 60, dt = 0, timer = null, onStart = null, onEnd = null, animate; if (tween instanceof Tween) return tween; @@ -4656,12 +4655,14 @@ var Tween = makeClass(Primitive, { Primitive.call(self); self.start = function() { run = true; + if (timer) {clearTimeout(timer); timer = null;} if (is_first_frame(tween) && onStart) onStart(self); - setTimeout(animate, (is_first_frame(tween) ? (tween.delay || 0) : 0) + dt); + timer = setTimeout(animate, (is_first_frame(tween) ? (tween.delay || 0) : 0) + dt); return self; }; self.stop = function() { run = false; + if (timer) {clearTimeout(timer); timer = null;} return self; }; self.rewind = function() { @@ -4684,6 +4685,9 @@ var Tween = makeClass(Primitive, { self.numberOfFrames = function() { return tween.nframes; }; + self.framesPerSecond = function() { + return tween.fps; + }; self.getBoundingBox = function() { return { ymin: tween.bb.ymin, @@ -4766,14 +4770,56 @@ var Tween = makeClass(Primitive, { ctx.stroke(); }; self.toCanvasPath = function(ctx) { - ctx.beginPath(); - tween.current.shape.forEach(function(cb) { - ctx.moveTo(cb[0].x, cb[0].y); - ctx.bezierCurveTo(cb[1].x, cb[1].y, cb[2].x, cb[2].y, cb[3].x, cb[3].y); + var firstx = 0, firsty = 0, + lastx = 0, lasty = 0, + isConnected = true; + tween.current.shape.forEach(function(b, i) { + var connects = true; + if (0 === i) + { + connects = true; + firstx = b[0].x; + firsty = b[0].y; + ctx.beginPath(); + ctx.moveTo(b[0].x, b[0].y); + ctx.bezierCurveTo(b[1].x, b[1].y, b[2].x, b[2].y, b[3].x, b[3].y); + } + else + { + connects = is_almost_equal(b[0].x, lastx) && is_almost_equal(b[0].y, lasty); + if (connects) + { + ctx.bezierCurveTo(b[1].x, b[1].y, b[2].x, b[2].y, b[3].x, b[3].y); + } + else + { + if (isConnected && is_almost_equal(firstx, lastx) && is_almost_equal(firsty, lasty)) + { + // close this and start new path + ctx.closePath(); + ctx.beginPath(); + isConnected = true; + } + else + { + isConnected = false; + } + firstx = b[0].x; + firsty = b[0].y; + ctx.moveTo(b[0].x, b[0].y); + ctx.bezierCurveTo(b[1].x, b[1].y, b[2].x, b[2].y, b[3].x, b[3].y); + } + } + lastx = b[3].x; + lasty = b[3].y; }); + if (isConnected && is_almost_equal(firstx, lastx) && is_almost_equal(firsty, lasty)) + ctx.closePath(); }; self.dispose = function() { run = false; + if (timer) clearTimeout(timer); + timer = null; onStart = null; onEnd = null; tween = null; @@ -4781,8 +4827,9 @@ var Tween = makeClass(Primitive, { }; fps = 60; - dt = stdMath.floor(1000/fps); tween = prepare_tween(tween, fps); + fps = tween.fps; + dt = stdMath.floor(1000/fps); animate = function animate() { if (!run || !tween) return; if (next_frame(tween)) @@ -4794,7 +4841,7 @@ var Tween = makeClass(Primitive, { } else { - setTimeout(animate, dt); + timer = setTimeout(animate, dt); } } }; diff --git a/build/Geometrize.min.js b/build/Geometrize.min.js index 4621481..9e3b8b1 100644 --- a/build/Geometrize.min.js +++ b/build/Geometrize.min.js @@ -2,8 +2,7 @@ * Geometrize * computational geometry and rendering library for JavaScript * -* @version 0.9.5 (2022-12-13 15:01:12) +* @version 0.9.5 (2022-12-13 18:11:08) * https://github.com/foo123/Geometrize * -**/ -!function(t,n,e){"use strict";"object"==typeof module&&module.exports?(module.$deps=module.$deps||{})&&(module.exports=module.$deps[n]=e.call(t)):"function"==typeof define&&define.amd&&"function"==typeof require&&"function"==typeof require.specified&&require.specified(n)?define(n,["module"],function(n){return e.moduleUri=n.uri,e.call(t)}):n in t||(t[n]=e.call(t)||1)&&"function"==typeof define&&define.amd&&define(function(){return t[n]})}("undefined"!=typeof self?self:this,"Geometrize",function(){"use strict";var v=Object.prototype.hasOwnProperty,t=Object.prototype.toString,b=Object.defineProperty,S=Math,G=S.abs,C=S.sqrt,l=S.pow,$=S.PI,w=2*$,u=1e-6,o=$/2,a=3*$/2,r=C(2),c=C(3),f=20,h=.01,_={},y=function(){},n="undefined"!=typeof global&&"[object global]"===t.call(global),x="undefined"!=typeof window&&"[object Window]"===t.call(window),e=(n?global:x&&window,{VERSION:"0.9.5",Math:{},Geometry:{}});function i(n,t,e){var r,i,o,a=v.call(t,"constructor")?t.constructor:function(){};for(r in n?(a.prototype=Object.create(n.prototype),a.prototype.$super=(i=n,o={},function(n,t){var e=":"+n;return 1===o[e]?(i.prototype.$super||y).call(this,n,t):(o[e]=1,t=("constructor"===n?i:i.prototype[n]||y).apply(this,t||[]),o[e]=0,t)})):a.prototype.$super=y,a.prototype.constructor=a,t)v.call(t,r)&&"constructor"!==r&&(a.prototype[r]=t[r]);if(e)for(r in e)v.call(e,r)&&(a[r]=e[r]);return a}var n={$changed:!1,$cb:null,dispose:function(){this.$cb=null},isChanged:function(n){return arguments.length?(this.$changed=!!n,this):this.$changed},onChange:function(n,t){var e,r=this;return!1===t&&(St(n)||_t(n))?r.$cb&&-1!==(e=(_t(n)?r.$cb.map(function(n){return bt(n.id)}):r.$cb).indexOf(n))&&r.$cb.splice(e,1):St(n)&&(r.$cb||(r.$cb=[]),-1===(e=r.$cb.indexOf(n))&&r.$cb.push(n)),r},triggerChange:function(){var t=this;return t.$cb&&t.$cb.forEach(function(n){n(t)}),t}},k=i(null,ct(null,{constructor:function e(r){var i=this;return r instanceof e?r:i instanceof e?(r=Ct(r),i.dispose=function(){r=null,e.prototype.dispose.call(i)},i.clone=function(){return new e(r)},i.val=function(n){if(arguments.length){n=n instanceof e?n.val():Ct(n);var t=!st(r,n);return r=n,t&&!i.isChanged()&&(i.isChanged(!0),i.triggerChange()),i}return r},i.valueOf=function(){return r.valueOf()},i.toString=function(){return bt(r)},void i.isChanged(!0)):new e(r)},clone:null,val:null,valueOf:null,toString:null},n)),g=i(null,{constructor:function n(t,e,r,i,o,a,s,u,l){var c=this;return t instanceof n?t:c instanceof n?(kt(t)&&9<=t.length?(c.$00=Ct(t[0]),c.$01=Ct(t[1]),c.$02=Ct(t[2]),c.$10=Ct(t[3]),c.$11=Ct(t[4]),c.$12=Ct(t[5])):(c.$00=t,c.$01=e,c.$02=r,c.$10=i,c.$11=o,c.$12=a),c.$20=0,c.$21=0,void(c.$22=1)):new n(t,e,r,i,o,a,s,u,l)},$00:1,$01:0,$02:0,$10:0,$11:1,$12:0,$20:0,$21:0,$22:1,clone:function(){var n=this;return new g(n.$00,n.$01,n.$02,n.$10,n.$11,n.$12,0,0,1)},eq:function(n){if(n instanceof g){var t=this;return st(t.$00,n.$00)&&st(t.$01,n.$01)&&st(t.$02,n.$02)&&st(t.$10,n.$10)&&st(t.$11,n.$11)&&st(t.$12,n.$12)}return!1},add:function(n){var t=this;return n instanceof g?new g(t.$00+n.$00,t.$01+n.$01,t.$02+n.$02,t.$10+n.$10,t.$11+n.$11,t.$12+n.$12,0,0,1):(n=Ct(n),new g(t.$00+n,t.$01+n,t.$02+n,t.$10+n,t.$11+n,t.$12+n,0,0,1))},mul:function(n){var t=this;return n instanceof g?new g(t.$00*n.$00+t.$01*n.$10+t.$02*n.$20,t.$00*n.$01+t.$01*n.$11+t.$02*n.$21,t.$00*n.$02+t.$01*n.$12+t.$02*n.$22,t.$10*n.$00+t.$11*n.$10+t.$12*n.$20,t.$10*n.$01+t.$11*n.$11+t.$12*n.$21,t.$10*n.$02+t.$11*n.$12+t.$12*n.$22,0,0,1):(n=Ct(n),new g(t.$00*n,t.$01*n,t.$02*n,t.$10*n,t.$11*n,t.$12*n,0,0,1))},det:function(){var n=this;return n.$00*(n.$11*n.$22-n.$12*n.$21)+n.$01*(n.$12*n.$20-n.$10*n.$22)+n.$02*(n.$21*n.$10-n.$11*n.$20)},inv:function(){var n,t,e,r=this,i=r.$00,o=r.$01,a=r.$02,s=r.$10,u=r.$11,l=r.$12,c=i*u-o*s;return at(c,0)?null:new g(n=u/c,t=-o/c,-n*a-t*l,e=-s/c,r=i/c,-e*a-r*l,0,0,1)},transform:function(n,t){var e=this,r=n.x,i=n.y,n=e.$00*r+e.$01*i+e.$02,e=e.$10*r+e.$11*i+e.$12;return t?(t.x=n,t.y=e):t=new B(n,e),t},getTranslation:function(){return{x:this.$02,y:this.$12}},getRotationAngle:function(){return S.atan2(this.$10,this.$00)},getScale:function(){var n=this.$00,t=-this.$01,e=this.$10,r=this.$11;return{x:ot(n)*Hn(n,e),y:ot(r)*Hn(t,r)}},toArray:function(){var n=this;return[n.$00,n.$01,n.$02,n.$10,n.$11,n.$12,n.$20,n.$21,n.$22]},toSVG:function(){var n=this;return"matrix("+bt(n.$00)+" "+bt(n.$10)+" "+bt(n.$01)+" "+bt(n.$11)+" "+bt(n.$02)+" "+bt(n.$12)+")"},toCSS:function(){var n=this;return"matrix("+bt(n.$00)+","+bt(n.$10)+","+bt(n.$01)+","+bt(n.$11)+","+bt(n.$02)+","+bt(n.$12)+")"},toCanvas:function(n){var t=this;return n.transform(t.$00,t.$10,t.$01,t.$11,t.$02,t.$12),n},toTex:function(){return g.arrayTex(this.toArray(),3,3)},toString:function(){return g.arrayString(this.toArray(),3,3)}},{eye:function(){return new g(1,0,0,0,1,0,0,0,1)},translate:function(n,t){return new g(1,0,Ct(n),0,1,Ct(t),0,0,1)},rotate:function(n,t,e){e=Ct(e||0),t=Ct(t||0),n=Ct(n);var r=S.cos(n),n=S.sin(n);return new g(r,-n,t-r*t+n*e,n,r,e-r*e-n*t,0,0,1)},scale:function(n,t,e,r){return r=Ct(r||0),e=Ct(e||0),n=Ct(n),t=Ct(t),new g(n,0,-n*e+e,0,t,-t*r+r,0,0,1)},reflectX:function(){return new g(-1,0,0,0,1,0,0,0,1)},reflectY:function(){return new g(1,0,0,0,-1,0,0,0,1)},shearX:function(n){return new g(1,Ct(n),0,0,1,0,0,0,1)},shearY:function(n){return new g(1,0,0,Ct(n),1,0,0,0,1)},arrayTex:function(n,t,e){for(var r="\\begin{pmatrix}",i=0;it.x?n:t),(!g&&(st.y?n:t),{ymin:h.y,xmin:f.x,ymax:u.y,xmax:o.x}}),configurable:!1}),void(l.isChanged=function(n){return!0===n&&(v=d=m=null),l.$super("isChanged",arguments)})):new n(t,e,r,i,o,a,s)},name:"Arc",clone:function(){var n=this;return new D(n.start.clone(),n.end.clone(),n.radiusX,n.radiusY,n.angle,n.largeArc,n.sweep)},transform:function(n){var t=this,e=t.radiusX,r=t.radiusY,i=t.angle,o=rt(n.getRotationAngle()),a=n.getScale();return new D(t.start.transform(n),t.end.transform(n),e*a.x,r*a.y,i+o,t.largeArc,t.sweep)},isClosed:function(){return!1},isConvex:function(){return!1},hasMatrix:function(){return!1},f:function(n){var t=this,e=t.center,r=t.cs;return Nn(t.theta+n*t.dtheta,e.x,e.y,t.rX,t.rY,r[0],r[1])},d:function(){var n,t,e,r,i,o,a,s=this,a=(n=s.center.x,t=s.center.y,e=s.rY,r=s.rX,i=[s.cs[0],-s.cs[1]],o=-s.theta,a=-s.dtheta,{p0:Nn(o,n,t,e,r,i[0],i[1]),p1:Nn(o+a,n,t,e,r,i[0],i[1]),fa:G(a)>$,fs:0=w&&n.closePath()},toTex:function(){var n=this;return"\\text{Arc: }\\left("+[$t(n.start),$t(n.end),bt(n.radiusX),bt(n.radiusY),bt(n.angle)+"\\text{°}",bt(n.largeArc?1:0),bt(n.sweep?1:0)].join(",")+"\\right)"},toString:function(){var n=this;return"Arc("+[bt(n.start),bt(n.end),bt(n.radiusX),bt(n.radiusY),bt(n.angle)+"°",bt(n.largeArc),bt(n.sweep)].join(",")+")"}});e.Arc=D;var H=i(n,{constructor:function n(t){var r,i=this,e=null,o=null,a=null;return t instanceof n?t:i instanceof n?(i.$super("constructor",[t]),b(i,"length",{get:function(){return null==e&&(e=jn(i._lines)),e},enumerable:!0,configurable:!1}),b(i,"_bbox",{get:function(){return null==o&&(o=r(i._points)),o},enumerable:!(r=function(t){var n=An(t[0].x-2*t[1].x+t[2].x,t[1].x-t[0].x),e=!1===n?[t[1]]:n.map(function(n){return 0<=n&&n<=1?Ln(n,t):t[1]}),r=An(t[0].y-2*t[1].y+t[2].y,t[1].y-t[0].y),n=!1===r?[t[1]]:r.map(function(n){return 0<=n&&n<=1?Ln(n,t):t[1]}),r=S.min.apply(S,e.concat([t[0],t[2]]).map(ut)),e=S.max.apply(S,e.concat([t[0],t[2]]).map(ut));return{ymin:S.min.apply(S,n.concat([t[0],t[2]]).map(lt)),xmin:r,ymax:S.max.apply(S,n.concat([t[0],t[2]]).map(lt)),xmax:e}}),configurable:!1}),b(i,"_hull",{get:function(){var t,n,e;return null==a&&(n=Dn(e=i._points),t=g.rotate(n.R).mul(g.translate(n.Tx,n.Ty)),n=r(e.map(function(n){return t.transform(n,{x:0,y:0})})),e=t.inv(),a=[e.transform(new B(n.xmin,n.ymin)),e.transform(new B(n.xmax,n.ymin)),e.transform(new B(n.xmax,n.ymax)),e.transform(new B(n.xmin,n.ymax))]),a},enumerable:!1,configurable:!1}),void(i.isChanged=function(n){return!0===n&&(a=o=e=null),i.$super("isChanged",arguments)})):new n(t)},name:"QBezier",clone:function(){return new H(this.points.map(function(n){return n.clone()}))},transform:function(t){return new H(this.points.map(function(n){return n.transform(t)}))},hasPoint:function(n){return fn(n,this._points)},intersects:function(n){var t,e=this;return n instanceof B?!!(t=fn(n,e._points))&&[n]:n instanceof J?!!(t=wn(e._lines,n.center,n.radius))&&t.map(B):n instanceof K?!!(t=_n(e._lines,n.center,n.radiusX,n.radiusY,n.cs))&&t.map(B):n instanceof D?!!(t=kn(e._lines,n.center,n.rX,n.rY,n.cs,n.theta,n.dtheta))&&t.map(B):n instanceof H?!!(t=Pn(e._lines,n._points))&&t.map(B):n instanceof E&&n.intersects(e)},f:function(n){return Ln(n,this._points)},bezierPoints:function(){var n=this._points;return[[{x:n[0].x,y:n[0].y},{x:n[0].x+2*(n[1].x-n[0].x)/3,y:n[0].y+2*(n[1].y-n[0].y)/3},{x:n[2].x+2*(n[1].x-n[2].x)/3,y:n[2].y+2*(n[1].y-n[2].y)/3},{x:n[2].x,y:n[2].y}]]},toSVG:function(n){return this.toSVGPath(!!arguments.length&&n)},toSVGPath:function(n){var t=this,e=t._points,e=["M",e[0].x,e[0].y,"Q",e[1].x,e[1].y,e[2].x,e[2].y].join(" ");return arguments.length?ft("path",{id:[t.id,!1],d:[e,t.isChanged()],style:[t.style.toSVG(),t.style.isChanged()]},n):e},toCanvas:function(n){this.style.toCanvas(n),this.toCanvasPath(n),n.stroke()},toCanvasPath:function(n){var t=this._points;n.beginPath(),n.moveTo(t[0].x,t[0].y),n.quadraticCurveTo(t[1].x,t[1].y,t[2].x,t[2].y)}});e.QBezier=e.Bezier2=H;var W=i(n,{constructor:function n(t){var r,i=this,e=null,o=null,a=null;return t instanceof n?t:i instanceof n?(i.$super("constructor",[t]),b(i,"length",{get:function(){return null==e&&(e=jn(i._lines)),e},enumerable:!0,configurable:!1}),b(i,"_bbox",{get:function(){return null==o&&(o=r(i._points)),o},enumerable:!(r=function(e){var n=Xn(3*(-e[0].x+3*e[1].x-3*e[2].x+e[3].x),2*(3*e[0].x-6*e[1].x+3*e[2].x),-3*e[0].x+3*e[1].x),t=!1===n?[e[1],e[2]]:n.map(function(n,t){return 0<=n&&n<=1?Rn(n,e):e[t+1]}),r=Xn(3*(-e[0].y+3*e[1].y-3*e[2].y+e[3].y),2*(3*e[0].y-6*e[1].y+3*e[2].y),-3*e[0].y+3*e[1].y),n=!1===r?[e[1],e[2]]:r.map(function(n,t){return 0<=n&&n<=1?Rn(n,e):e[t+1]}),r=S.min.apply(S,t.concat([e[0],e[3]]).map(ut)),t=S.max.apply(S,t.concat([e[0],e[3]]).map(ut));return{ymin:S.min.apply(S,n.concat([e[0],e[3]]).map(lt)),xmin:r,ymax:S.max.apply(S,n.concat([e[0],e[3]]).map(lt)),xmax:t}}),configurable:!1}),b(i,"_hull",{get:function(){var t,n,e;return null==a&&(n=Dn(e=i._points),t=g.rotate(n.R).mul(g.translate(n.Tx,n.Ty)),n=r(e.map(function(n){return t.transform(n,{x:0,y:0})})),e=t.inv(),a=[e.transform(new B(n.xmin,n.ymin)),e.transform(new B(n.xmax,n.ymin)),e.transform(new B(n.xmax,n.ymax)),e.transform(new B(n.xmin,n.ymax))]),a},enumerable:!1,configurable:!1}),void(i.isChanged=function(n){return!0===n&&(a=o=e=null),i.$super("isChanged",arguments)})):new n(t)},name:"CBezier",clone:function(){return new W(this.points.map(function(n){return n.clone()}))},transform:function(t){return new W(this.points.map(function(n){return n.transform(t)}))},hasPoint:function(n){return hn(n,this._points)},intersects:function(n){var t,e=this;return n instanceof B?!!(t=hn(n,e._points))&&[n]:n instanceof J?!!(t=wn(e._lines,n.center,n.radius))&&t.map(B):n instanceof K?!!(t=_n(e._lines,n.center,n.radiusX,n.radiusY,n.cs))&&t.map(B):n instanceof D?!!(t=kn(e._lines,n.center,n.rX,n.rY,n.cs,n.theta,n.dtheta))&&t.map(B):n instanceof H?!!(t=Pn(e._lines,n._points))&&t.map(B):n instanceof W?!!(t=Sn(e._lines,n._points))&&t.map(B):n instanceof E&&n.intersects(e)},f:function(n){return Rn(n,this._points)},bezierPoints:function(){var n=this._points;return[[{x:n[0].x,y:n[0].y},{x:n[1].x,y:n[1].y},{x:n[2].x,y:n[2].y},{x:n[3].x,y:n[3].y}]]},toSVG:function(n){return this.toSVGPath(!!arguments.length&&n)},toSVGPath:function(n){var t=this,e=t._points,e=["M",e[0].x,e[0].y,"C",e[1].x,e[1].y,e[2].x,e[2].y,e[3].x,e[3].y].join(" ");return arguments.length?ft("path",{id:[t.id,!1],d:[e,t.isChanged()],style:[t.style.toSVG(),t.style.isChanged()]},n):e},toCanvas:function(n){this.style.toCanvas(n),this.toCanvasPath(n),n.stroke()},toCanvasPath:function(n){var t=this._points;n.beginPath(),n.moveTo(t[0].x,t[0].y),n.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y)}});e.CBezier=e.Bezier3=W;var U=i(z,{constructor:function n(t){var r=this,e=null,i=null,o=null,a=null,s=null;return t instanceof n?t:r instanceof n?(r.$super("constructor",[t]),b(r,"vertices",{get:function(){return r.points},set:function(n){r.points=n},enumerable:!0,configurable:!1}),b(r,"edges",{get:function(){var e=r.points;return 1=n.nframes}n["ease-in"]=n["ease-in-quad"],n["ease-out"]=n["ease-out-quad"],n["ease-in-out"]=n["ease-in-out-quad"];var on=i(E,{constructor:function n(e){var t,r=this,i=!1,o=0,a=null,s=null;return e instanceof n?e:r instanceof n?(E.call(r),r.start=function(){return i=!0,en(e)&&a&&a(r),setTimeout(t,(en(e)&&e.delay||0)+o),r},r.stop=function(){return i=!1,r},r.rewind=function(){return function(n){n.reverse?n.kf=n.keyframes.length-1:n.kf=0;var t,e,r,i,o,a,s=n.keyframes[n.kf],u=s.transform.translate.x,l=s.transform.translate.y,c=s.transform.scale.origin.x,f=s.transform.scale.origin.y,h=s.transform.scale.x,y=s.transform.scale.y,g=s.transform.rotate.origin.x,x=s.transform.rotate.origin.y,p=s.transform.rotate.angle,m=1,d=0,v=s.shape[n.reverse?1:0],b=v.length,C=new Array(b);for(st(p,0)||(m=S.cos(p),d=S.sin(p)),u+=g-m*g+d*x,l+=x-m*x-d*g,e=0;e=n.keyframes[n.kf+1].frame&&n.kf+2"+bt(r)+"":"/>");return t}function ht(a,s,u,i){if(St(a.onChange))return a;function l(t){a.$cb.forEach(function(n){n(t)})}var c=!0;i=i||gt;var f=function(n,t){for(var e=n;et.x?n:t),(!g&&(st.y?n:t),{ymin:h.y,xmin:f.x,ymax:u.y,xmax:o.x}}),configurable:!1}),void(l.isChanged=function(n){return!0===n&&(v=d=m=null),l.$super("isChanged",arguments)})):new n(t,e,r,i,o,a,s)},name:"Arc",clone:function(){var n=this;return new D(n.start.clone(),n.end.clone(),n.radiusX,n.radiusY,n.angle,n.largeArc,n.sweep)},transform:function(n){var t=this,e=t.radiusX,r=t.radiusY,i=t.angle,o=rt(n.getRotationAngle()),a=n.getScale();return new D(t.start.transform(n),t.end.transform(n),e*a.x,r*a.y,i+o,t.largeArc,t.sweep)},isClosed:function(){return!1},isConvex:function(){return!1},hasMatrix:function(){return!1},f:function(n){var t=this,e=t.center,r=t.cs;return Nn(t.theta+n*t.dtheta,e.x,e.y,t.rX,t.rY,r[0],r[1])},d:function(){var n,t,e,r,i,o,a,s=this,a=(n=s.center.x,t=s.center.y,e=s.rY,r=s.rX,i=[s.cs[0],-s.cs[1]],o=-s.theta,a=-s.dtheta,{p0:Nn(o,n,t,e,r,i[0],i[1]),p1:Nn(o+a,n,t,e,r,i[0],i[1]),fa:G(a)>$,fs:0=w&&n.closePath()},toTex:function(){var n=this;return"\\text{Arc: }\\left("+[$t(n.start),$t(n.end),bt(n.radiusX),bt(n.radiusY),bt(n.angle)+"\\text{°}",bt(n.largeArc?1:0),bt(n.sweep?1:0)].join(",")+"\\right)"},toString:function(){var n=this;return"Arc("+[bt(n.start),bt(n.end),bt(n.radiusX),bt(n.radiusY),bt(n.angle)+"°",bt(n.largeArc),bt(n.sweep)].join(",")+")"}});e.Arc=D;var H=i(n,{constructor:function n(t){var r,i=this,e=null,o=null,a=null;return t instanceof n?t:i instanceof n?(i.$super("constructor",[t]),b(i,"length",{get:function(){return null==e&&(e=Tn(i._lines)),e},enumerable:!0,configurable:!1}),b(i,"_bbox",{get:function(){return null==o&&(o=r(i._points)),o},enumerable:!(r=function(t){var n=An(t[0].x-2*t[1].x+t[2].x,t[1].x-t[0].x),e=!1===n?[t[1]]:n.map(function(n){return 0<=n&&n<=1?Ln(n,t):t[1]}),r=An(t[0].y-2*t[1].y+t[2].y,t[1].y-t[0].y),n=!1===r?[t[1]]:r.map(function(n){return 0<=n&&n<=1?Ln(n,t):t[1]}),r=S.min.apply(S,e.concat([t[0],t[2]]).map(ut)),e=S.max.apply(S,e.concat([t[0],t[2]]).map(ut));return{ymin:S.min.apply(S,n.concat([t[0],t[2]]).map(lt)),xmin:r,ymax:S.max.apply(S,n.concat([t[0],t[2]]).map(lt)),xmax:e}}),configurable:!1}),b(i,"_hull",{get:function(){var t,n,e;return null==a&&(n=Dn(e=i._points),t=g.rotate(n.R).mul(g.translate(n.Tx,n.Ty)),n=r(e.map(function(n){return t.transform(n,{x:0,y:0})})),e=t.inv(),a=[e.transform(new B(n.xmin,n.ymin)),e.transform(new B(n.xmax,n.ymin)),e.transform(new B(n.xmax,n.ymax)),e.transform(new B(n.xmin,n.ymax))]),a},enumerable:!1,configurable:!1}),void(i.isChanged=function(n){return!0===n&&(a=o=e=null),i.$super("isChanged",arguments)})):new n(t)},name:"QBezier",clone:function(){return new H(this.points.map(function(n){return n.clone()}))},transform:function(t){return new H(this.points.map(function(n){return n.transform(t)}))},hasPoint:function(n){return fn(n,this._points)},intersects:function(n){var t,e=this;return n instanceof B?!!(t=fn(n,e._points))&&[n]:n instanceof J?!!(t=wn(e._lines,n.center,n.radius))&&t.map(B):n instanceof K?!!(t=_n(e._lines,n.center,n.radiusX,n.radiusY,n.cs))&&t.map(B):n instanceof D?!!(t=kn(e._lines,n.center,n.rX,n.rY,n.cs,n.theta,n.dtheta))&&t.map(B):n instanceof H?!!(t=Pn(e._lines,n._points))&&t.map(B):n instanceof E&&n.intersects(e)},f:function(n){return Ln(n,this._points)},bezierPoints:function(){var n=this._points;return[[{x:n[0].x,y:n[0].y},{x:n[0].x+2*(n[1].x-n[0].x)/3,y:n[0].y+2*(n[1].y-n[0].y)/3},{x:n[2].x+2*(n[1].x-n[2].x)/3,y:n[2].y+2*(n[1].y-n[2].y)/3},{x:n[2].x,y:n[2].y}]]},toSVG:function(n){return this.toSVGPath(!!arguments.length&&n)},toSVGPath:function(n){var t=this,e=t._points,e=["M",e[0].x,e[0].y,"Q",e[1].x,e[1].y,e[2].x,e[2].y].join(" ");return arguments.length?ft("path",{id:[t.id,!1],d:[e,t.isChanged()],style:[t.style.toSVG(),t.style.isChanged()]},n):e},toCanvas:function(n){this.style.toCanvas(n),this.toCanvasPath(n),n.stroke()},toCanvasPath:function(n){var t=this._points;n.beginPath(),n.moveTo(t[0].x,t[0].y),n.quadraticCurveTo(t[1].x,t[1].y,t[2].x,t[2].y)}});e.QBezier=e.Bezier2=H;var W=i(n,{constructor:function n(t){var r,i=this,e=null,o=null,a=null;return t instanceof n?t:i instanceof n?(i.$super("constructor",[t]),b(i,"length",{get:function(){return null==e&&(e=Tn(i._lines)),e},enumerable:!0,configurable:!1}),b(i,"_bbox",{get:function(){return null==o&&(o=r(i._points)),o},enumerable:!(r=function(e){var n=Xn(3*(-e[0].x+3*e[1].x-3*e[2].x+e[3].x),2*(3*e[0].x-6*e[1].x+3*e[2].x),-3*e[0].x+3*e[1].x),t=!1===n?[e[1],e[2]]:n.map(function(n,t){return 0<=n&&n<=1?Rn(n,e):e[t+1]}),r=Xn(3*(-e[0].y+3*e[1].y-3*e[2].y+e[3].y),2*(3*e[0].y-6*e[1].y+3*e[2].y),-3*e[0].y+3*e[1].y),n=!1===r?[e[1],e[2]]:r.map(function(n,t){return 0<=n&&n<=1?Rn(n,e):e[t+1]}),r=S.min.apply(S,t.concat([e[0],e[3]]).map(ut)),t=S.max.apply(S,t.concat([e[0],e[3]]).map(ut));return{ymin:S.min.apply(S,n.concat([e[0],e[3]]).map(lt)),xmin:r,ymax:S.max.apply(S,n.concat([e[0],e[3]]).map(lt)),xmax:t}}),configurable:!1}),b(i,"_hull",{get:function(){var t,n,e;return null==a&&(n=Dn(e=i._points),t=g.rotate(n.R).mul(g.translate(n.Tx,n.Ty)),n=r(e.map(function(n){return t.transform(n,{x:0,y:0})})),e=t.inv(),a=[e.transform(new B(n.xmin,n.ymin)),e.transform(new B(n.xmax,n.ymin)),e.transform(new B(n.xmax,n.ymax)),e.transform(new B(n.xmin,n.ymax))]),a},enumerable:!1,configurable:!1}),void(i.isChanged=function(n){return!0===n&&(a=o=e=null),i.$super("isChanged",arguments)})):new n(t)},name:"CBezier",clone:function(){return new W(this.points.map(function(n){return n.clone()}))},transform:function(t){return new W(this.points.map(function(n){return n.transform(t)}))},hasPoint:function(n){return hn(n,this._points)},intersects:function(n){var t,e=this;return n instanceof B?!!(t=hn(n,e._points))&&[n]:n instanceof J?!!(t=wn(e._lines,n.center,n.radius))&&t.map(B):n instanceof K?!!(t=_n(e._lines,n.center,n.radiusX,n.radiusY,n.cs))&&t.map(B):n instanceof D?!!(t=kn(e._lines,n.center,n.rX,n.rY,n.cs,n.theta,n.dtheta))&&t.map(B):n instanceof H?!!(t=Pn(e._lines,n._points))&&t.map(B):n instanceof W?!!(t=Sn(e._lines,n._points))&&t.map(B):n instanceof E&&n.intersects(e)},f:function(n){return Rn(n,this._points)},bezierPoints:function(){var n=this._points;return[[{x:n[0].x,y:n[0].y},{x:n[1].x,y:n[1].y},{x:n[2].x,y:n[2].y},{x:n[3].x,y:n[3].y}]]},toSVG:function(n){return this.toSVGPath(!!arguments.length&&n)},toSVGPath:function(n){var t=this,e=t._points,e=["M",e[0].x,e[0].y,"C",e[1].x,e[1].y,e[2].x,e[2].y,e[3].x,e[3].y].join(" ");return arguments.length?ft("path",{id:[t.id,!1],d:[e,t.isChanged()],style:[t.style.toSVG(),t.style.isChanged()]},n):e},toCanvas:function(n){this.style.toCanvas(n),this.toCanvasPath(n),n.stroke()},toCanvasPath:function(n){var t=this._points;n.beginPath(),n.moveTo(t[0].x,t[0].y),n.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y)}});e.CBezier=e.Bezier3=W;var U=i(z,{constructor:function n(t){var r=this,e=null,i=null,o=null,a=null,s=null;return t instanceof n?t:r instanceof n?(r.$super("constructor",[t]),b(r,"vertices",{get:function(){return r.points},set:function(n){r.points=n},enumerable:!0,configurable:!1}),b(r,"edges",{get:function(){var e=r.points;return 1=n.nframes}n["ease-in"]=n["ease-in-quad"],n["ease-out"]=n["ease-out-quad"],n["ease-in-out"]=n["ease-in-out-quad"];var on=i(E,{constructor:function n(l){var t,e,r=this,i=!1,o=0,a=null,s=null,u=null;return l instanceof n?l:r instanceof n?(E.call(r),r.start=function(){return i=!0,a&&(clearTimeout(a),a=null),en(l)&&s&&s(r),a=setTimeout(e,(en(l)&&l.delay||0)+o),r},r.stop=function(){return i=!1,a&&(clearTimeout(a),a=null),r},r.rewind=function(){return function(n){n.reverse?n.kf=n.keyframes.length-1:n.kf=0;var t,e,r,i,o,a,s=n.keyframes[n.kf],u=s.transform.translate.x,l=s.transform.translate.y,c=s.transform.scale.origin.x,f=s.transform.scale.origin.y,h=s.transform.scale.x,y=s.transform.scale.y,g=s.transform.rotate.origin.x,x=s.transform.rotate.origin.y,p=s.transform.rotate.angle,m=1,d=0,v=s.shape[n.reverse?1:0],b=v.length,C=new Array(b);for(st(p,0)||(m=S.cos(p),d=S.sin(p)),u+=g-m*g+d*x,l+=x-m*x-d*g,e=0;e=n.keyframes[n.kf+1].frame&&n.kf+2"+bt(r)+"":"/>");return t}function ht(a,s,u,i){if(St(a.onChange))return a;function l(t){a.$cb.forEach(function(n){n(t)})}var c=!0;i=i||gt;var f=function(n,t){for(var e=n;e