@leafer-in/resize 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/resize.cjs CHANGED
@@ -128,8 +128,9 @@ function scaleResizePath(leaf, scaleX, scaleY) {
128
128
  leaf.path = leaf.__.path;
129
129
  }
130
130
  function scaleResizePoints(leaf, scaleX, scaleY) {
131
- PathScaler.scalePoints(leaf.__.points, scaleX, scaleY);
132
- leaf.points = leaf.__.points;
131
+ const { points } = leaf;
132
+ typeof points[0] === 'object' ? points.forEach(p => { p.x *= scaleX, p.y *= scaleY; }) : PathScaler.scalePoints(points, scaleX, scaleY);
133
+ leaf.points = points;
133
134
  }
134
135
  function scaleResizeGroup(group, scaleX, scaleY) {
135
136
  const { children } = group;
@@ -126,8 +126,9 @@ function scaleResizePath(leaf, scaleX, scaleY) {
126
126
  leaf.path = leaf.__.path;
127
127
  }
128
128
  function scaleResizePoints(leaf, scaleX, scaleY) {
129
- PathScaler.scalePoints(leaf.__.points, scaleX, scaleY);
130
- leaf.points = leaf.__.points;
129
+ const { points } = leaf;
130
+ typeof points[0] === 'object' ? points.forEach(p => { p.x *= scaleX, p.y *= scaleY; }) : PathScaler.scalePoints(points, scaleX, scaleY);
131
+ leaf.points = points;
131
132
  }
132
133
  function scaleResizeGroup(group, scaleX, scaleY) {
133
134
  const { children } = group;
@@ -1 +1 @@
1
- import{PathCommandMap as t,MatrixHelper as e,Direction9 as i,Leaf as s,Text as o,Path as a,Line as n,Polygon as c,Group as h,Box as l}from"@leafer-ui/draw";const{M:r,L:_,C:f,Q:p,Z:u,N:d,D:g,X:z,G:b,F:k,O:R,P:y,U:w}=t,S={scale(t,e,i){if(!t)return;let s,o=0,a=t.length;for(;o<a;)switch(s=t[o],s){case r:case _:m(t,e,i,o,1),o+=3;break;case f:m(t,e,i,o,3),o+=7;break;case p:m(t,e,i,o,2),o+=5;break;case u:o+=1;break;case d:m(t,e,i,o,2),o+=5;break;case g:m(t,e,i,o,2),o+=9;break;case z:m(t,e,i,o,2),o+=6;break;case b:m(t,e,i,o,2),o+=9;break;case k:m(t,e,i,o,2),o+=5;break;case R:t[o]=b,t.splice(o+4,0,t[o+3],0),m(t,e,i,o,2),o+=9,a+=2;break;case y:t[o]=k,t.splice(o+4,0,t[o+3]),m(t,e,i,o,2),o+=5,a+=1;break;case w:m(t,e,i,o,2),o+=6}},scalePoints(t,e,i,s,o){for(let a=o?s+1:0,n=o?a+2*o:t.length;a<n;a+=2)t[a]*=e,t[a+1]*=i}},{scalePoints:m}=S,x=e.get(),{topLeft:C,top:I,topRight:O,right:B,bottom:P,left:v}=i;function X(t,e,i){t.pathInputed?F(t,e,i):(1!==e&&(t.width*=e),1!==i&&(t.height*=i))}function D(t,e,i){const{app:s}=t,o=s&&s.editor;let a=e;if(o.editing){const s=t.__layout;let{width:n,height:c}=s.boxBounds;switch(n*=i-e,c*=e-i,o.resizeDirection){case I:case P:a=i,s.affectScaleOrRotation?t.moveInner(-n/2,0):t.x-=n/2;break;case v:case B:s.affectScaleOrRotation?t.moveInner(0,-c/2):t.y-=c/2;break;case C:case O:s.affectScaleOrRotation?t.moveInner(0,-c):t.y-=c}}t.fontSize*=a;const n=t.__;n.__autoWidth||(t.width*=a),n.__autoHeight||(t.height*=a)}function F(t,e,i){S.scale(t.__.path,e,i),t.path=t.__.path}function H(t,e,i){S.scalePoints(t.__.points,e,i),t.points=t.__.points}function L(t,e,i){const{children:s}=t;for(let t=0;t<s.length;t++)x.a=e,x.d=i,s[t].transform(x,!0)}const W=s.prototype;W.scaleResize=function(t,e=t,i){const s=this;i||s.editConfig&&"scale"===s.editConfig.editSize?(s.scaleX*=t,s.scaleY*=e):(t<0&&(s.scaleX*=-1,t=-t),e<0&&(s.scaleY*=-1,e=-e),this.__scaleResize(t,e))},W.__scaleResize=function(t,e){X(this,t,e)},W.resizeWidth=function(t){const e=t/this.getBounds("box","local").width;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},W.resizeHeight=function(t){const e=t/this.getBounds("box","local").height;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?e:1,e,!0)},o.prototype.__scaleResize=function(t,e){this.__.resizeFontSize||this.editConfig&&"font-size"===this.editConfig.editSize?D(this,t,e):X(this,t,e)},a.prototype.__scaleResize=function(t,e){F(this,t,e)},n.prototype.__scaleResize=function(t,e){this.pathInputed?F(this,t,e):this.points?H(this,t,e):this.width*=t},c.prototype.__scaleResize=function(t,e){this.pathInputed?F(this,t,e):this.points?H(this,t,e):X(this,t,e)},h.prototype.__scaleResize=function(t,e){L(this,t,e)},l.prototype.__scaleResize=function(t,e){this.__.__autoSize&&this.children.length?L(this,t,e):(X(this,t,e),this.__.resizeChildren&&L(this,t,e))};export{S as PathScaler,X as scaleResize,D as scaleResizeFontSize,L as scaleResizeGroup,F as scaleResizePath,H as scaleResizePoints};
1
+ import{PathCommandMap as t,MatrixHelper as e,Direction9 as i,Leaf as s,Text as o,Path as a,Line as c,Polygon as n,Group as h,Box as r}from"@leafer-ui/draw";const{M:l,L:_,C:f,Q:p,Z:u,N:d,D:b,X:g,G:z,F:k,O:R,P:y,U:w}=t,x={scale(t,e,i){if(!t)return;let s,o=0,a=t.length;for(;o<a;)switch(s=t[o],s){case l:case _:S(t,e,i,o,1),o+=3;break;case f:S(t,e,i,o,3),o+=7;break;case p:S(t,e,i,o,2),o+=5;break;case u:o+=1;break;case d:S(t,e,i,o,2),o+=5;break;case b:S(t,e,i,o,2),o+=9;break;case g:S(t,e,i,o,2),o+=6;break;case z:S(t,e,i,o,2),o+=9;break;case k:S(t,e,i,o,2),o+=5;break;case R:t[o]=z,t.splice(o+4,0,t[o+3],0),S(t,e,i,o,2),o+=9,a+=2;break;case y:t[o]=k,t.splice(o+4,0,t[o+3]),S(t,e,i,o,2),o+=5,a+=1;break;case w:S(t,e,i,o,2),o+=6}},scalePoints(t,e,i,s,o){for(let a=o?s+1:0,c=o?a+2*o:t.length;a<c;a+=2)t[a]*=e,t[a+1]*=i}},{scalePoints:S}=x,m=e.get(),{topLeft:C,top:I,topRight:O,right:B,bottom:P,left:v}=i;function X(t,e,i){t.pathInputed?F(t,e,i):(1!==e&&(t.width*=e),1!==i&&(t.height*=i))}function D(t,e,i){const{app:s}=t,o=s&&s.editor;let a=e;if(o.editing){const s=t.__layout;let{width:c,height:n}=s.boxBounds;switch(c*=i-e,n*=e-i,o.resizeDirection){case I:case P:a=i,s.affectScaleOrRotation?t.moveInner(-c/2,0):t.x-=c/2;break;case v:case B:s.affectScaleOrRotation?t.moveInner(0,-n/2):t.y-=n/2;break;case C:case O:s.affectScaleOrRotation?t.moveInner(0,-n):t.y-=n}}t.fontSize*=a;const c=t.__;c.__autoWidth||(t.width*=a),c.__autoHeight||(t.height*=a)}function F(t,e,i){x.scale(t.__.path,e,i),t.path=t.__.path}function H(t,e,i){const{points:s}=t;"object"==typeof s[0]?s.forEach((t=>{t.x*=e,t.y*=i})):x.scalePoints(s,e,i),t.points=s}function L(t,e,i){const{children:s}=t;for(let t=0;t<s.length;t++)m.a=e,m.d=i,s[t].transform(m,!0)}const W=s.prototype;W.scaleResize=function(t,e=t,i){const s=this;i||s.editConfig&&"scale"===s.editConfig.editSize?(s.scaleX*=t,s.scaleY*=e):(t<0&&(s.scaleX*=-1,t=-t),e<0&&(s.scaleY*=-1,e=-e),this.__scaleResize(t,e))},W.__scaleResize=function(t,e){X(this,t,e)},W.resizeWidth=function(t){const e=t/this.getBounds("box","local").width;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},W.resizeHeight=function(t){const e=t/this.getBounds("box","local").height;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?e:1,e,!0)},o.prototype.__scaleResize=function(t,e){this.__.resizeFontSize||this.editConfig&&"font-size"===this.editConfig.editSize?D(this,t,e):X(this,t,e)},a.prototype.__scaleResize=function(t,e){F(this,t,e)},c.prototype.__scaleResize=function(t,e){this.pathInputed?F(this,t,e):this.points?H(this,t,e):this.width*=t},n.prototype.__scaleResize=function(t,e){this.pathInputed?F(this,t,e):this.points?H(this,t,e):X(this,t,e)},h.prototype.__scaleResize=function(t,e){L(this,t,e)},r.prototype.__scaleResize=function(t,e){this.__.__autoSize&&this.children.length?L(this,t,e):(X(this,t,e),this.__.resizeChildren&&L(this,t,e))};export{x as PathScaler,X as scaleResize,D as scaleResizeFontSize,L as scaleResizeGroup,F as scaleResizePath,H as scaleResizePoints};
package/dist/resize.js CHANGED
@@ -128,8 +128,9 @@ this.LeaferIN.resize = (function (exports, draw) {
128
128
  leaf.path = leaf.__.path;
129
129
  }
130
130
  function scaleResizePoints(leaf, scaleX, scaleY) {
131
- PathScaler.scalePoints(leaf.__.points, scaleX, scaleY);
132
- leaf.points = leaf.__.points;
131
+ const { points } = leaf;
132
+ typeof points[0] === 'object' ? points.forEach(p => { p.x *= scaleX, p.y *= scaleY; }) : PathScaler.scalePoints(points, scaleX, scaleY);
133
+ leaf.points = points;
133
134
  }
134
135
  function scaleResizeGroup(group, scaleX, scaleY) {
135
136
  const { children } = group;
@@ -1 +1 @@
1
- "use strict";var e=require("@leafer-ui/draw");const{M:t,L:i,C:s,Q:o,Z:a,N:c,D:n,X:h,G:r,F:l,O:_,P:p,U:f}=e.PathCommandMap,u={scale(e,u,z){if(!e)return;let g,R=0,b=e.length;for(;R<b;)switch(g=e[R],g){case t:case i:d(e,u,z,R,1),R+=3;break;case s:d(e,u,z,R,3),R+=7;break;case o:d(e,u,z,R,2),R+=5;break;case a:R+=1;break;case c:d(e,u,z,R,2),R+=5;break;case n:d(e,u,z,R,2),R+=9;break;case h:d(e,u,z,R,2),R+=6;break;case r:d(e,u,z,R,2),R+=9;break;case l:d(e,u,z,R,2),R+=5;break;case _:e[R]=r,e.splice(R+4,0,e[R+3],0),d(e,u,z,R,2),R+=9,b+=2;break;case p:e[R]=l,e.splice(R+4,0,e[R+3]),d(e,u,z,R,2),R+=5,b+=1;break;case f:d(e,u,z,R,2),R+=6}},scalePoints(e,t,i,s,o){for(let a=o?s+1:0,c=o?a+2*o:e.length;a<c;a+=2)e[a]*=t,e[a+1]*=i}},{scalePoints:d}=u,z=e.MatrixHelper.get(),{topLeft:g,top:R,topRight:b,right:k,bottom:x,left:y}=e.Direction9;function P(e,t,i){e.pathInputed?w(e,t,i):(1!==t&&(e.width*=t),1!==i&&(e.height*=i))}function S(e,t,i){const{app:s}=e,o=s&&s.editor;let a=t;if(o.editing){const s=e.__layout;let{width:c,height:n}=s.boxBounds;switch(c*=i-t,n*=t-i,o.resizeDirection){case R:case x:a=i,s.affectScaleOrRotation?e.moveInner(-c/2,0):e.x-=c/2;break;case y:case k:s.affectScaleOrRotation?e.moveInner(0,-n/2):e.y-=n/2;break;case g:case b:s.affectScaleOrRotation?e.moveInner(0,-n):e.y-=n}}e.fontSize*=a;const c=e.__;c.__autoWidth||(e.width*=a),c.__autoHeight||(e.height*=a)}function w(e,t,i){u.scale(e.__.path,t,i),e.path=e.__.path}function m(e,t,i){u.scalePoints(e.__.points,t,i),e.points=e.__.points}function C(e,t,i){const{children:s}=e;for(let e=0;e<s.length;e++)z.a=t,z.d=i,s[e].transform(z,!0)}const B=e.Leaf.prototype;B.scaleResize=function(e,t=e,i){const s=this;i||s.editConfig&&"scale"===s.editConfig.editSize?(s.scaleX*=e,s.scaleY*=t):(e<0&&(s.scaleX*=-1,e=-e),t<0&&(s.scaleY*=-1,t=-t),this.__scaleResize(e,t))},B.__scaleResize=function(e,t){P(this,e,t)},B.resizeWidth=function(e){const t=e/this.getBounds("box","local").width;this.scaleOf(this.__layout.boxBounds,t,this.__.lockRatio?t:1,!0)},B.resizeHeight=function(e){const t=e/this.getBounds("box","local").height;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?t:1,t,!0)},e.Text.prototype.__scaleResize=function(e,t){this.__.resizeFontSize||this.editConfig&&"font-size"===this.editConfig.editSize?S(this,e,t):P(this,e,t)},e.Path.prototype.__scaleResize=function(e,t){w(this,e,t)},e.Line.prototype.__scaleResize=function(e,t){this.pathInputed?w(this,e,t):this.points?m(this,e,t):this.width*=e},e.Polygon.prototype.__scaleResize=function(e,t){this.pathInputed?w(this,e,t):this.points?m(this,e,t):P(this,e,t)},e.Group.prototype.__scaleResize=function(e,t){C(this,e,t)},e.Box.prototype.__scaleResize=function(e,t){this.__.__autoSize&&this.children.length?C(this,e,t):(P(this,e,t),this.__.resizeChildren&&C(this,e,t))},exports.PathScaler=u,exports.scaleResize=P,exports.scaleResizeFontSize=S,exports.scaleResizeGroup=C,exports.scaleResizePath=w,exports.scaleResizePoints=m;
1
+ "use strict";var e=require("@leafer-ui/draw");const{M:t,L:s,C:i,Q:o,Z:a,N:c,D:n,X:h,G:r,F:l,O:p,P:_,U:f}=e.PathCommandMap,u={scale(e,u,z){if(!e)return;let g,b=0,R=e.length;for(;b<R;)switch(g=e[b],g){case t:case s:d(e,u,z,b,1),b+=3;break;case i:d(e,u,z,b,3),b+=7;break;case o:d(e,u,z,b,2),b+=5;break;case a:b+=1;break;case c:d(e,u,z,b,2),b+=5;break;case n:d(e,u,z,b,2),b+=9;break;case h:d(e,u,z,b,2),b+=6;break;case r:d(e,u,z,b,2),b+=9;break;case l:d(e,u,z,b,2),b+=5;break;case p:e[b]=r,e.splice(b+4,0,e[b+3],0),d(e,u,z,b,2),b+=9,R+=2;break;case _:e[b]=l,e.splice(b+4,0,e[b+3]),d(e,u,z,b,2),b+=5,R+=1;break;case f:d(e,u,z,b,2),b+=6}},scalePoints(e,t,s,i,o){for(let a=o?i+1:0,c=o?a+2*o:e.length;a<c;a+=2)e[a]*=t,e[a+1]*=s}},{scalePoints:d}=u,z=e.MatrixHelper.get(),{topLeft:g,top:b,topRight:R,right:x,bottom:k,left:y}=e.Direction9;function P(e,t,s){e.pathInputed?w(e,t,s):(1!==t&&(e.width*=t),1!==s&&(e.height*=s))}function S(e,t,s){const{app:i}=e,o=i&&i.editor;let a=t;if(o.editing){const i=e.__layout;let{width:c,height:n}=i.boxBounds;switch(c*=s-t,n*=t-s,o.resizeDirection){case b:case k:a=s,i.affectScaleOrRotation?e.moveInner(-c/2,0):e.x-=c/2;break;case y:case x:i.affectScaleOrRotation?e.moveInner(0,-n/2):e.y-=n/2;break;case g:case R:i.affectScaleOrRotation?e.moveInner(0,-n):e.y-=n}}e.fontSize*=a;const c=e.__;c.__autoWidth||(e.width*=a),c.__autoHeight||(e.height*=a)}function w(e,t,s){u.scale(e.__.path,t,s),e.path=e.__.path}function m(e,t,s){const{points:i}=e;"object"==typeof i[0]?i.forEach((e=>{e.x*=t,e.y*=s})):u.scalePoints(i,t,s),e.points=i}function C(e,t,s){const{children:i}=e;for(let e=0;e<i.length;e++)z.a=t,z.d=s,i[e].transform(z,!0)}const B=e.Leaf.prototype;B.scaleResize=function(e,t=e,s){const i=this;s||i.editConfig&&"scale"===i.editConfig.editSize?(i.scaleX*=e,i.scaleY*=t):(e<0&&(i.scaleX*=-1,e=-e),t<0&&(i.scaleY*=-1,t=-t),this.__scaleResize(e,t))},B.__scaleResize=function(e,t){P(this,e,t)},B.resizeWidth=function(e){const t=e/this.getBounds("box","local").width;this.scaleOf(this.__layout.boxBounds,t,this.__.lockRatio?t:1,!0)},B.resizeHeight=function(e){const t=e/this.getBounds("box","local").height;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?t:1,t,!0)},e.Text.prototype.__scaleResize=function(e,t){this.__.resizeFontSize||this.editConfig&&"font-size"===this.editConfig.editSize?S(this,e,t):P(this,e,t)},e.Path.prototype.__scaleResize=function(e,t){w(this,e,t)},e.Line.prototype.__scaleResize=function(e,t){this.pathInputed?w(this,e,t):this.points?m(this,e,t):this.width*=e},e.Polygon.prototype.__scaleResize=function(e,t){this.pathInputed?w(this,e,t):this.points?m(this,e,t):P(this,e,t)},e.Group.prototype.__scaleResize=function(e,t){C(this,e,t)},e.Box.prototype.__scaleResize=function(e,t){this.__.__autoSize&&this.children.length?C(this,e,t):(P(this,e,t),this.__.resizeChildren&&C(this,e,t))},exports.PathScaler=u,exports.scaleResize=P,exports.scaleResizeFontSize=S,exports.scaleResizeGroup=C,exports.scaleResizePath=w,exports.scaleResizePoints=m;
@@ -1 +1 @@
1
- this.LeaferIN=this.LeaferIN||{},this.LeaferIN.resize=function(e,t){"use strict";const{M:i,L:s,C:o,Q:a,Z:n,N:c,D:h,X:r,G:l,F:_,O:f,P:p,U:u}=t.PathCommandMap,d={scale(e,t,d){if(!e)return;let g,R=0,b=e.length;for(;R<b;)switch(g=e[R],g){case i:case s:z(e,t,d,R,1),R+=3;break;case o:z(e,t,d,R,3),R+=7;break;case a:z(e,t,d,R,2),R+=5;break;case n:R+=1;break;case c:z(e,t,d,R,2),R+=5;break;case h:z(e,t,d,R,2),R+=9;break;case r:z(e,t,d,R,2),R+=6;break;case l:z(e,t,d,R,2),R+=9;break;case _:z(e,t,d,R,2),R+=5;break;case f:e[R]=l,e.splice(R+4,0,e[R+3],0),z(e,t,d,R,2),R+=9,b+=2;break;case p:e[R]=_,e.splice(R+4,0,e[R+3]),z(e,t,d,R,2),R+=5,b+=1;break;case u:z(e,t,d,R,2),R+=6}},scalePoints(e,t,i,s,o){for(let a=o?s+1:0,n=o?a+2*o:e.length;a<n;a+=2)e[a]*=t,e[a+1]*=i}},{scalePoints:z}=d,g=t.MatrixHelper.get(),{topLeft:R,top:b,topRight:k,right:y,bottom:I,left:P}=t.Direction9;function S(e,t,i){e.pathInputed?L(e,t,i):(1!==t&&(e.width*=t),1!==i&&(e.height*=i))}function x(e,t,i){const{app:s}=e,o=s&&s.editor;let a=t;if(o.editing){const s=e.__layout;let{width:n,height:c}=s.boxBounds;switch(n*=i-t,c*=t-i,o.resizeDirection){case b:case I:a=i,s.affectScaleOrRotation?e.moveInner(-n/2,0):e.x-=n/2;break;case P:case y:s.affectScaleOrRotation?e.moveInner(0,-c/2):e.y-=c/2;break;case R:case k:s.affectScaleOrRotation?e.moveInner(0,-c):e.y-=c}}e.fontSize*=a;const n=e.__;n.__autoWidth||(e.width*=a),n.__autoHeight||(e.height*=a)}function L(e,t,i){d.scale(e.__.path,t,i),e.path=e.__.path}function m(e,t,i){d.scalePoints(e.__.points,t,i),e.points=e.__.points}function w(e,t,i){const{children:s}=e;for(let e=0;e<s.length;e++)g.a=t,g.d=i,s[e].transform(g,!0)}const C=t.Leaf.prototype;return C.scaleResize=function(e,t=e,i){const s=this;i||s.editConfig&&"scale"===s.editConfig.editSize?(s.scaleX*=e,s.scaleY*=t):(e<0&&(s.scaleX*=-1,e=-e),t<0&&(s.scaleY*=-1,t=-t),this.__scaleResize(e,t))},C.__scaleResize=function(e,t){S(this,e,t)},C.resizeWidth=function(e){const t=e/this.getBounds("box","local").width;this.scaleOf(this.__layout.boxBounds,t,this.__.lockRatio?t:1,!0)},C.resizeHeight=function(e){const t=e/this.getBounds("box","local").height;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?t:1,t,!0)},t.Text.prototype.__scaleResize=function(e,t){this.__.resizeFontSize||this.editConfig&&"font-size"===this.editConfig.editSize?x(this,e,t):S(this,e,t)},t.Path.prototype.__scaleResize=function(e,t){L(this,e,t)},t.Line.prototype.__scaleResize=function(e,t){this.pathInputed?L(this,e,t):this.points?m(this,e,t):this.width*=e},t.Polygon.prototype.__scaleResize=function(e,t){this.pathInputed?L(this,e,t):this.points?m(this,e,t):S(this,e,t)},t.Group.prototype.__scaleResize=function(e,t){w(this,e,t)},t.Box.prototype.__scaleResize=function(e,t){this.__.__autoSize&&this.children.length?w(this,e,t):(S(this,e,t),this.__.resizeChildren&&w(this,e,t))},e.PathScaler=d,e.scaleResize=S,e.scaleResizeFontSize=x,e.scaleResizeGroup=w,e.scaleResizePath=L,e.scaleResizePoints=m,e}({},LeaferUI);
1
+ this.LeaferIN=this.LeaferIN||{},this.LeaferIN.resize=function(e,t){"use strict";const{M:i,L:s,C:o,Q:a,Z:c,N:n,D:h,X:r,G:l,F:f,O:_,P:p,U:u}=t.PathCommandMap,d={scale(e,t,d){if(!e)return;let g,b=0,R=e.length;for(;b<R;)switch(g=e[b],g){case i:case s:z(e,t,d,b,1),b+=3;break;case o:z(e,t,d,b,3),b+=7;break;case a:z(e,t,d,b,2),b+=5;break;case c:b+=1;break;case n:z(e,t,d,b,2),b+=5;break;case h:z(e,t,d,b,2),b+=9;break;case r:z(e,t,d,b,2),b+=6;break;case l:z(e,t,d,b,2),b+=9;break;case f:z(e,t,d,b,2),b+=5;break;case _:e[b]=l,e.splice(b+4,0,e[b+3],0),z(e,t,d,b,2),b+=9,R+=2;break;case p:e[b]=f,e.splice(b+4,0,e[b+3]),z(e,t,d,b,2),b+=5,R+=1;break;case u:z(e,t,d,b,2),b+=6}},scalePoints(e,t,i,s,o){for(let a=o?s+1:0,c=o?a+2*o:e.length;a<c;a+=2)e[a]*=t,e[a+1]*=i}},{scalePoints:z}=d,g=t.MatrixHelper.get(),{topLeft:b,top:R,topRight:k,right:y,bottom:x,left:I}=t.Direction9;function P(e,t,i){e.pathInputed?L(e,t,i):(1!==t&&(e.width*=t),1!==i&&(e.height*=i))}function S(e,t,i){const{app:s}=e,o=s&&s.editor;let a=t;if(o.editing){const s=e.__layout;let{width:c,height:n}=s.boxBounds;switch(c*=i-t,n*=t-i,o.resizeDirection){case R:case x:a=i,s.affectScaleOrRotation?e.moveInner(-c/2,0):e.x-=c/2;break;case I:case y:s.affectScaleOrRotation?e.moveInner(0,-n/2):e.y-=n/2;break;case b:case k:s.affectScaleOrRotation?e.moveInner(0,-n):e.y-=n}}e.fontSize*=a;const c=e.__;c.__autoWidth||(e.width*=a),c.__autoHeight||(e.height*=a)}function L(e,t,i){d.scale(e.__.path,t,i),e.path=e.__.path}function m(e,t,i){const{points:s}=e;"object"==typeof s[0]?s.forEach((e=>{e.x*=t,e.y*=i})):d.scalePoints(s,t,i),e.points=s}function w(e,t,i){const{children:s}=e;for(let e=0;e<s.length;e++)g.a=t,g.d=i,s[e].transform(g,!0)}const C=t.Leaf.prototype;return C.scaleResize=function(e,t=e,i){const s=this;i||s.editConfig&&"scale"===s.editConfig.editSize?(s.scaleX*=e,s.scaleY*=t):(e<0&&(s.scaleX*=-1,e=-e),t<0&&(s.scaleY*=-1,t=-t),this.__scaleResize(e,t))},C.__scaleResize=function(e,t){P(this,e,t)},C.resizeWidth=function(e){const t=e/this.getBounds("box","local").width;this.scaleOf(this.__layout.boxBounds,t,this.__.lockRatio?t:1,!0)},C.resizeHeight=function(e){const t=e/this.getBounds("box","local").height;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?t:1,t,!0)},t.Text.prototype.__scaleResize=function(e,t){this.__.resizeFontSize||this.editConfig&&"font-size"===this.editConfig.editSize?S(this,e,t):P(this,e,t)},t.Path.prototype.__scaleResize=function(e,t){L(this,e,t)},t.Line.prototype.__scaleResize=function(e,t){this.pathInputed?L(this,e,t):this.points?m(this,e,t):this.width*=e},t.Polygon.prototype.__scaleResize=function(e,t){this.pathInputed?L(this,e,t):this.points?m(this,e,t):P(this,e,t)},t.Group.prototype.__scaleResize=function(e,t){w(this,e,t)},t.Box.prototype.__scaleResize=function(e,t){this.__.__autoSize&&this.children.length?w(this,e,t):(P(this,e,t),this.__.resizeChildren&&w(this,e,t))},e.PathScaler=d,e.scaleResize=P,e.scaleResizeFontSize=S,e.scaleResizeGroup=w,e.scaleResizePath=L,e.scaleResizePoints=m,e}({},LeaferUI);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-in/resize",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "@leafer-in/resize",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -21,10 +21,10 @@
21
21
  ],
