paper.js/dist/paper-core.min.js

36 lines
156 KiB
JavaScript
Raw Normal View History

2013-06-26 22:42:24 -04:00
/*!
2013-07-21 19:51:52 -04:00
* Paper.js v0.9.9 - The Swiss Army Knife of Vector Graphics Scripting.
2013-06-26 22:42:24 -04:00
* http://paperjs.org/
*
* Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey
* http://lehni.org/ & http://jonathanpuckey.com/
*
* Distributed under the MIT license. See LICENSE file for details.
*
* All rights reserved.
*
2013-07-21 19:51:52 -04:00
* Date: Sun Jul 21 16:44:30 2013 -0700
2013-06-26 22:42:24 -04:00
*
***
*
* straps.js - Class inheritance library with support for bean-style accessors
*
* Copyright (c) 2006 - 2013 Juerg Lehni
* http://lehni.org/
*
* Distributed under the MIT license.
*
***
*
* acorn.js
* http://marijnhaverbeke.nl/acorn/
*
* Acorn is a tiny, fast JavaScript parser written in JavaScript,
* created by Marijn Haverbeke and released under an MIT license.
*
*/
2013-07-21 19:51:52 -04:00
var paper=new function(){var t=new function(){function e(t,e,i,n,r,a){function h(n,s,a,h){var s=s||(s=d(e,n))&&(s.get?s:s.value);"string"==typeof s&&"#"===s[0]&&(s=t[s.substring(1)]||s);var l,c="function"==typeof s,_=s,g=r||c?s&&s.get?n in t:t[n]:null;!(a||void 0!==s&&e.hasOwnProperty(n))||r&&g||(c&&g&&(s.base=g),c&&u&&0===s.length&&(l=n.match(/^(get|is)(([A-Z])(.*))$/))&&u.push([l[3].toLowerCase()+l[4],l[2]]),_&&!c&&_.get||(_={value:_,writable:!0}),(d(t,n)||{configurable:!0}).configurable&&(_.configurable=!0,_.enumerable=i),f(t,n,_)),!h||!c||r&&h[n]||(h[n]=function(e){return e&&t[n].apply(e,o.call(arguments,1))})}var u;if(e){u=[];for(var l in e)e.hasOwnProperty(l)&&!s.test(l)&&h(l,null,!0,a);h("toString"),h("valueOf");for(var c=0,_=u&&u.length;_>c;c++)try{var g=u[c],v=g[1];h(g[0],{get:t["get"+v]||t["is"+v],set:t["set"+v]},!0)}catch(m){}}return t}function i(e,i,n,s){try{e&&(s||void 0===s&&l(e)?h:u).call(e,i,n=n||e)}catch(r){if(r!==t.stop)throw r}return n}function n(t){return i(t,function(t,e){this[e]=t},new t.constructor)}var s=/^(statics|generics|preserve|enumerable|prototype|toString|valueOf)$/,r=Object.prototype.toString,a=Array.prototype,o=a.slice,h=a.forEach||function(t,e){for(var i=0,n=this.length;n>i;i++)t.call(e,this[i],i,this)},u=function(t,e){for(var i in this)this.hasOwnProperty(i)&&t.call(e,this[i],i,this)},l=Array.isArray=Array.isArray||function(t){return"[object Array]"===r.call(t)},c=Object.create||function(t){return{__proto__:t}},d=Object.getOwnPropertyDescriptor||function(t,e){var i=t.__lookupGetter__&&t.__lookupGetter__(e);return i?{get:i,set:t.__lookupSetter__(e),enumerable:!0,configurable:!0}:t.hasOwnProperty(e)?{value:t[e],enumerable:!0,configurable:!0,writable:!0}:null},_=Object.defineProperty||function(t,e,i){return(i.get||i.set)&&t.__defineGetter__?(i.get&&t.__defineGetter__(e,i.get),i.set&&t.__defineSetter__(e,i.set)):t[e]=i.value,t},f=function(t,e,i){return delete t[e],_(t,e,i)};return e(function(){},{inject:function(t){if(t){var i=this.prototype,n=Object.getPrototypeOf(i).constructor,s=t.statics===!0?t:t.statics;s!=t&&e(i,t,t.enumerable,n&&n.prototype,t.preserve,t.generics&&this),e(this,s,!0,n,t.preserve)}for(var r=1,a=arguments.length;a>r;r++)this.inject(arguments[r]);return this},extend:function(){for(var t,i=this,n=0,s=arguments.length;s>n&&!(t=arguments[n].initialize);n++);return t=t||function(){i.apply(this,arguments)},t.prototype=c(this.prototype),f(t.prototype,"constructor",{value:t,writable:!0,configurable:!0}),e(t,this,!0),arguments.length?this.inject.apply(t,arguments):t}},!0).inject({inject:function(){for(var t=0,i=arguments.length;i>t;t++)e(this,arguments[t],arguments[t].enumerable);return this},extend:function(){var t=c(this);return t.inject.apply(t,arguments)},each:function(t,e){return i(this,t,e)},clone:function(){return n(this)},statics:{each:i,clone:n,define:f,describe:d,create:function(t){return c(t.prototype)},isPlainObject:function(e){var i=null!=e&&e.constructor;return i&&(i===Object||i===t||"Object"===i.name)},check:function(t){return!(!t&&0!==t)},pick:function(){for(var t=0,e=arguments.length;e>t;t++)if(void 0!==arguments[t])return arguments[t];return null},stop:{}}})};"undefined"!=typeof module&&(module.exports=t),t.inject({generics:!0,clone:function(){return new this.constructor(this)},toString:function(){return null!=this._id?(this._class||"Object")+(this._name?" '"+this._name+"'":" @"+this._id):"{ "+t.each(this,function(t,e){if(!/^_/.test(e)){var i=typeof t;this.push(e+": "+("number"===i?r.instance.number(t):"string"===i?"'"+t+"'":t))}},[]).join(", ")+" }"},exportJSON:function(e){return t.exportJSON(this,e)},toJSON:function(){return t.serialize(this)},_set:function(e,i){if(e&&t.isPlainObject(e)){for(var n in e)!(e.hasOwnProperty(n)&&n in this)||i&&i[n]||(this[n]=e[n]);return!0}},statics:{exports:{},extend:function ee(){var e=ee.base.apply(this,arguments),i=e.prototype._class;return i&&!t.exports[i]&&(t.exports[i]=e),e},equals:function(e,i){function n(t,e){for(var i in t)if(t.hasOwnProperty(i)&&void 0===e[i])return!1;return!0}if(e===i)return!0;if(e&&e.equals)return e.
},getTranslation:function(){return new o(this._tx,this._ty)},getScaling:function(){return(this.decompose()||{}).scaling},getRotation:function(){return(this.decompose()||{}).rotation},inverted:function(){var t=this._getDeterminant();return t&&new f(this._d/t,-this._c/t,-this._b/t,this._a/t,(this._b*this._ty-this._d*this._tx)/t,(this._c*this._tx-this._a*this._ty)/t)},shiftless:function(){return new f(this._a,this._c,this._b,this._d,0,0)},applyToContext:function(t){t.transform(this._a,this._c,this._b,this._d,this._tx,this._ty)}},new function(){return t.each({scaleX:"_a",scaleY:"_d",translateX:"_tx",translateY:"_ty",shearX:"_b",shearY:"_c"},function(e,i){i=t.capitalize(i),this["get"+i]=function(){return this[e]},this["set"+i]=function(t){this[e]=t}},{})}),g=t.extend({_class:"Line",initialize:function(t,e,i,n,s){var r=!1;arguments.length>=4?(this._px=t,this._py=e,this._vx=i,this._vy=n,r=s):(this._px=t.x,this._py=t.y,this._vx=e.x,this._vy=e.y,r=i),r||(this._vx-=this._px,this._vy-=this._py)},getPoint:function(){return new o(this._px,this._py)},getVector:function(){return new o(this._vx,this._vy)},getLength:function(){return this.getVector().getLength()},intersect:function(t,e){return g.intersect(this._px,this._py,this._vx,this._vy,t._px,t._py,t._vx,t._vy,!0,e)},getSide:function(t){return g.getSide(this._px,this._py,this._vx,this._vy,t.x,t.y,!0)},getDistance:function(t){return Math.abs(g.getSignedDistance(this._px,this._py,this._vx,this._vy,t.x,t.y,!0))},statics:{intersect:function(t,e,i,n,s,r,h,u,l,c){l||(i-=t,n-=e,h-=s,u-=r);var d=u*i-h*n;if(!a.isZero(d)){var _=t-s,f=e-r,g=(h*f-u*_)/d,v=(i*f-n*_)/d;if((c||g>=0&&1>=g)&&(c||v>=0&&1>=v))return new o(t+g*i,e+g*n)}},getSide:function(t,e,i,n,s,r,a){a||(i-=t,n-=e);var o=s-t,h=r-e,u=o*n-h*i;return 0===u&&(u=o*i+h*n,u>0&&(o-=i,h-=n,u=o*i+h*n,0>u&&(u=0))),0>u?-1:u>0?1:0},getSignedDistance:function(t,e,i,n,s,r,a){a||(i-=t,n-=e);var o=n/i,h=e-o*t;return(r-o*s-h)/Math.sqrt(o*o+1)}}}),v=s.extend({_class:"Project",_list:"projects",_reference:"project",initialize:function(t){s.call(this,!0),this.layers=[],this.symbols=[],this._currentStyle=new R,this.activeLayer=new w,t&&(this.view=t instanceof V?t:V.create(t)),this._selectedItems={},this._selectedItemCount=0,this._drawCount=0,this.options={}},_serialize:function(e,i){return t.serialize(this.layers,e,!0,i)},clear:function(){for(var t=this.layers.length-1;t>=0;t--)this.layers[t].remove();this.symbols=[]},remove:function re(){return re.base.call(this)?(this.view&&this.view.remove(),!0):!1},getCurrentStyle:function(){return this._currentStyle},setCurrentStyle:function(t){this._currentStyle.initialize(t)},getIndex:function(){return this._index},getSelectedItems:function(){var t=[];for(var e in this._selectedItems){var i=this._selectedItems[e];i._drawCount===this._drawCount&&t.push(i)}return t},_updateSelection:function(t){t._selected?(this._selectedItemCount++,this._selectedItems[t._id]=t,t.isInserted()&&(t._drawCount=this._drawCount)):(this._selectedItemCount--,delete this._selectedItems[t._id])},selectAll:function(){for(var t=0,e=this.layers.length;e>t;t++)this.layers[t].setSelected(!0)},deselectAll:function(){for(var t in this._selectedItems)this._selectedItems[t].setSelected(!1)},hitTest:function(e,i){e=o.read(arguments),i=S.getOptions(t.read(arguments));for(var n=this.layers.length-1;n>=0;n--){var s=this.layers[n].hitTest(e,i);if(s)return s}return null},importJSON:function(e){return this.activate(),t.importJSON(e)},draw:function(e,i){this._drawCount++,e.save(),i.applyToContext(e);for(var n=t.merge({offset:new o(0,0),transforms:[i]}),s=0,r=this.layers.length;r>s;s++)this.layers[s].draw(e,n);if(e.restore(),this._selectedItemCount>0){e.save(),e.strokeWidth=1;for(var a in this._selectedItems){var h=this._selectedItems[a];if(h._drawCount===this._drawCount&&(h._drawSelected||h._boundsSelected)){var u=h.getSelectedColor()||h.getLayer().getSelectedColor();e.strokeStyle=e.fillStyle=u?u.toCanvasStyle(e):"#009dec";var l=h._globalMatrix;if(h._drawSelected&&h._drawSelected(e,l),h._boundsSelected){var c=l._transformCorners(h._getBounds("getBounds"));e.be
},_setSelected:function(t,e){var i=this._path,e=!!e,n=this._selectionState||0,s=[!!(4&n),!!(1&n),!!(2&n)];if(t==this._point){if(e)s[1]=s[2]=!1;else{var r=this.getPrevious(),a=this.getNext();s[1]=r&&(r._point.isSelected()||r._handleOut.isSelected()),s[2]=a&&(a._point.isSelected()||a._handleIn.isSelected())}s[0]=e}else{var o=t==this._handleIn?1:2;s[o]!=e&&(e&&(s[0]=!1),s[o]=e)}this._selectionState=(s[0]?4:0)|(s[1]?1:0)|(s[2]?2:0),i&&n!=this._selectionState&&(i._updateSelection(this,n,this._selectionState),i._changed(33))},isSelected:function(){return this._isSelected(this._point)},setSelected:function(t){this._setSelected(this._point,t)},getIndex:function(){return void 0!==this._index?this._index:null},getPath:function(){return this._path||null},getCurve:function(){var t=this._path,e=this._index;return t?(t._closed||e!=t._segments.length-1||e--,t.getCurves()[e]||null):null},getLocation:function(){var t=this.getCurve();return t?new I(t,t.getNext()?0:1):null},getNext:function(){var t=this._path&&this._path._segments;return t&&(t[this._index+1]||this._path._closed&&t[0])||null},getPrevious:function(){var t=this._path&&this._path._segments;return t&&(t[this._index-1]||this._path._closed&&t[t.length-1])||null},reverse:function(){return new P(this._point,this._handleOut,this._handleIn)},remove:function(){return this._path?!!this._path.removeSegment(this._index):!1},clone:function(){return new P(this._point,this._handleIn,this._handleOut)},equals:function(t){return t===this||t&&this._point.equals(t._point)&&this._handleIn.equals(t._handleIn)&&this._handleOut.equals(t._handleOut)||!1},toString:function(){var t=["point: "+this._point];return this._handleIn.isZero()||t.push("handleIn: "+this._handleIn),this._handleOut.isZero()||t.push("handleOut: "+this._handleOut),"{ "+t.join(", ")+" }"},_transformCoordinates:function(t,e,i){var n=this._point,s=i&&this._handleIn.isZero()?null:this._handleIn,r=i&&this._handleOut.isZero()?null:this._handleOut,a=n._x,o=n._y,h=2;return e[0]=a,e[1]=o,s&&(e[h++]=s._x+a,e[h++]=s._y+o),r&&(e[h++]=r._x+a,e[h++]=r._y+o),t&&(t._transformCoordinates(e,0,e,0,h/2),a=e[0],o=e[1],i?(n._x=a,n._y=o,h=2,s&&(s._x=e[h++]-a,s._y=e[h++]-o),r&&(r._x=e[h++]-a,r._y=e[h++]-o)):(s||(e[h++]=a,e[h++]=o),r||(e[h++]=a,e[h++]=o))),e}}),z=o.extend({initialize:function(t,e){var i,n,s;t?void 0!==(i=t[0])?n=t[1]:(void 0===(i=t.x)&&(t=o.read(arguments),i=t.x),n=t.y,s=t.selected):i=n=0,this._x=i,this._y=n,this._owner=e,s&&this.setSelected(!0)},set:function(t,e){return this._x=t,this._y=e,this._owner._changed(this),this},getX:function(){return this._x},setX:function(t){this._x=t,this._owner._changed(this)},getY:function(){return this._y},setY:function(t){this._y=t,this._owner._changed(this)},isZero:function(){return a.isZero(this._x)&&a.isZero(this._y)},setSelected:function(t){this._owner._setSelected(this,t)},isSelected:function(){return this._owner._isSelected(this)}}),M=t.extend({_class:"Curve",initialize:function(t,e,i,n,s,r,a,o){var h=arguments.length;if(3===h)this._path=t,this._segment1=e,this._segment2=i;else if(0===h)this._segment1=new P,this._segment2=new P;else if(1===h)this._segment1=new P(t.segment1),this._segment2=new P(t.segment2);else if(2===h)this._segment1=new P(t),this._segment2=new P(e);else{var u,l,c,d;4===h?(u=t,l=e,c=i,d=n):8===h&&(u=[t,e],d=[a,o],l=[i-t,n-e],c=[s-a,r-o]),this._segment1=new P(u,null,l),this._segment2=new P(d,c,null)}},_changed:function(){delete this._length,delete this._bounds},getPoint1:function(){return this._segment1._point},setPoint1:function(t){t=o.read(arguments),this._segment1._point.set(t.x,t.y)},getPoint2:function(){return this._segment2._point},setPoint2:function(t){t=o.read(arguments),this._segment2._point.set(t.x,t.y)},getHandle1:function(){return this._segment1._handleOut},setHandle1:function(t){t=o.read(arguments),this._segment1._handleOut.set(t.x,t.y)},getHandle2:function(){return this._segment2._handleIn},setHandle2:function(t){t=o.read(arguments),this._segment2._handleIn.set(t.x,t.y)},getSegment1:function(){return this._segment1},getSegment2:function(){return this._segment2},getPat
if("boolean"==typeof u){i=h,n=u;var l=a.add(i).divide(2),s=l.add(l.subtract(a).rotate(n?-90:90))}else s=h,i=o.read(arguments);var c=new g(a.add(s).divide(2),s.subtract(a).rotate(90),!0),d=new g(s.add(i).divide(2),i.subtract(s).rotate(90),!0),_=c.intersect(d,!0),f=new g(a,i),v=f.getSide(s);if(!_){if(!v)return this.lineTo(i);throw Error("Cannot put an arc through the given points: "+[a,s,i])}var m=a.subtract(_),p=m.getDirectedAngle(i.subtract(_)),y=f.getSide(_);0==y?p=v*Math.abs(p):v==y&&(p-=360*(0>p?-1:1));for(var w=Math.abs(p),x=w>=360?4:Math.ceil(w/90),b=p/x,C=b*Math.PI/360,S=4/3*Math.sin(C)/(1+Math.cos(C)),z=[],M=0;x>=M;M++){var I=x>M?_.add(m):i,k=x>M?m.rotate(90).multiply(S):null;0==M?r.setHandleOut(k):z.push(new P(I,m.rotate(-90).multiply(S),k)),m=m.rotate(b)}this._add(z)},lineBy:function(t){t=o.read(arguments);var i=e(this);this.lineTo(i._point.add(t))},curveBy:function(t,i,n){t=o.read(t),i=o.read(i);var s=e(this)._point;this.curveTo(s.add(t),s.add(i),n)},arcBy:function(t,i){t=o.read(t),i=o.read(i);var n=e(this)._point;this.arcTo(n.add(t),n.add(i))},closePath:function(){var t=this.getFirstSegment(),e=this.getLastSegment();t._point.equals(e._point)&&(t.setHandleIn(e._handleIn),e.remove()),this.setClosed(!0)}}},{_getBounds:function(t,e){return A[t](this._segments,this._closed,this.getStyle(),e)},statics:{isClockwise:function(t){function e(t,e){r&&(s+=(i-t)*(e+n)),i=t,n=e,r=!0}for(var i,n,s=0,r=!1,a=0,o=t.length;o>a;a++){var h=t[a],u=t[o>a+1?a+1:0],l=h._point,c=h._handleOut,d=u._handleIn,_=u._point;e(l._x,l._y),e(l._x+c._x,l._y+c._y),e(_._x+d._x,_._y+d._y),e(_._x,_._y)}return s>0},getBounds:function(t,e,i,n,s){function r(t){t._transformCoordinates(n,o,!1);for(var e=0;2>e;e++)M._addBounds(h[e],h[e+4],o[e+2],o[e],e,s?s[e]:0,u,l,c);var i=h;h=o,o=i}var a=t[0];if(!a)return new d;for(var o=Array(6),h=a._transformCoordinates(n,Array(6),!1),u=h.slice(0,2),l=u.slice(),c=Array(2),_=1,f=t.length;f>_;_++)r(t[_]);return e&&r(a),new d(u[0],u[1],l[0]-u[0],l[1]-u[1])},getStrokeBounds:function(t,e,i,n){function s(t,e){if(!e)return[t,t];var i=e.shiftless(),n=i.transform(new o(t,0)),s=i.transform(new o(0,t)),r=n.getAngleInRadians(),a=n.getLength(),h=s.getLength(),u=Math.sin(r),l=Math.cos(r),c=Math.tan(r),d=-Math.atan(h*c/a),_=Math.atan(h/(c*a));return[Math.abs(a*Math.cos(d)*l-h*Math.sin(d)*u),Math.abs(h*Math.sin(_)*l+a*Math.cos(_)*u)]}function r(t){f=f.include(n?n._transformPoint(t,t):t)}function a(t,e){"round"===e||!t._handleIn.isZero()&&!t._handleOut.isZero()?f=f.unite(p.setCenter(n?n._transformPoint(t._point):t._point)):A._addSquareJoin(t,e,c,m,r)}function h(t,e){switch(e){case"round":a(t,e);break;case"butt":case"square":A._addSquareCap(t,e,c,r)}}if(!i.getStrokeColor()||!i.getStrokeWidth())return A.getBounds(t,e,i,n);for(var l=t.length-(e?0:1),c=i.getStrokeWidth()/2,_=s(c,n),f=A.getBounds(t,e,i,n,_),g=i.getStrokeJoin(),v=i.getStrokeCap(),m=c*i.getMiterLimit(),p=new d(new u(_).multiply(2)),y=1;l>y;y++)a(t[y],g);return e?a(t[0],g):(h(t[0],v),h(t[t.length-1],v)),f},_addSquareJoin:function(t,e,i,n,s,r){var a=t.getCurve(),h=a.getPrevious(),u=a.getPointAt(0,!0),l=h.getNormalAt(1,!0),c=a.getNormalAt(0,!0),d=l.getDirectedAngle(c)<0?-i:i;if(l.setLength(d),c.setLength(d),r&&(s(u),s(u.add(l))),"miter"===e){var _=new g(u.add(l),new o(-l.y,l.x),!0).intersect(new g(u.add(c),new o(-c.y,c.x),!0),!0);if(_&&u.getDistance(_)<=n&&(s(_),!r))return}r||s(u.add(l)),s(u.add(c))},_addSquareCap:function(t,e,i,n,s){var r=t._point,a=t.getLocation(),o=a.getNormal().normalize(i);s&&(n(r.subtract(o)),n(r.add(o))),"square"===e&&(r=r.add(o.rotate(0==a.getParameter()?-90:90))),n(r.add(o)),n(r.subtract(o))},getHandleBounds:function(t,e,i,n,s,r){var a=Array(6),o=1/0,h=-o,u=o,l=h;s=s/2||0,r=r/2||0;for(var c=0,_=t.length;_>c;c++){var f=t[c];f._transformCoordinates(n,a,!1);for(var g=0;6>g;g+=2){var v=0==g?r:s,m=a[g],p=a[g+1],y=m-v,w=m+v,x=p-v,b=p+v;o>y&&(o=y),w>h&&(h=w),u>x&&(u=x),b>l&&(l=b)}}return new d(o,u,h-o,l-u)},getRoughBounds:function(t,e,i,n){var s=i.getStrokeColor()?i.getStrokeWidth():0,r=s;return s>0&&("miter"===i.getStrokeJoin()&&(r=s*i.getMiterLimit()),"square
},stop:function(t){q.stopPropagation(t),q.preventDefault(t)}};q.requestAnimationFrame=new function(){var t="equestAnimationFrame",e=window["r"+t]||window["webkitR"+t]||window["mozR"+t]||window["oR"+t]||window["msR"+t];e&&e(function(t){null==t&&(e=null)});var i,s=[],r=!0;return q.add(window,{focus:function(){r=!0},blur:function(){r=!1}}),function(t,a){return e?e(t,a):(s.push([t,a]),i||(i=setInterval(function(){for(var t=s.length-1;t>=0;t--){var e=s[t],i=e[0],a=e[1];(!a||("true"==n.getAttribute(a,"keepalive")||r)&&E.isInView(a))&&(s.splice(t,1),i(Date.now()))}},1e3/60)),void 0)}};var V=t.extend(e,{_class:"View",initialize:function Se(t){this._scope=paper,this._project=paper.project,this._element=t;var e;if(this._id=t.getAttribute("id"),null==this._id&&t.setAttribute("id",this._id="view-"+Se._id++),q.add(t,this._viewHandlers),n.hasAttribute(t,"resize")){var i=E.getOffset(t,!0),s=this;e=E.getViewportBounds(t).getSize().subtract(i),this._windowHandlers={resize:function(){E.isInvisible(t)||(i=E.getOffset(t,!0)),s.setViewSize(E.getViewportBounds(t).getSize().subtract(i))}},q.add(window,this._windowHandlers)}else e=new u(parseInt(t.getAttribute("width"),10),parseInt(t.getAttribute("height"),10)),e.isNaN()&&(e=E.getSize(t));if(t.width=e.width,t.height=e.height,n.hasAttribute(t,"stats")&&"undefined"!=typeof Stats){this._stats=new Stats;var r=this._stats.domElement,a=r.style,i=E.getOffset(t);a.position="absolute",a.left=i.x+"px",a.top=i.y+"px",document.body.appendChild(r)}Se._views.push(this),Se._viewsById[this._id]=this,this._viewSize=new c(e.width,e.height,this,"setViewSize"),this._matrix=new f,this._zoom=1,Se._focused||(Se._focused=this),this._frameItems={},this._frameItemCount=0},remove:function(){return this._project?(V._focused==this&&(V._focused=null),V._views.splice(V._views.indexOf(this),1),delete V._viewsById[this._id],this._project.view==this&&(this._project.view=null),q.remove(this._element,this._viewHandlers),q.remove(window,this._windowHandlers),this._element=this._project=null,this.detach("frame"),this._frameItems={},!0):!1},_events:{onFrame:{install:function(){this._requested||(this._animate=!0,this._requestFrame())},uninstall:function(){this._animate=!1}},onResize:{}},_animate:!1,_time:0,_count:0,_requestFrame:function(){var t=this;q.requestAnimationFrame(function(){t._requested=!1,t._animate&&(t._requestFrame(),t._handleFrame())},this._element),this._requested=!0},_handleFrame:function(){paper=this._scope;var e=Date.now()/1e3,i=this._before?e-this._before:0;this._before=e,this._handlingFrame=!0,this.fire("frame",t.merge({delta:i,time:this._time+=i,count:this._count++})),this._stats&&this._stats.update(),this._handlingFrame=!1,this.draw(!0)},_animateItem:function(t,e){var i=this._frameItems;e?(i[t._id]={item:t,time:0,count:0},1===++this._frameItemCount&&this.attach("frame",this._handleFrameItems)):(delete i[t._id],0===--this._frameItemCount&&this.detach("frame",this._handleFrameItems))},_handleFrameItems:function(e){for(var i in this._frameItems){var n=this._frameItems[i];n.item.fire("frame",t.merge(e,{time:n.time+=e.delta,count:n.count++}))}},_redraw:function(){this._project._needsRedraw=!0,this._handlingFrame||(this._animate?this._handleFrame():this.draw())},_transform:function(t){this._matrix.concatenate(t),this._bounds=null,this._inverse=null,this._redraw()},getElement:function(){return this._element},getViewSize:function(){return this._viewSize},setViewSize:function(t){t=u.read(arguments);var e=t.subtract(this._viewSize);e.isZero()||(this._element.width=t.width,this._element.height=t.height,this._viewSize.set(t.width,t.height,!0),this._bounds=null,this.fire("resize",{size:t,delta:e}),this._redraw())},getBounds:function(){return this._bounds||(this._bounds=this._getInverse()._transformBounds(new d(new o,this._viewSize))),this._bounds},getSize:function(){return this.getBounds().getSize(arguments[0])},getCenter:function(){return this.getBounds().getCenter(arguments[0])},setCenter:function(t){t=o.read(arguments),this.scrollBy(t.subtract(this.getCenter()))},getZoom:function(){return this._zoom},setZoom:function(t)