@leafer/core 1.6.6 → 1.7.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/lib/core.cjs +37 -22
- package/lib/core.esm.js +37 -22
- package/lib/core.esm.min.js +1 -1
- package/lib/core.esm.min.js.map +1 -1
- package/lib/core.min.cjs +1 -1
- package/lib/core.min.cjs.map +1 -1
- package/package.json +17 -17
- package/src/index.ts +1 -1
- package/types/index.d.ts +1 -1
package/lib/core.cjs
CHANGED
|
@@ -45,7 +45,7 @@ const IncrementId = {
|
|
|
45
45
|
};
|
|
46
46
|
const I$1 = IncrementId;
|
|
47
47
|
|
|
48
|
-
const { round: round$3, pow: pow$1, PI: PI$
|
|
48
|
+
const { round: round$3, pow: pow$1, PI: PI$1 } = Math;
|
|
49
49
|
const MathHelper = {
|
|
50
50
|
within(value, min, max) {
|
|
51
51
|
if (typeof min === 'object')
|
|
@@ -141,9 +141,9 @@ const MathHelper = {
|
|
|
141
141
|
function randInt(num) {
|
|
142
142
|
return Math.round(Math.random() * num);
|
|
143
143
|
}
|
|
144
|
-
const OneRadian = PI$
|
|
145
|
-
const PI2 = PI$
|
|
146
|
-
const PI_2 = PI$
|
|
144
|
+
const OneRadian = PI$1 / 180;
|
|
145
|
+
const PI2 = PI$1 * 2;
|
|
146
|
+
const PI_2 = PI$1 / 2;
|
|
147
147
|
function getPointData() { return { x: 0, y: 0 }; }
|
|
148
148
|
function getBoundsData() { return { x: 0, y: 0, width: 0, height: 0 }; }
|
|
149
149
|
function getMatrixData() { return { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }; }
|
|
@@ -438,7 +438,7 @@ const MatrixHelper = {
|
|
|
438
438
|
const M$6 = MatrixHelper;
|
|
439
439
|
|
|
440
440
|
const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3 } = MatrixHelper;
|
|
441
|
-
const { sin: sin$2, cos: cos$2, abs: abs$2, sqrt: sqrt$2, atan2: atan2$2, min: min$1, round: round$2
|
|
441
|
+
const { sin: sin$2, cos: cos$2, abs: abs$2, sqrt: sqrt$2, atan2: atan2$2, min: min$1, round: round$2 } = Math;
|
|
442
442
|
const PointHelper = {
|
|
443
443
|
defaultPoint: getPointData(),
|
|
444
444
|
tempPoint: {},
|
|
@@ -551,10 +551,11 @@ const PointHelper = {
|
|
|
551
551
|
getRadianFrom(fromX, fromY, originX, originY, toX, toY, toOriginX, toOriginY) {
|
|
552
552
|
if (toOriginX === undefined)
|
|
553
553
|
toOriginX = originX, toOriginY = originY;
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
const
|
|
557
|
-
|
|
554
|
+
const a = fromX - originX;
|
|
555
|
+
const b = fromY - originY;
|
|
556
|
+
const c = toX - toOriginX;
|
|
557
|
+
const d = toY - toOriginY;
|
|
558
|
+
return Math.atan2(a * d - b * c, a * c + b * d);
|
|
558
559
|
},
|
|
559
560
|
getAtan2(t, to) {
|
|
560
561
|
return atan2$2(to.y - t.y, to.x - t.x);
|
|
@@ -3341,7 +3342,7 @@ const { getCenterX, getCenterY } = PointHelper;
|
|
|
3341
3342
|
const { arcTo } = PathCommandDataHelper;
|
|
3342
3343
|
const PathCorner = {
|
|
3343
3344
|
smooth(data, cornerRadius, _cornerSmoothing) {
|
|
3344
|
-
let command, commandLen;
|
|
3345
|
+
let command, lastCommand, commandLen;
|
|
3345
3346
|
let i = 0, x = 0, y = 0, startX = 0, startY = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0;
|
|
3346
3347
|
const len = data.length;
|
|
3347
3348
|
const smooth = [];
|
|
@@ -3379,8 +3380,10 @@ const PathCorner = {
|
|
|
3379
3380
|
lastY = y;
|
|
3380
3381
|
break;
|
|
3381
3382
|
case Z:
|
|
3382
|
-
|
|
3383
|
-
|
|
3383
|
+
if (lastCommand !== Z) {
|
|
3384
|
+
arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY);
|
|
3385
|
+
smooth.push(Z);
|
|
3386
|
+
}
|
|
3384
3387
|
i += 1;
|
|
3385
3388
|
break;
|
|
3386
3389
|
default:
|
|
@@ -3389,6 +3392,7 @@ const PathCorner = {
|
|
|
3389
3392
|
smooth.push(data[i + j]);
|
|
3390
3393
|
i += commandLen;
|
|
3391
3394
|
}
|
|
3395
|
+
lastCommand = command;
|
|
3392
3396
|
}
|
|
3393
3397
|
if (command !== Z) {
|
|
3394
3398
|
smooth[1] = startX;
|
|
@@ -3885,12 +3889,12 @@ class LeaferImage {
|
|
|
3885
3889
|
try {
|
|
3886
3890
|
if (transform && pattern.setTransform) {
|
|
3887
3891
|
pattern.setTransform(transform);
|
|
3888
|
-
transform =
|
|
3892
|
+
transform = undefined;
|
|
3889
3893
|
}
|
|
3890
3894
|
}
|
|
3891
3895
|
catch (_a) { }
|
|
3892
3896
|
if (paint)
|
|
3893
|
-
paint
|
|
3897
|
+
DataHelper.stintSet(paint, 'transform', transform);
|
|
3894
3898
|
return pattern;
|
|
3895
3899
|
}
|
|
3896
3900
|
destroy() {
|
|
@@ -3995,10 +3999,14 @@ function pathInputType(defaultValue) {
|
|
|
3995
3999
|
}));
|
|
3996
4000
|
}
|
|
3997
4001
|
const pathType = boundsType;
|
|
3998
|
-
function affectStrokeBoundsType(defaultValue) {
|
|
4002
|
+
function affectStrokeBoundsType(defaultValue, useStroke) {
|
|
3999
4003
|
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
4000
4004
|
set(value) {
|
|
4001
|
-
this.__setAttr(key, value)
|
|
4005
|
+
if (this.__setAttr(key, value)) {
|
|
4006
|
+
doStrokeType(this);
|
|
4007
|
+
if (useStroke)
|
|
4008
|
+
this.__.__useStroke = true;
|
|
4009
|
+
}
|
|
4002
4010
|
}
|
|
4003
4011
|
}));
|
|
4004
4012
|
}
|
|
@@ -5424,6 +5432,8 @@ const LeafBounds = {
|
|
|
5424
5432
|
|
|
5425
5433
|
const LeafRender = {
|
|
5426
5434
|
__render(canvas, options) {
|
|
5435
|
+
if (options.shape)
|
|
5436
|
+
return this.__renderShape(canvas, options);
|
|
5427
5437
|
if (this.__worldOpacity) {
|
|
5428
5438
|
const data = this.__;
|
|
5429
5439
|
canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
|
|
@@ -5433,12 +5443,10 @@ const LeafRender = {
|
|
|
5433
5443
|
return this.__renderEraser(canvas, options);
|
|
5434
5444
|
const tempCanvas = canvas.getSameCanvas(true, true);
|
|
5435
5445
|
this.__draw(tempCanvas, options, canvas);
|
|
5436
|
-
if (this.__worldFlipped)
|
|
5446
|
+
if (this.__worldFlipped)
|
|
5437
5447
|
canvas.copyWorldByReset(tempCanvas, this.__nowWorld, null, data.__blendMode, true);
|
|
5438
|
-
|
|
5439
|
-
else {
|
|
5448
|
+
else
|
|
5440
5449
|
canvas.copyWorldToInner(tempCanvas, this.__nowWorld, this.__layout.renderBounds, data.__blendMode);
|
|
5441
|
-
}
|
|
5442
5450
|
tempCanvas.recycle(this.__nowWorld);
|
|
5443
5451
|
}
|
|
5444
5452
|
else {
|
|
@@ -5448,6 +5456,12 @@ const LeafRender = {
|
|
|
5448
5456
|
Debug.drawBounds(this, canvas, options);
|
|
5449
5457
|
}
|
|
5450
5458
|
},
|
|
5459
|
+
__renderShape(canvas, options) {
|
|
5460
|
+
if (this.__worldOpacity) {
|
|
5461
|
+
canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
|
|
5462
|
+
this.__drawShape(canvas, options);
|
|
5463
|
+
}
|
|
5464
|
+
},
|
|
5451
5465
|
__clip(canvas, options) {
|
|
5452
5466
|
if (this.__worldOpacity) {
|
|
5453
5467
|
canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
|
|
@@ -5867,7 +5881,8 @@ exports.Leaf = class Leaf {
|
|
|
5867
5881
|
__drawFast(_canvas, _options) { }
|
|
5868
5882
|
__draw(_canvas, _options, _originCanvas) { }
|
|
5869
5883
|
__clip(_canvas, _options) { }
|
|
5870
|
-
__renderShape(_canvas, _options
|
|
5884
|
+
__renderShape(_canvas, _options) { }
|
|
5885
|
+
__drawShape(_canvas, _options) { }
|
|
5871
5886
|
__updateWorldOpacity() { }
|
|
5872
5887
|
__updateChange() { }
|
|
5873
5888
|
__drawPath(_canvas) { }
|
|
@@ -6235,7 +6250,7 @@ class LeafLevelList {
|
|
|
6235
6250
|
}
|
|
6236
6251
|
}
|
|
6237
6252
|
|
|
6238
|
-
const version = "1.
|
|
6253
|
+
const version = "1.7.0";
|
|
6239
6254
|
|
|
6240
6255
|
exports.AlignHelper = AlignHelper;
|
|
6241
6256
|
exports.AroundHelper = AroundHelper;
|
package/lib/core.esm.js
CHANGED
|
@@ -43,7 +43,7 @@ const IncrementId = {
|
|
|
43
43
|
};
|
|
44
44
|
const I$1 = IncrementId;
|
|
45
45
|
|
|
46
|
-
const { round: round$3, pow: pow$1, PI: PI$
|
|
46
|
+
const { round: round$3, pow: pow$1, PI: PI$1 } = Math;
|
|
47
47
|
const MathHelper = {
|
|
48
48
|
within(value, min, max) {
|
|
49
49
|
if (typeof min === 'object')
|
|
@@ -139,9 +139,9 @@ const MathHelper = {
|
|
|
139
139
|
function randInt(num) {
|
|
140
140
|
return Math.round(Math.random() * num);
|
|
141
141
|
}
|
|
142
|
-
const OneRadian = PI$
|
|
143
|
-
const PI2 = PI$
|
|
144
|
-
const PI_2 = PI$
|
|
142
|
+
const OneRadian = PI$1 / 180;
|
|
143
|
+
const PI2 = PI$1 * 2;
|
|
144
|
+
const PI_2 = PI$1 / 2;
|
|
145
145
|
function getPointData() { return { x: 0, y: 0 }; }
|
|
146
146
|
function getBoundsData() { return { x: 0, y: 0, width: 0, height: 0 }; }
|
|
147
147
|
function getMatrixData() { return { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }; }
|
|
@@ -436,7 +436,7 @@ const MatrixHelper = {
|
|
|
436
436
|
const M$6 = MatrixHelper;
|
|
437
437
|
|
|
438
438
|
const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3 } = MatrixHelper;
|
|
439
|
-
const { sin: sin$2, cos: cos$2, abs: abs$2, sqrt: sqrt$2, atan2: atan2$2, min: min$1, round: round$2
|
|
439
|
+
const { sin: sin$2, cos: cos$2, abs: abs$2, sqrt: sqrt$2, atan2: atan2$2, min: min$1, round: round$2 } = Math;
|
|
440
440
|
const PointHelper = {
|
|
441
441
|
defaultPoint: getPointData(),
|
|
442
442
|
tempPoint: {},
|
|
@@ -549,10 +549,11 @@ const PointHelper = {
|
|
|
549
549
|
getRadianFrom(fromX, fromY, originX, originY, toX, toY, toOriginX, toOriginY) {
|
|
550
550
|
if (toOriginX === undefined)
|
|
551
551
|
toOriginX = originX, toOriginY = originY;
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
const
|
|
555
|
-
|
|
552
|
+
const a = fromX - originX;
|
|
553
|
+
const b = fromY - originY;
|
|
554
|
+
const c = toX - toOriginX;
|
|
555
|
+
const d = toY - toOriginY;
|
|
556
|
+
return Math.atan2(a * d - b * c, a * c + b * d);
|
|
556
557
|
},
|
|
557
558
|
getAtan2(t, to) {
|
|
558
559
|
return atan2$2(to.y - t.y, to.x - t.x);
|
|
@@ -3339,7 +3340,7 @@ const { getCenterX, getCenterY } = PointHelper;
|
|
|
3339
3340
|
const { arcTo } = PathCommandDataHelper;
|
|
3340
3341
|
const PathCorner = {
|
|
3341
3342
|
smooth(data, cornerRadius, _cornerSmoothing) {
|
|
3342
|
-
let command, commandLen;
|
|
3343
|
+
let command, lastCommand, commandLen;
|
|
3343
3344
|
let i = 0, x = 0, y = 0, startX = 0, startY = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0;
|
|
3344
3345
|
const len = data.length;
|
|
3345
3346
|
const smooth = [];
|
|
@@ -3377,8 +3378,10 @@ const PathCorner = {
|
|
|
3377
3378
|
lastY = y;
|
|
3378
3379
|
break;
|
|
3379
3380
|
case Z:
|
|
3380
|
-
|
|
3381
|
-
|
|
3381
|
+
if (lastCommand !== Z) {
|
|
3382
|
+
arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY);
|
|
3383
|
+
smooth.push(Z);
|
|
3384
|
+
}
|
|
3382
3385
|
i += 1;
|
|
3383
3386
|
break;
|
|
3384
3387
|
default:
|
|
@@ -3387,6 +3390,7 @@ const PathCorner = {
|
|
|
3387
3390
|
smooth.push(data[i + j]);
|
|
3388
3391
|
i += commandLen;
|
|
3389
3392
|
}
|
|
3393
|
+
lastCommand = command;
|
|
3390
3394
|
}
|
|
3391
3395
|
if (command !== Z) {
|
|
3392
3396
|
smooth[1] = startX;
|
|
@@ -3883,12 +3887,12 @@ class LeaferImage {
|
|
|
3883
3887
|
try {
|
|
3884
3888
|
if (transform && pattern.setTransform) {
|
|
3885
3889
|
pattern.setTransform(transform);
|
|
3886
|
-
transform =
|
|
3890
|
+
transform = undefined;
|
|
3887
3891
|
}
|
|
3888
3892
|
}
|
|
3889
3893
|
catch (_a) { }
|
|
3890
3894
|
if (paint)
|
|
3891
|
-
paint
|
|
3895
|
+
DataHelper.stintSet(paint, 'transform', transform);
|
|
3892
3896
|
return pattern;
|
|
3893
3897
|
}
|
|
3894
3898
|
destroy() {
|
|
@@ -3993,10 +3997,14 @@ function pathInputType(defaultValue) {
|
|
|
3993
3997
|
}));
|
|
3994
3998
|
}
|
|
3995
3999
|
const pathType = boundsType;
|
|
3996
|
-
function affectStrokeBoundsType(defaultValue) {
|
|
4000
|
+
function affectStrokeBoundsType(defaultValue, useStroke) {
|
|
3997
4001
|
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
3998
4002
|
set(value) {
|
|
3999
|
-
this.__setAttr(key, value)
|
|
4003
|
+
if (this.__setAttr(key, value)) {
|
|
4004
|
+
doStrokeType(this);
|
|
4005
|
+
if (useStroke)
|
|
4006
|
+
this.__.__useStroke = true;
|
|
4007
|
+
}
|
|
4000
4008
|
}
|
|
4001
4009
|
}));
|
|
4002
4010
|
}
|
|
@@ -5422,6 +5430,8 @@ const LeafBounds = {
|
|
|
5422
5430
|
|
|
5423
5431
|
const LeafRender = {
|
|
5424
5432
|
__render(canvas, options) {
|
|
5433
|
+
if (options.shape)
|
|
5434
|
+
return this.__renderShape(canvas, options);
|
|
5425
5435
|
if (this.__worldOpacity) {
|
|
5426
5436
|
const data = this.__;
|
|
5427
5437
|
canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
|
|
@@ -5431,12 +5441,10 @@ const LeafRender = {
|
|
|
5431
5441
|
return this.__renderEraser(canvas, options);
|
|
5432
5442
|
const tempCanvas = canvas.getSameCanvas(true, true);
|
|
5433
5443
|
this.__draw(tempCanvas, options, canvas);
|
|
5434
|
-
if (this.__worldFlipped)
|
|
5444
|
+
if (this.__worldFlipped)
|
|
5435
5445
|
canvas.copyWorldByReset(tempCanvas, this.__nowWorld, null, data.__blendMode, true);
|
|
5436
|
-
|
|
5437
|
-
else {
|
|
5446
|
+
else
|
|
5438
5447
|
canvas.copyWorldToInner(tempCanvas, this.__nowWorld, this.__layout.renderBounds, data.__blendMode);
|
|
5439
|
-
}
|
|
5440
5448
|
tempCanvas.recycle(this.__nowWorld);
|
|
5441
5449
|
}
|
|
5442
5450
|
else {
|
|
@@ -5446,6 +5454,12 @@ const LeafRender = {
|
|
|
5446
5454
|
Debug.drawBounds(this, canvas, options);
|
|
5447
5455
|
}
|
|
5448
5456
|
},
|
|
5457
|
+
__renderShape(canvas, options) {
|
|
5458
|
+
if (this.__worldOpacity) {
|
|
5459
|
+
canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
|
|
5460
|
+
this.__drawShape(canvas, options);
|
|
5461
|
+
}
|
|
5462
|
+
},
|
|
5449
5463
|
__clip(canvas, options) {
|
|
5450
5464
|
if (this.__worldOpacity) {
|
|
5451
5465
|
canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
|
|
@@ -5865,7 +5879,8 @@ let Leaf = class Leaf {
|
|
|
5865
5879
|
__drawFast(_canvas, _options) { }
|
|
5866
5880
|
__draw(_canvas, _options, _originCanvas) { }
|
|
5867
5881
|
__clip(_canvas, _options) { }
|
|
5868
|
-
__renderShape(_canvas, _options
|
|
5882
|
+
__renderShape(_canvas, _options) { }
|
|
5883
|
+
__drawShape(_canvas, _options) { }
|
|
5869
5884
|
__updateWorldOpacity() { }
|
|
5870
5885
|
__updateChange() { }
|
|
5871
5886
|
__drawPath(_canvas) { }
|
|
@@ -6233,6 +6248,6 @@ class LeafLevelList {
|
|
|
6233
6248
|
}
|
|
6234
6249
|
}
|
|
6235
6250
|
|
|
6236
|
-
const version = "1.
|
|
6251
|
+
const version = "1.7.0";
|
|
6237
6252
|
|
|
6238
6253
|
export { AlignHelper, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Branch, BranchHelper, BranchRender, CanvasManager, ChildEvent, Creator, DataHelper, Debug, Direction4, Direction9, EllipseHelper, Event, EventCreator, Eventer, FileHelper, ImageEvent, ImageManager, IncrementId, LayoutEvent, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, LeaferCanvasBase, LeaferEvent, LeaferImage, MathHelper, Matrix, MatrixHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Platform, Plugin, Point, PointHelper, PropertyEvent, RectHelper, RenderEvent, ResizeEvent, Resource, Run, StringNumberMap, TaskItem, TaskProcessor, TwoPointBoundsHelper, UICreator, WaitHelper, WatchEvent, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isEmptyData, isNull, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, tempBounds, tempMatrix, tempPoint$2 as tempPoint, useModule, version, visibleType };
|