22
22
  "repository": {
23
23
  "type": "git",
24
- "url": "https://github.com/leaferjs/in.git"
24
+ "url": "https://github.com/leaferjs/leafer-in.git"
25
25
  },
26
- "homepage": "https://github.com/leaferjs/in/tree/main/packages/resize",
27
- "bugs": "https://github.com/leaferjs/in/issues",
26
+ "homepage": "https://github.com/leaferjs/leafer-in/tree/main/packages/resize",
27
+ "bugs": "https://github.com/leaferjs/leafer-in/issues",
28
28
  "keywords": [
29
29
  "leafer resize",
30
30
  "leafer-resize",
@@ -34,7 +34,7 @@
34
34
  "leaferjs"
35
35
  ],
36
36
  "dependencies": {
37
- "@leafer-ui/draw": "^1.0.4",
38
- "@leafer-ui/interface": "^1.0.4"
37
+ "@leafer-ui/draw": "^1.0.6",
38
+ "@leafer-ui/interface": "^1.0.6"
39
39
  }
40
40
  }
package/src/scaler.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { IBranch, ILeaf, ILine, IPolygon, IText } from '@leafer-ui/interface'
1
+ import { IBranch, ILeaf, ILine, IPolygon, IText, IPointData } from '@leafer-ui/interface'
2
2
  import { Direction9, MatrixHelper } from '@leafer-ui/draw'
3
3
 
4
4
  import { PathScaler } from './PathScaler'
@@ -63,8 +63,9 @@ export function scaleResizePath(leaf: ILeaf, scaleX: number, scaleY: number): vo
63
63
  }
64
64
 
65
65
  export function scaleResizePoints(leaf: ILine | IPolygon, scaleX: number, scaleY: number): void {
66
- PathScaler.scalePoints(leaf.__.points, scaleX, scaleY)
67
- leaf.points = leaf.__.points
66
+ const { points } = leaf
67
+ typeof points[0] === 'object' ? (points as IPointData[]).forEach(p => { p.x *= scaleX, p.y *= scaleY }) : PathScaler.scalePoints(points as number[], scaleX, scaleY)
68
+ leaf.points = points
68
69
  }
69
70
 
70
71