@leafer/core 1.12.2 → 1.12.4
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 +35 -12
- package/lib/core.esm.js +35 -12
- 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
|
@@ -239,11 +239,13 @@ const Platform = {
|
|
|
239
239
|
const ctx = canvas.getContext("2d");
|
|
240
240
|
if (opacity) ctx.globalAlpha = opacity;
|
|
241
241
|
ctx.imageSmoothingEnabled = smooth === false ? false : true;
|
|
242
|
-
if (
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
242
|
+
if (image) {
|
|
243
|
+
if (clip) {
|
|
244
|
+
const scaleX = width / clip.width, scaleY = height / clip.height;
|
|
245
|
+
ctx.setTransform(scaleX, 0, 0, scaleY, -clip.x * scaleX, -clip.y * scaleY);
|
|
246
|
+
ctx.drawImage(image, 0, 0, image.width, image.height);
|
|
247
|
+
} else ctx.drawImage(image, 0, 0, width, height);
|
|
248
|
+
}
|
|
247
249
|
return canvas;
|
|
248
250
|
},
|
|
249
251
|
setPatternTransform(pattern, transform, paint) {
|
|
@@ -4110,6 +4112,10 @@ class LeaferImage {
|
|
|
4110
4112
|
get url() {
|
|
4111
4113
|
return this.config.url;
|
|
4112
4114
|
}
|
|
4115
|
+
get crossOrigin() {
|
|
4116
|
+
const {crossOrigin: crossOrigin} = this.config;
|
|
4117
|
+
return isUndefined(crossOrigin) ? Platform.image.crossOrigin : crossOrigin;
|
|
4118
|
+
}
|
|
4113
4119
|
get completed() {
|
|
4114
4120
|
return this.ready || !!this.error;
|
|
4115
4121
|
}
|
|
@@ -4127,12 +4133,14 @@ class LeaferImage {
|
|
|
4127
4133
|
ImageManager.isFormat("svg", config) && (this.isSVG = true);
|
|
4128
4134
|
ImageManager.hasAlphaPixel(config) && (this.hasAlphaPixel = true);
|
|
4129
4135
|
}
|
|
4130
|
-
load(onSuccess, onError) {
|
|
4136
|
+
load(onSuccess, onError, thumbSize) {
|
|
4131
4137
|
if (!this.loading) {
|
|
4132
4138
|
this.loading = true;
|
|
4133
|
-
const {crossOrigin: crossOrigin} = this.config;
|
|
4134
4139
|
Resource.tasker.add(() => __awaiter(this, void 0, void 0, function*() {
|
|
4135
|
-
return yield Platform.origin.loadImage(this.
|
|
4140
|
+
return yield Platform.origin.loadImage(this.getLoadUrl(thumbSize), this.crossOrigin, this).then(img => {
|
|
4141
|
+
if (thumbSize) this.setThumbView(img);
|
|
4142
|
+
this.setView(img);
|
|
4143
|
+
}).catch(e => {
|
|
4136
4144
|
this.error = e;
|
|
4137
4145
|
this.onComplete(false);
|
|
4138
4146
|
});
|
|
@@ -4153,9 +4161,11 @@ class LeaferImage {
|
|
|
4153
4161
|
}
|
|
4154
4162
|
setView(img) {
|
|
4155
4163
|
this.ready = true;
|
|
4156
|
-
this.width
|
|
4157
|
-
|
|
4158
|
-
|
|
4164
|
+
if (!this.width) {
|
|
4165
|
+
this.width = img.width;
|
|
4166
|
+
this.height = img.height;
|
|
4167
|
+
this.view = img;
|
|
4168
|
+
}
|
|
4159
4169
|
this.onComplete(true);
|
|
4160
4170
|
}
|
|
4161
4171
|
onComplete(isSuccess) {
|
|
@@ -4201,6 +4211,19 @@ class LeaferImage {
|
|
|
4201
4211
|
Platform.image.setPatternTransform(pattern, transform, paint);
|
|
4202
4212
|
return pattern;
|
|
4203
4213
|
}
|
|
4214
|
+
getLoadUrl(_thumbSize) {
|
|
4215
|
+
return this.url;
|
|
4216
|
+
}
|
|
4217
|
+
setThumbView(_view) {}
|
|
4218
|
+
getThumbSize(_lod) {
|
|
4219
|
+
return undefined;
|
|
4220
|
+
}
|
|
4221
|
+
getMinLevel() {
|
|
4222
|
+
return undefined;
|
|
4223
|
+
}
|
|
4224
|
+
getLevelData(_level, _width, _height) {
|
|
4225
|
+
return undefined;
|
|
4226
|
+
}
|
|
4204
4227
|
clearLevels(_checkUse) {}
|
|
4205
4228
|
destroy() {
|
|
4206
4229
|
this.clearLevels();
|
|
@@ -6930,7 +6953,7 @@ class LeafLevelList {
|
|
|
6930
6953
|
}
|
|
6931
6954
|
}
|
|
6932
6955
|
|
|
6933
|
-
const version = "1.12.
|
|
6956
|
+
const version = "1.12.4";
|
|
6934
6957
|
|
|
6935
6958
|
exports.AlignHelper = AlignHelper;
|
|
6936
6959
|
|
package/lib/core.esm.js
CHANGED
|
@@ -237,11 +237,13 @@ const Platform = {
|
|
|
237
237
|
const ctx = canvas.getContext("2d");
|
|
238
238
|
if (opacity) ctx.globalAlpha = opacity;
|
|
239
239
|
ctx.imageSmoothingEnabled = smooth === false ? false : true;
|
|
240
|
-
if (
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
240
|
+
if (image) {
|
|
241
|
+
if (clip) {
|
|
242
|
+
const scaleX = width / clip.width, scaleY = height / clip.height;
|
|
243
|
+
ctx.setTransform(scaleX, 0, 0, scaleY, -clip.x * scaleX, -clip.y * scaleY);
|
|
244
|
+
ctx.drawImage(image, 0, 0, image.width, image.height);
|
|
245
|
+
} else ctx.drawImage(image, 0, 0, width, height);
|
|
246
|
+
}
|
|
245
247
|
return canvas;
|
|
246
248
|
},
|
|
247
249
|
setPatternTransform(pattern, transform, paint) {
|
|
@@ -4108,6 +4110,10 @@ class LeaferImage {
|
|
|
4108
4110
|
get url() {
|
|
4109
4111
|
return this.config.url;
|
|
4110
4112
|
}
|
|
4113
|
+
get crossOrigin() {
|
|
4114
|
+
const {crossOrigin: crossOrigin} = this.config;
|
|
4115
|
+
return isUndefined(crossOrigin) ? Platform.image.crossOrigin : crossOrigin;
|
|
4116
|
+
}
|
|
4111
4117
|
get completed() {
|
|
4112
4118
|
return this.ready || !!this.error;
|
|
4113
4119
|
}
|
|
@@ -4125,12 +4131,14 @@ class LeaferImage {
|
|
|
4125
4131
|
ImageManager.isFormat("svg", config) && (this.isSVG = true);
|
|
4126
4132
|
ImageManager.hasAlphaPixel(config) && (this.hasAlphaPixel = true);
|
|
4127
4133
|
}
|
|
4128
|
-
load(onSuccess, onError) {
|
|
4134
|
+
load(onSuccess, onError, thumbSize) {
|
|
4129
4135
|
if (!this.loading) {
|
|
4130
4136
|
this.loading = true;
|
|
4131
|
-
const {crossOrigin: crossOrigin} = this.config;
|
|
4132
4137
|
Resource.tasker.add(() => __awaiter(this, void 0, void 0, function*() {
|
|
4133
|
-
return yield Platform.origin.loadImage(this.
|
|
4138
|
+
return yield Platform.origin.loadImage(this.getLoadUrl(thumbSize), this.crossOrigin, this).then(img => {
|
|
4139
|
+
if (thumbSize) this.setThumbView(img);
|
|
4140
|
+
this.setView(img);
|
|
4141
|
+
}).catch(e => {
|
|
4134
4142
|
this.error = e;
|
|
4135
4143
|
this.onComplete(false);
|
|
4136
4144
|
});
|
|
@@ -4151,9 +4159,11 @@ class LeaferImage {
|
|
|
4151
4159
|
}
|
|
4152
4160
|
setView(img) {
|
|
4153
4161
|
this.ready = true;
|
|
4154
|
-
this.width
|
|
4155
|
-
|
|
4156
|
-
|
|
4162
|
+
if (!this.width) {
|
|
4163
|
+
this.width = img.width;
|
|
4164
|
+
this.height = img.height;
|
|
4165
|
+
this.view = img;
|
|
4166
|
+
}
|
|
4157
4167
|
this.onComplete(true);
|
|
4158
4168
|
}
|
|
4159
4169
|
onComplete(isSuccess) {
|
|
@@ -4199,6 +4209,19 @@ class LeaferImage {
|
|
|
4199
4209
|
Platform.image.setPatternTransform(pattern, transform, paint);
|
|
4200
4210
|
return pattern;
|
|
4201
4211
|
}
|
|
4212
|
+
getLoadUrl(_thumbSize) {
|
|
4213
|
+
return this.url;
|
|
4214
|
+
}
|
|
4215
|
+
setThumbView(_view) {}
|
|
4216
|
+
getThumbSize(_lod) {
|
|
4217
|
+
return undefined;
|
|
4218
|
+
}
|
|
4219
|
+
getMinLevel() {
|
|
4220
|
+
return undefined;
|
|
4221
|
+
}
|
|
4222
|
+
getLevelData(_level, _width, _height) {
|
|
4223
|
+
return undefined;
|
|
4224
|
+
}
|
|
4202
4225
|
clearLevels(_checkUse) {}
|
|
4203
4226
|
destroy() {
|
|
4204
4227
|
this.clearLevels();
|
|
@@ -6928,6 +6951,6 @@ class LeafLevelList {
|
|
|
6928
6951
|
}
|
|
6929
6952
|
}
|
|
6930
6953
|
|
|
6931
|
-
const version = "1.12.
|
|
6954
|
+
const version = "1.12.4";
|
|
6932
6955
|
|
|
6933
6956
|
export { AlignHelper, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Branch, BranchHelper, BranchRender, CanvasManager, ChildEvent, Creator, DataHelper, Debug, Direction4, Direction9, EllipseHelper, Event, EventCreator, Eventer, FileHelper, FourNumberHelper, 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, PathCommandNodeHelper, 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, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, dimType, doBoundsType, doStrokeType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds, tempMatrix, tempPoint$2 as tempPoint, tryToNumber, useModule, version, visibleType };
|