@leafer-in/resize 1.0.0-rc.28 → 1.0.0
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 +11 -2
- package/dist/resize.esm.js +11 -2
- package/dist/resize.esm.min.js +1 -1
- package/dist/resize.js +11 -2
- package/dist/resize.min.cjs +1 -1
- package/dist/resize.min.js +1 -1
- package/package.json +3 -3
- package/src/index.ts +1 -72
- package/src/resize.ts +93 -0
package/dist/resize.cjs
CHANGED
|
@@ -121,7 +121,8 @@ function scaleResizeGroup(group, scaleX, scaleY) {
|
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
draw.Leaf.prototype
|
|
124
|
+
const leaf = draw.Leaf.prototype;
|
|
125
|
+
leaf.scaleResize = function (scaleX, scaleY = scaleX, noResize) {
|
|
125
126
|
const data = this;
|
|
126
127
|
if (noResize || (data.editConfig && data.editConfig.editSize === 'scale')) {
|
|
127
128
|
data.scaleX *= scaleX;
|
|
@@ -135,9 +136,17 @@ draw.Leaf.prototype.scaleResize = function (scaleX, scaleY = scaleX, noResize) {
|
|
|
135
136
|
this.__scaleResize(scaleX, scaleY);
|
|
136
137
|
}
|
|
137
138
|
};
|
|
138
|
-
|
|
139
|
+
leaf.__scaleResize = function (scaleX, scaleY) {
|
|
139
140
|
scaleResize(this, scaleX, scaleY);
|
|
140
141
|
};
|
|
142
|
+
leaf.resizeWidth = function (width) {
|
|
143
|
+
const scale = width / this.getBounds('box', 'local').width;
|
|
144
|
+
this.scaleOf(this.__layout.boxBounds, scale, this.__.lockRatio ? scale : 1, true);
|
|
145
|
+
};
|
|
146
|
+
leaf.resizeHeight = function (height) {
|
|
147
|
+
const scale = height / this.getBounds('box', 'local').height;
|
|
148
|
+
this.scaleOf(this.__layout.boxBounds, this.__.lockRatio ? scale : 1, scale, true);
|
|
149
|
+
};
|
|
141
150
|
draw.Text.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
142
151
|
if (this.__.__autoSize && (this.__.resizeFontSize || (this.editConfig && this.editConfig.editSize === 'font-size'))) {
|
|
143
152
|
scaleResizeFontSize(this, scaleX, scaleY);
|
package/dist/resize.esm.js
CHANGED
|
@@ -119,7 +119,8 @@ function scaleResizeGroup(group, scaleX, scaleY) {
|
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
|
|
122
|
+
const leaf = Leaf.prototype;
|
|
123
|
+
leaf.scaleResize = function (scaleX, scaleY = scaleX, noResize) {
|
|
123
124
|
const data = this;
|
|
124
125
|
if (noResize || (data.editConfig && data.editConfig.editSize === 'scale')) {
|
|
125
126
|
data.scaleX *= scaleX;
|
|
@@ -133,9 +134,17 @@ Leaf.prototype.scaleResize = function (scaleX, scaleY = scaleX, noResize) {
|
|
|
133
134
|
this.__scaleResize(scaleX, scaleY);
|
|
134
135
|
}
|
|
135
136
|
};
|
|
136
|
-
|
|
137
|
+
leaf.__scaleResize = function (scaleX, scaleY) {
|
|
137
138
|
scaleResize(this, scaleX, scaleY);
|
|
138
139
|
};
|
|
140
|
+
leaf.resizeWidth = function (width) {
|
|
141
|
+
const scale = width / this.getBounds('box', 'local').width;
|
|
142
|
+
this.scaleOf(this.__layout.boxBounds, scale, this.__.lockRatio ? scale : 1, true);
|
|
143
|
+
};
|
|
144
|
+
leaf.resizeHeight = function (height) {
|
|
145
|
+
const scale = height / this.getBounds('box', 'local').height;
|
|
146
|
+
this.scaleOf(this.__layout.boxBounds, this.__.lockRatio ? scale : 1, scale, true);
|
|
147
|
+
};
|
|
139
148
|
Text.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
140
149
|
if (this.__.__autoSize && (this.__.resizeFontSize || (this.editConfig && this.editConfig.editSize === 'font-size'))) {
|
|
141
150
|
scaleResizeFontSize(this, scaleX, scaleY);
|
package/dist/resize.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PathCommandMap as
|
|
1
|
+
import{PathCommandMap as t,MatrixHelper as e,Leaf as i,Text as s,Path as o,Line as n,Polygon as c,Group as a,Box as h}from"@leafer-ui/draw";const{M:_,L:l,C:r,Q:p,Z:f,N:u,D:d,X:z,G:b,F:g,O:k,P:R,U:y}=t,x={scale(t,e,i){if(!t)return;let s,o=0,n=t.length;for(;o<n;)switch(s=t[o],s){case _:case l:S(t,e,i,o,1),o+=3;break;case r:S(t,e,i,o,3),o+=7;break;case p:S(t,e,i,o,2),o+=5;break;case f:o+=1;break;case u:S(t,e,i,o,2),o+=5;break;case d:S(t,e,i,o,2),o+=9;break;case z:S(t,e,i,o,2),o+=6;break;case b:S(t,e,i,o,2),o+=9;break;case g:S(t,e,i,o,2),o+=5;break;case k:t[o]=b,t.splice(o+4,0,t[o+3],0),S(t,e,i,o,2),o+=9,n+=2;break;case R:t[o]=g,t.splice(o+4,0,t[o+3]),S(t,e,i,o,2),o+=5,n+=1;break;case y:S(t,e,i,o,2),o+=6}},scalePoints(t,e,i,s,o){for(let n=o?s+1:0,c=o?n+2*o:t.length;n<c;n+=2)t[n]*=e,t[n+1]*=i}},{scalePoints:S}=x,w=e.get();function B(t,e,i){t.pathInputed?P(t,e,i):(1!==e&&(t.width*=e),1!==i&&(t.height*=i))}function C(t,e,i){const{width:s,height:o}=t.__localBoxBounds;1!==e?(t.fontSize*=e,t.y-=o*(e-i)/2):1!==i&&(t.fontSize*=i,t.x-=s*(i-e)/2)}function P(t,e,i){x.scale(t.__.path,e,i),t.path=t.__.path}function m(t,e,i){x.scalePoints(t.__.points,e,i),t.points=t.__.points}function I(t,e,i){const{children:s}=t;for(let t=0;t<s.length;t++)w.a=e,w.d=i,s[t].transform(w,!0)}const O=i.prototype;O.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))},O.__scaleResize=function(t,e){B(this,t,e)},O.resizeWidth=function(t){const e=t/this.getBounds("box","local").width;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},O.resizeHeight=function(t){const e=t/this.getBounds("box","local").height;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?e:1,e,!0)},s.prototype.__scaleResize=function(t,e){this.__.__autoSize&&(this.__.resizeFontSize||this.editConfig&&"font-size"===this.editConfig.editSize)?C(this,t,e):B(this,t,e)},o.prototype.__scaleResize=function(t,e){P(this,t,e)},n.prototype.__scaleResize=function(t,e){this.pathInputed?P(this,t,e):this.points?m(this,t,e):this.width*=t},c.prototype.__scaleResize=function(t,e){this.pathInputed?P(this,t,e):this.points?m(this,t,e):B(this,t,e)},a.prototype.__scaleResize=function(t,e){I(this,t,e)},h.prototype.__scaleResize=function(t,e){this.__.__autoSize&&this.children.length?I(this,t,e):(B(this,t,e),this.__.resizeChildren&&I(this,t,e))};export{x as PathScaler,B as scaleResize,C as scaleResizeFontSize,I as scaleResizeGroup,P as scaleResizePath,m as scaleResizePoints};
|
package/dist/resize.js
CHANGED
|
@@ -121,7 +121,8 @@ this.LeaferIN.resize = (function (exports, draw) {
|
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
draw.Leaf.prototype
|
|
124
|
+
const leaf = draw.Leaf.prototype;
|
|
125
|
+
leaf.scaleResize = function (scaleX, scaleY = scaleX, noResize) {
|
|
125
126
|
const data = this;
|
|
126
127
|
if (noResize || (data.editConfig && data.editConfig.editSize === 'scale')) {
|
|
127
128
|
data.scaleX *= scaleX;
|
|
@@ -135,9 +136,17 @@ this.LeaferIN.resize = (function (exports, draw) {
|
|
|
135
136
|
this.__scaleResize(scaleX, scaleY);
|
|
136
137
|
}
|
|
137
138
|
};
|
|
138
|
-
|
|
139
|
+
leaf.__scaleResize = function (scaleX, scaleY) {
|
|
139
140
|
scaleResize(this, scaleX, scaleY);
|
|
140
141
|
};
|
|
142
|
+
leaf.resizeWidth = function (width) {
|
|
143
|
+
const scale = width / this.getBounds('box', 'local').width;
|
|
144
|
+
this.scaleOf(this.__layout.boxBounds, scale, this.__.lockRatio ? scale : 1, true);
|
|
145
|
+
};
|
|
146
|
+
leaf.resizeHeight = function (height) {
|
|
147
|
+
const scale = height / this.getBounds('box', 'local').height;
|
|
148
|
+
this.scaleOf(this.__layout.boxBounds, this.__.lockRatio ? scale : 1, scale, true);
|
|
149
|
+
};
|
|
141
150
|
draw.Text.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
142
151
|
if (this.__.__autoSize && (this.__.resizeFontSize || (this.editConfig && this.editConfig.editSize === 'font-size'))) {
|
|
143
152
|
scaleResizeFontSize(this, scaleX, scaleY);
|
package/dist/resize.min.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("@leafer-ui/draw");const{M:t,L:s,C:i,Q:
|
|
1
|
+
"use strict";var e=require("@leafer-ui/draw");const{M:t,L:s,C:i,Q:o,Z:a,N:n,D:c,X:h,G:l,F:r,O:_,P:p,U:u}=e.PathCommandMap,f={scale(e,f,d){if(!e)return;let g,R=0,b=e.length;for(;R<b;)switch(g=e[R],g){case t:case s:z(e,f,d,R,1),R+=3;break;case i:z(e,f,d,R,3),R+=7;break;case o:z(e,f,d,R,2),R+=5;break;case a:R+=1;break;case n:z(e,f,d,R,2),R+=5;break;case c:z(e,f,d,R,2),R+=9;break;case h:z(e,f,d,R,2),R+=6;break;case l:z(e,f,d,R,2),R+=9;break;case r:z(e,f,d,R,2),R+=5;break;case _:e[R]=l,e.splice(R+4,0,e[R+3],0),z(e,f,d,R,2),R+=9,b+=2;break;case p:e[R]=r,e.splice(R+4,0,e[R+3]),z(e,f,d,R,2),R+=5,b+=1;break;case u:z(e,f,d,R,2),R+=6}},scalePoints(e,t,s,i,o){for(let a=o?i+1:0,n=o?a+2*o:e.length;a<n;a+=2)e[a]*=t,e[a+1]*=s}},{scalePoints:z}=f,d=e.MatrixHelper.get();function g(e,t,s){e.pathInputed?b(e,t,s):(1!==t&&(e.width*=t),1!==s&&(e.height*=s))}function R(e,t,s){const{width:i,height:o}=e.__localBoxBounds;1!==t?(e.fontSize*=t,e.y-=o*(t-s)/2):1!==s&&(e.fontSize*=s,e.x-=i*(s-t)/2)}function b(e,t,s){f.scale(e.__.path,t,s),e.path=e.__.path}function x(e,t,s){f.scalePoints(e.__.points,t,s),e.points=e.__.points}function k(e,t,s){const{children:i}=e;for(let e=0;e<i.length;e++)d.a=t,d.d=s,i[e].transform(d,!0)}const y=e.Leaf.prototype;y.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))},y.__scaleResize=function(e,t){g(this,e,t)},y.resizeWidth=function(e){const t=e/this.getBounds("box","local").width;this.scaleOf(this.__layout.boxBounds,t,this.__.lockRatio?t:1,!0)},y.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.__.__autoSize&&(this.__.resizeFontSize||this.editConfig&&"font-size"===this.editConfig.editSize)?R(this,e,t):g(this,e,t)},e.Path.prototype.__scaleResize=function(e,t){b(this,e,t)},e.Line.prototype.__scaleResize=function(e,t){this.pathInputed?b(this,e,t):this.points?x(this,e,t):this.width*=e},e.Polygon.prototype.__scaleResize=function(e,t){this.pathInputed?b(this,e,t):this.points?x(this,e,t):g(this,e,t)},e.Group.prototype.__scaleResize=function(e,t){k(this,e,t)},e.Box.prototype.__scaleResize=function(e,t){this.__.__autoSize&&this.children.length?k(this,e,t):(g(this,e,t),this.__.resizeChildren&&k(this,e,t))},exports.PathScaler=f,exports.scaleResize=g,exports.scaleResizeFontSize=R,exports.scaleResizeGroup=k,exports.scaleResizePath=b,exports.scaleResizePoints=x;
|
package/dist/resize.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
this.LeaferIN=this.LeaferIN||{},this.LeaferIN.resize=function(e,t){"use strict";const{M:s,L:i,C:
|
|
1
|
+
this.LeaferIN=this.LeaferIN||{},this.LeaferIN.resize=function(e,t){"use strict";const{M:s,L:i,C:o,Q:a,Z:n,N:c,D:h,X:l,G:_,F:r,O:f,P:p,U:u}=t.PathCommandMap,z={scale(e,t,z){if(!e)return;let g,R=0,b=e.length;for(;R<b;)switch(g=e[R],g){case s:case i:d(e,t,z,R,1),R+=3;break;case o:d(e,t,z,R,3),R+=7;break;case a:d(e,t,z,R,2),R+=5;break;case n:R+=1;break;case c:d(e,t,z,R,2),R+=5;break;case h:d(e,t,z,R,2),R+=9;break;case l:d(e,t,z,R,2),R+=6;break;case _:d(e,t,z,R,2),R+=9;break;case r:d(e,t,z,R,2),R+=5;break;case f:e[R]=_,e.splice(R+4,0,e[R+3],0),d(e,t,z,R,2),R+=9,b+=2;break;case p:e[R]=r,e.splice(R+4,0,e[R+3]),d(e,t,z,R,2),R+=5,b+=1;break;case u:d(e,t,z,R,2),R+=6}},scalePoints(e,t,s,i,o){for(let a=o?i+1:0,n=o?a+2*o:e.length;a<n;a+=2)e[a]*=t,e[a+1]*=s}},{scalePoints:d}=z,g=t.MatrixHelper.get();function R(e,t,s){e.pathInputed?k(e,t,s):(1!==t&&(e.width*=t),1!==s&&(e.height*=s))}function b(e,t,s){const{width:i,height:o}=e.__localBoxBounds;1!==t?(e.fontSize*=t,e.y-=o*(t-s)/2):1!==s&&(e.fontSize*=s,e.x-=i*(s-t)/2)}function k(e,t,s){z.scale(e.__.path,t,s),e.path=e.__.path}function y(e,t,s){z.scalePoints(e.__.points,t,s),e.points=e.__.points}function P(e,t,s){const{children:i}=e;for(let e=0;e<i.length;e++)g.a=t,g.d=s,i[e].transform(g,!0)}const x=t.Leaf.prototype;return x.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))},x.__scaleResize=function(e,t){R(this,e,t)},x.resizeWidth=function(e){const t=e/this.getBounds("box","local").width;this.scaleOf(this.__layout.boxBounds,t,this.__.lockRatio?t:1,!0)},x.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.__.__autoSize&&(this.__.resizeFontSize||this.editConfig&&"font-size"===this.editConfig.editSize)?b(this,e,t):R(this,e,t)},t.Path.prototype.__scaleResize=function(e,t){k(this,e,t)},t.Line.prototype.__scaleResize=function(e,t){this.pathInputed?k(this,e,t):this.points?y(this,e,t):this.width*=e},t.Polygon.prototype.__scaleResize=function(e,t){this.pathInputed?k(this,e,t):this.points?y(this,e,t):R(this,e,t)},t.Group.prototype.__scaleResize=function(e,t){P(this,e,t)},t.Box.prototype.__scaleResize=function(e,t){this.__.__autoSize&&this.children.length?P(this,e,t):(R(this,e,t),this.__.resizeChildren&&P(this,e,t))},e.PathScaler=z,e.scaleResize=R,e.scaleResizeFontSize=b,e.scaleResizeGroup=P,e.scaleResizePath=k,e.scaleResizePoints=y,e}({},LeaferUI);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-in/resize",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "@leafer-in/resize",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"leaferjs"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@leafer-ui/draw": "1.0.0
|
|
38
|
-
"@leafer-ui/interface": "1.0.0
|
|
37
|
+
"@leafer-ui/draw": "1.0.0",
|
|
38
|
+
"@leafer-ui/interface": "1.0.0"
|
|
39
39
|
}
|
|
40
40
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,74 +1,3 @@
|
|
|
1
1
|
export { PathScaler } from './PathScaler'
|
|
2
2
|
export { scaleResize, scaleResizeGroup, scaleResizeFontSize, scaleResizePath, scaleResizePoints } from './scaler'
|
|
3
|
-
|
|
4
|
-
import { Leaf, Path, Line, Text, Polygon, Group, Box, UI } from '@leafer-ui/draw'
|
|
5
|
-
|
|
6
|
-
import { scaleResize, scaleResizeFontSize, scaleResizeGroup, scaleResizePath, scaleResizePoints } from './scaler'
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
// leaf
|
|
10
|
-
|
|
11
|
-
Leaf.prototype.scaleResize = function (scaleX: number, scaleY = scaleX, noResize?: boolean): void {
|
|
12
|
-
const data = this as UI
|
|
13
|
-
if (noResize || (data.editConfig && data.editConfig.editSize === 'scale')) {
|
|
14
|
-
data.scaleX *= scaleX
|
|
15
|
-
data.scaleY *= scaleY
|
|
16
|
-
} else {
|
|
17
|
-
if (scaleX < 0) data.scaleX *= -1, scaleX = -scaleX
|
|
18
|
-
if (scaleY < 0) data.scaleY *= -1, scaleY = -scaleY
|
|
19
|
-
this.__scaleResize(scaleX, scaleY)
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
Leaf.prototype.__scaleResize = function (scaleX: number, scaleY: number): void {
|
|
25
|
-
scaleResize(this, scaleX, scaleY)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
Text.prototype.__scaleResize = function (scaleX: number, scaleY: number): void {
|
|
29
|
-
if (this.__.__autoSize && (this.__.resizeFontSize || (this.editConfig && this.editConfig.editSize === 'font-size'))) {
|
|
30
|
-
scaleResizeFontSize(this, scaleX, scaleY)
|
|
31
|
-
} else {
|
|
32
|
-
scaleResize(this, scaleX, scaleY)
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
Path.prototype.__scaleResize = function (scaleX: number, scaleY: number): void {
|
|
37
|
-
scaleResizePath(this, scaleX, scaleY)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
Line.prototype.__scaleResize = function (scaleX: number, scaleY: number): void {
|
|
41
|
-
if (this.pathInputed) {
|
|
42
|
-
scaleResizePath(this, scaleX, scaleY)
|
|
43
|
-
} else if (this.points) {
|
|
44
|
-
scaleResizePoints(this, scaleX, scaleY)
|
|
45
|
-
} else {
|
|
46
|
-
this.width *= scaleX
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
Polygon.prototype.__scaleResize = function (scaleX: number, scaleY: number): void {
|
|
51
|
-
if (this.pathInputed) {
|
|
52
|
-
scaleResizePath(this, scaleX, scaleY)
|
|
53
|
-
} else if (this.points) {
|
|
54
|
-
scaleResizePoints(this, scaleX, scaleY)
|
|
55
|
-
} else {
|
|
56
|
-
scaleResize(this, scaleX, scaleY)
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
// group
|
|
62
|
-
|
|
63
|
-
Group.prototype.__scaleResize = function (scaleX: number, scaleY: number): void {
|
|
64
|
-
scaleResizeGroup(this, scaleX, scaleY)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
Box.prototype.__scaleResize = function (scaleX: number, scaleY: number): void {
|
|
68
|
-
if (this.__.__autoSize && this.children.length) {
|
|
69
|
-
scaleResizeGroup(this, scaleX, scaleY)
|
|
70
|
-
} else {
|
|
71
|
-
scaleResize(this, scaleX, scaleY)
|
|
72
|
-
if (this.__.resizeChildren) scaleResizeGroup(this, scaleX, scaleY)
|
|
73
|
-
}
|
|
74
|
-
}
|
|
3
|
+
export * from './resize'
|
package/src/resize.ts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
|
|
2
|
+
import { Leaf, Path, Line, Text, Polygon, Group, Box, UI } from '@leafer-ui/draw'
|
|
3
|
+
|
|
4
|
+
import { scaleResize, scaleResizeFontSize, scaleResizeGroup, scaleResizePath, scaleResizePoints } from './scaler'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
// leaf
|
|
8
|
+
|
|
9
|
+
const leaf = Leaf.prototype
|
|
10
|
+
|
|
11
|
+
leaf.scaleResize = function (scaleX: number, scaleY = scaleX, noResize?: boolean): void {
|
|
12
|
+
const data = this as UI
|
|
13
|
+
if (noResize || (data.editConfig && data.editConfig.editSize === 'scale')) {
|
|
14
|
+
data.scaleX *= scaleX
|
|
15
|
+
data.scaleY *= scaleY
|
|
16
|
+
} else {
|
|
17
|
+
if (scaleX < 0) data.scaleX *= -1, scaleX = -scaleX
|
|
18
|
+
if (scaleY < 0) data.scaleY *= -1, scaleY = -scaleY
|
|
19
|
+
this.__scaleResize(scaleX, scaleY)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
leaf.__scaleResize = function (scaleX: number, scaleY: number): void {
|
|
25
|
+
scaleResize(this, scaleX, scaleY)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
leaf.resizeWidth = function (width: number): void {
|
|
30
|
+
const scale = width / this.getBounds('box', 'local').width
|
|
31
|
+
this.scaleOf(this.__layout.boxBounds, scale, this.__.lockRatio ? scale : 1, true)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
leaf.resizeHeight = function (height: number): void {
|
|
36
|
+
const scale = height / this.getBounds('box', 'local').height
|
|
37
|
+
this.scaleOf(this.__layout.boxBounds, this.__.lockRatio ? scale : 1, scale, true)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
// UI
|
|
42
|
+
|
|
43
|
+
Text.prototype.__scaleResize = function (scaleX: number, scaleY: number): void {
|
|
44
|
+
if (this.__.__autoSize && (this.__.resizeFontSize || (this.editConfig && this.editConfig.editSize === 'font-size'))) {
|
|
45
|
+
scaleResizeFontSize(this, scaleX, scaleY)
|
|
46
|
+
} else {
|
|
47
|
+
scaleResize(this, scaleX, scaleY)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
Path.prototype.__scaleResize = function (scaleX: number, scaleY: number): void {
|
|
53
|
+
scaleResizePath(this, scaleX, scaleY)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
Line.prototype.__scaleResize = function (scaleX: number, scaleY: number): void {
|
|
58
|
+
if (this.pathInputed) {
|
|
59
|
+
scaleResizePath(this, scaleX, scaleY)
|
|
60
|
+
} else if (this.points) {
|
|
61
|
+
scaleResizePoints(this, scaleX, scaleY)
|
|
62
|
+
} else {
|
|
63
|
+
this.width *= scaleX
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
Polygon.prototype.__scaleResize = function (scaleX: number, scaleY: number): void {
|
|
69
|
+
if (this.pathInputed) {
|
|
70
|
+
scaleResizePath(this, scaleX, scaleY)
|
|
71
|
+
} else if (this.points) {
|
|
72
|
+
scaleResizePoints(this, scaleX, scaleY)
|
|
73
|
+
} else {
|
|
74
|
+
scaleResize(this, scaleX, scaleY)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
// group
|
|
80
|
+
|
|
81
|
+
Group.prototype.__scaleResize = function (scaleX: number, scaleY: number): void {
|
|
82
|
+
scaleResizeGroup(this, scaleX, scaleY)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
Box.prototype.__scaleResize = function (scaleX: number, scaleY: number): void {
|
|
87
|
+
if (this.__.__autoSize && this.children.length) {
|
|
88
|
+
scaleResizeGroup(this, scaleX, scaleY)
|
|
89
|
+
} else {
|
|
90
|
+
scaleResize(this, scaleX, scaleY)
|
|
91
|
+
if (this.__.resizeChildren) scaleResizeGroup(this, scaleX, scaleY)
|
|
92
|
+
}
|
|
93
|
+
}
|