@leafer-draw/miniapp 1.3.3 → 1.4.1

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.
@@ -1,4 +1,4 @@
1
- import { LeaferCanvasBase, Platform, canvasPatch, DataHelper, canvasSizeAttrs, ResizeEvent, Creator, LeaferImage, defineKey, FileHelper, LeafList, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, Bounds, LeafBoundsHelper, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, BoundsHelper, MatrixHelper, MathHelper, AlignHelper, ImageEvent, AroundHelper, PointHelper, Direction4 } from '@leafer/core';
1
+ import { LeaferCanvasBase, Platform, canvasPatch, DataHelper, canvasSizeAttrs, ResizeEvent, FileHelper, Creator, LeaferImage, defineKey, LeafList, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, BoundsHelper, MatrixHelper, MathHelper, AlignHelper, ImageEvent, AroundHelper, PointHelper, Direction4 } from '@leafer/core';
2
2
  export * from '@leafer/core';
3
3
  export { LeaferImage } from '@leafer/core';
4
4
  import { PaintImage, ColorConvert, PaintGradient, Export, Group, TextConvert, Paint, Effect } from '@leafer-ui/draw';
@@ -486,7 +486,7 @@ class Layouter {
486
486
  }
487
487
  partLayout() {
488
488
  var _a;
489
- if (!((_a = this.__updatedList) === null || _a === undefined ? undefined : _a.length))
489
+ if (!((_a = this.__updatedList) === null || _a === void 0 ? void 0 : _a.length))
490
490
  return;
491
491
  const t = Run.start('PartLayout');
492
492
  const { target, __updatedList: updateList } = this;
@@ -1176,7 +1176,7 @@ function getPatternData(paint, box, image) {
1176
1176
  box = tempBox.set(box).shrink(paint.padding);
1177
1177
  if (paint.mode === 'strench')
1178
1178
  paint.mode = 'stretch';
1179
- const { opacity, mode, align, offset, scale, size, rotation, repeat } = paint;
1179
+ const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
1180
1180
  const sameBox = box.width === width && box.height === height;
1181
1181
  const data = { mode };
1182
1182
  const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
@@ -1239,6 +1239,8 @@ function getPatternData(paint, box, image) {
1239
1239
  data.height = height;
1240
1240
  if (opacity)
1241
1241
  data.opacity = opacity;
1242
+ if (filters)
1243
+ data.filters = filters;
1242
1244
  if (repeat)
1243
1245
  data.repeat = typeof repeat === 'string' ? (repeat === 'x' ? 'repeat-x' : 'repeat-y') : 'repeat';
1244
1246
  return data;
@@ -1341,7 +1343,7 @@ function createPattern(ui, paint, pixelRatio) {
1341
1343
  scaleX = abs$1(scaleX);
1342
1344
  scaleY = abs$1(scaleY);
1343
1345
  const { image, data } = paint;
1344
- let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, opacity, transform, repeat } = data;
1346
+ let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, transform, repeat } = data;
1345
1347
  if (sx) {
1346
1348
  imageMatrix = get$1();
1347
1349
  copy$1(imageMatrix, transform);
@@ -1384,7 +1386,7 @@ function createPattern(ui, paint, pixelRatio) {
1384
1386
  }
1385
1387
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
1386
1388
  }
1387
- const canvas = image.getCanvas(ceil(width) || 1, ceil(height) || 1, opacity);
1389
+ const canvas = image.getCanvas(ceil(width) || 1, ceil(height) || 1, data.opacity, data.filters);
1388
1390
  const pattern = image.getPattern(canvas, repeat || (Platform.origin.noRepeat || 'no-repeat'), imageMatrix, paint);
1389
1391
  paint.style = pattern;
1390
1392
  paint.patternId = id;
@@ -1460,7 +1462,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
1460
1462
  canvas.opacity *= data.opacity;
1461
1463
  if (data.transform)
1462
1464
  canvas.transform(data.transform);
1463
- canvas.drawImage(paint.image.view, 0, 0, data.width, data.height);
1465
+ canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
1464
1466
  canvas.restore();
1465
1467
  return true;
1466
1468
  }
@@ -1470,7 +1472,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
1470
1472
  }
1471
1473
  else {
1472
1474
  if (!paint.patternTask) {
1473
- paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, undefined, undefined, function* () {
1475
+ paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
1474
1476
  paint.patternTask = null;
1475
1477
  if (canvas.bounds.hit(ui.__nowWorld))
1476
1478
  createPattern(ui, paint, pixelRatio);
@@ -2060,11 +2062,11 @@ const TextMode = 2;
2060
2062
  function layoutChar(drawData, style, width, _height) {
2061
2063
  const { rows } = drawData;
2062
2064
  const { textAlign, paraIndent, letterSpacing } = style;
2063
- let charX, addWordWidth, indentWidth, mode, wordChar;
2065
+ let charX, addWordWidth, indentWidth, mode, wordChar, wordsLength;
2064
2066
  rows.forEach(row => {
2065
2067
  if (row.words) {
2066
- indentWidth = paraIndent && row.paraStart ? paraIndent : 0;
2067
- addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
2068
+ indentWidth = paraIndent && row.paraStart ? paraIndent : 0, wordsLength = row.words.length;
2069
+ addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') && wordsLength > 1) ? (width - row.width - indentWidth) / (wordsLength - 1) : 0;
2068
2070
  mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode : TextMode);
2069
2071
  if (row.isOverflow && !letterSpacing)
2070
2072
  row.textMode = true;
@@ -2076,7 +2078,7 @@ function layoutChar(drawData, style, width, _height) {
2076
2078
  row.x += indentWidth;
2077
2079
  charX = row.x;
2078
2080
  row.data = [];
2079
- row.words.forEach(word => {
2081
+ row.words.forEach((word, index) => {
2080
2082
  if (mode === WordMode) {
2081
2083
  wordChar = { char: '', x: charX };
2082
2084
  charX = toWordChar(word.data, charX, wordChar);
@@ -2086,7 +2088,7 @@ function layoutChar(drawData, style, width, _height) {
2086
2088
  else {
2087
2089
  charX = toChar(word.data, charX, row.data, row.isOverflow);
2088
2090
  }
2089
- if (addWordWidth && (!row.paraEnd || textAlign === 'both')) {
2091
+ if (addWordWidth && (!row.paraEnd || textAlign === 'both') && (index !== wordsLength - 1)) {
2090
2092
  charX += addWordWidth;
2091
2093
  row.width += addWordWidth;
2092
2094
  }
@@ -2342,3 +2344,4 @@ try {
2342
2344
  catch (_a) { }
2343
2345
 
2344
2346
  export { Layouter, LeaferCanvas, Renderer, Watcher, useCanvas };
2347
+ //# sourceMappingURL=miniapp.esm.js.map