@leafer-draw/miniapp 2.0.0 → 2.0.2

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/miniapp.cjs CHANGED
@@ -116,8 +116,6 @@ class LeaferCanvas extends core.LeaferCanvasBase {
116
116
  }
117
117
  }
118
118
 
119
- const {mineType: mineType, fileType: fileType} = core.FileHelper;
120
-
121
119
  Object.assign(core.Creator, {
122
120
  canvas: (options, manager) => new LeaferCanvas(options, manager),
123
121
  image: options => new core.LeaferImage(options)
@@ -133,12 +131,12 @@ function useCanvas(_canvasType, app) {
133
131
  };
134
132
  return app.createOffscreenCanvas ? app.createOffscreenCanvas(data) : app.createOffScreenCanvas(data);
135
133
  },
136
- canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(mineType(type), quality),
134
+ canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(core.FileHelper.mimeType(type), quality),
137
135
  canvasToBolb: (canvas, type, quality) => canvas.toBuffer(type, {
138
136
  quality: quality
139
137
  }),
140
138
  canvasSaveAs: (canvas, filePath, quality) => {
141
- let data = canvas.toDataURL(mineType(fileType(filePath)), quality);
139
+ let data = canvas.toDataURL(core.FileHelper.mimeType(core.FileHelper.fileType(filePath)), quality);
142
140
  data = data.substring(data.indexOf("64,") + 3);
143
141
  return core.Platform.origin.download(data, filePath);
144
142
  },
@@ -172,7 +170,7 @@ function useCanvas(_canvasType, app) {
172
170
  });
173
171
  });
174
172
  },
175
- loadImage(src) {
173
+ loadImage(src, _crossOrigin, _leaferImage) {
176
174
  return new Promise((resolve, reject) => {
177
175
  const img = core.Platform.canvas.view.createImage();
178
176
  img.onload = () => {
@@ -184,6 +182,14 @@ function useCanvas(_canvasType, app) {
184
182
  img.src = core.Platform.image.getRealURL(src);
185
183
  });
186
184
  },
185
+ loadContent(url, responseType = "text") {
186
+ return new Promise((resolve, reject) => app.request({
187
+ url: url,
188
+ responseType: responseType === "arrayBuffer" ? "arraybuffer" : "text",
189
+ success: res => resolve(responseType === "json" && typeof res.data === "string" ? JSON.parse(res.data) : res.data),
190
+ fail: reject
191
+ }));
192
+ },
187
193
  noRepeat: "repeat-x"
188
194
  };
189
195
  core.Platform.miniapp = {
@@ -735,7 +741,7 @@ class Renderer {
735
741
  getCellList() {
736
742
  return undefined;
737
743
  }
738
- addBlock(block) {
744
+ addBlock(block, _leafList) {
739
745
  if (!this.updateBlocks) this.updateBlocks = [];
740
746
  this.updateBlocks.push(block);
741
747
  }
@@ -783,7 +789,8 @@ class Renderer {
783
789
  __onLayoutEnd(event) {
784
790
  if (event.data) event.data.map(item => {
785
791
  let empty;
786
- if (item.updatedList) item.updatedList.list.some(leaf => {
792
+ const {updatedList: updatedList} = item;
793
+ if (updatedList) updatedList.list.some(leaf => {
787
794
  empty = !leaf.__world.width || !leaf.__world.height;
788
795
  if (empty) {
789
796
  if (!leaf.isLeafer) debug.tip(leaf.innerName, ": empty");
@@ -791,7 +798,7 @@ class Renderer {
791
798
  }
792
799
  return empty;
793
800
  });
794
- this.addBlock(empty ? this.canvas.bounds : item.updatedBounds);
801
+ this.addBlock(empty ? this.canvas.bounds : item.updatedBounds, updatedList);
795
802
  });
796
803
  }
797
804
  emitRender(type, bounds, options) {
@@ -1131,11 +1138,14 @@ function compute(attrName, ui) {
1131
1138
  function getLeafPaint(attrName, paint, ui) {
1132
1139
  if (!core.isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
1133
1140
  let leafPaint;
1134
- const {boxBounds: boxBounds} = ui.__layout;
1135
- switch (paint.type) {
1141
+ const {boxBounds: boxBounds} = ui.__layout, {type: type} = paint;
1142
+ switch (type) {
1136
1143
  case "image":
1144
+ case "film":
1145
+ case "video":
1137
1146
  if (!paint.url) return undefined;
1138
1147
  leafPaint = draw.PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
1148
+ if (type !== "image") draw.PaintImage[type](leafPaint);
1139
1149
  break;
1140
1150
 
1141
1151
  case "linear":
@@ -1151,7 +1161,7 @@ function getLeafPaint(attrName, paint, ui) {
1151
1161
  break;
1152
1162
 
1153
1163
  case "solid":
1154
- const {type: type, color: color, opacity: opacity} = paint;
1164
+ const {color: color, opacity: opacity} = paint;
1155
1165
  leafPaint = {
1156
1166
  type: type,
1157
1167
  style: draw.ColorConvert.string(color, opacity)
@@ -1195,7 +1205,7 @@ const {isSame: isSame} = core.BoundsHelper;
1195
1205
 
1196
1206
  function image(ui, attrName, paint, boxBounds, firstUse) {
1197
1207
  let leafPaint, event;
1198
- const image = core.ImageManager.get(paint);
1208
+ const image = core.ImageManager.get(paint, paint.type);
1199
1209
  if (cache && paint === cache.paint && isSame(boxBounds, cache.boxBounds)) {
1200
1210
  leafPaint = cache.leafPaint;
1201
1211
  } else {
@@ -1256,8 +1266,8 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
1256
1266
  }
1257
1267
 
1258
1268
  function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
1259
- if (attrName === "fill" && !ui.__.__naturalWidth) {
1260
- const data = ui.__;
1269
+ const data = ui.__;
1270
+ if (attrName === "fill" && !data.__naturalWidth) {
1261
1271
  data.__naturalWidth = image.width / data.pixelRatio;
1262
1272
  data.__naturalHeight = image.height / data.pixelRatio;
1263
1273
  if (data.__autoSide) {
@@ -1269,7 +1279,12 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
1269
1279
  return false;
1270
1280
  }
1271
1281
  }
1272
- if (!leafPaint.data) draw.PaintImage.createData(leafPaint, image, paint, boxBounds);
1282
+ if (!leafPaint.data) {
1283
+ draw.PaintImage.createData(leafPaint, image, paint, boxBounds);
1284
+ const {transform: transform} = leafPaint.data, {opacity: opacity, blendMode: blendMode} = paint;
1285
+ const clip = transform && !transform.onlyScale || data.path || data.cornerRadius;
1286
+ if (clip || opacity && opacity < 1 || blendMode) leafPaint.complex = clip ? 2 : true;
1287
+ }
1273
1288
  return true;
1274
1289
  }
1275
1290
 
@@ -1312,7 +1327,7 @@ function getPatternData(paint, box, image) {
1312
1327
  if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
1313
1328
  if (paint.mode === "strench") paint.mode = "stretch";
1314
1329
  const {width: width, height: height} = image;
1315
- const {opacity: opacity, mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, filters: filters, interlace: interlace} = paint;
1330
+ const {mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, interlace: interlace} = paint;
1316
1331
  const sameBox = box.width === width && box.height === height;
1317
1332
  const data = {
1318
1333
  mode: mode
@@ -1375,8 +1390,6 @@ function getPatternData(paint, box, image) {
1375
1390
  data.scaleX = scaleX;
1376
1391
  data.scaleY = scaleY;
1377
1392
  }
1378
- if (opacity && opacity < 1) data.opacity = opacity;
1379
- if (filters) data.filters = filters;
1380
1393
  if (repeat) data.repeat = core.isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
1381
1394
  if (interlace) data.interlace = core.isNumber(interlace) || interlace.type === "percent" ? {
1382
1395
  type: "x",
@@ -1407,7 +1420,7 @@ const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translat
1407
1420
 
1408
1421
  function stretchMode(data, box, scaleX, scaleY) {
1409
1422
  const transform = get$2(), {x: x, y: y} = box;
1410
- if (x || y) translate(transform, x, y); else transform.onlyScale = true;
1423
+ if (x || y) translate(transform, x, y); else if (scaleX > 0 && scaleY > 0) transform.onlyScale = true;
1411
1424
  scaleHelper(transform, scaleX, scaleY);
1412
1425
  data.transform = transform;
1413
1426
  }
@@ -1529,10 +1542,10 @@ function createPatternTask(paint, ui, canvas, renderOptions) {
1529
1542
  }
1530
1543
 
1531
1544
  function createPattern(paint, ui, canvas, renderOptions) {
1532
- let {scaleX: scaleX, scaleY: scaleY} = draw.PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
1545
+ let {scaleX: scaleX, scaleY: scaleY} = draw.PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
1533
1546
  if (paint.patternId !== id && !ui.destroyed) {
1534
1547
  if (!(core.Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
1535
- const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = draw.PaintImage.getPatternFixScale(paint, scaleX, scaleY);
1548
+ const {image: image, data: data} = paint, {opacity: opacity, filters: filters} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = draw.PaintImage.getPatternFixScale(paint, scaleX, scaleY);
1536
1549
  let imageMatrix, xGap, yGap, {width: width, height: height} = image;
1537
1550
  if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
1538
1551
  width *= scaleX;
@@ -1548,7 +1561,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
1548
1561
  if (transform) copy$1(imageMatrix, transform);
1549
1562
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
1550
1563
  }
1551
- const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
1564
+ const imageCanvas = image.getCanvas(width, height, opacity, filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
1552
1565
  const pattern = image.getPattern(imageCanvas, data.repeat || (core.Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
1553
1566
  paint.style = pattern;
1554
1567
  paint.patternId = id;
@@ -1569,15 +1582,15 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
1569
1582
  }
1570
1583
 
1571
1584
  function checkImage(paint, drawImage, ui, canvas, renderOptions) {
1572
- const {scaleX: scaleX, scaleY: scaleY} = draw.PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
1585
+ const {scaleX: scaleX, scaleY: scaleY} = draw.PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
1573
1586
  const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
1574
- if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting || snapshot) {
1587
+ if (!data || paint.patternId === id && !exporting || snapshot) {
1575
1588
  return false;
1576
1589
  } else {
1577
1590
  if (drawImage) {
1578
1591
  if (data.repeat) {
1579
1592
  drawImage = false;
1580
- } else if (!(originPaint.changeful || core.Platform.name === "miniapp" && core.ResizeEvent.isResizing(ui) || exporting)) {
1593
+ } else if (!(originPaint.changeful || paint.film || core.Platform.name === "miniapp" && core.ResizeEvent.isResizing(ui) || exporting)) {
1581
1594
  drawImage = core.Platform.image.isLarge(image, scaleX, scaleY) || image.width * scaleX > 8096 || image.height * scaleY > 8096;
1582
1595
  }
1583
1596
  }
@@ -1595,20 +1608,21 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
1595
1608
  }
1596
1609
  }
1597
1610
 
1598
- function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
1599
- const {data: data, image: image} = paint, {blendMode: blendMode} = paint.originPaint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
1600
- let {width: width, height: height} = image, clipUI;
1601
- if ((clipUI = transform && !transform.onlyScale || u.path || u.cornerRadius) || opacity || blendMode) {
1611
+ function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions) {
1612
+ const {data: data, image: image, complex: complex} = paint;
1613
+ let {width: width, height: height} = image;
1614
+ if (complex) {
1615
+ const {blendMode: blendMode, opacity: opacity} = paint.originPaint, {transform: transform} = data;
1602
1616
  canvas.save();
1603
- clipUI && canvas.clipUI(ui);
1617
+ complex === 2 && canvas.clipUI(ui);
1604
1618
  blendMode && (canvas.blendMode = blendMode);
1605
1619
  opacity && (canvas.opacity *= opacity);
1606
1620
  transform && canvas.transform(transform);
1607
- canvas.drawImage(view, 0, 0, width, height);
1621
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
1608
1622
  canvas.restore();
1609
1623
  } else {
1610
1624
  if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
1611
- canvas.drawImage(view, 0, 0, width, height);
1625
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
1612
1626
  }
1613
1627
  }
1614
1628
 
@@ -2328,7 +2342,7 @@ function layoutText(drawData, style) {
2328
2342
  let {x: x, y: y, width: width, height: height} = bounds, realHeight = __lineHeight * countRows + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
2329
2343
  let starY = __baseLine;
2330
2344
  if (__clipText && realHeight > height) {
2331
- realHeight = Math.max(height, __lineHeight);
2345
+ realHeight = Math.max(style.__autoHeight ? realHeight : height, __lineHeight);
2332
2346
  if (countRows > 1) drawData.overflow = countRows;
2333
2347
  } else if (height || autoSizeAlign) {
2334
2348
  switch (verticalAlign) {
@@ -2385,10 +2399,10 @@ function layoutText(drawData, style) {
2385
2399
  }
2386
2400
 
2387
2401
  function clipText(drawData, style, x, width) {
2388
- if (!width) return;
2389
2402
  const {rows: rows, overflow: overflow} = drawData;
2390
2403
  let {textOverflow: textOverflow} = style;
2391
- rows.splice(overflow);
2404
+ if (overflow) rows.splice(overflow);
2405
+ if (!width) return;
2392
2406
  if (textOverflow && textOverflow !== "show") {
2393
2407
  if (textOverflow === "hide") textOverflow = ""; else if (textOverflow === "ellipsis") textOverflow = "...";
2394
2408
  let char, charRight;
@@ -2549,6 +2563,13 @@ try {
2549
2563
  if (wx) useCanvas("miniapp", wx);
2550
2564
  } catch (_a) {}
2551
2565
 
2566
+ Object.defineProperty(exports, "LeaferFilm", {
2567
+ enumerable: true,
2568
+ get: function() {
2569
+ return core.LeaferFilm;
2570
+ }
2571
+ });
2572
+
2552
2573
  Object.defineProperty(exports, "LeaferImage", {
2553
2574
  enumerable: true,
2554
2575
  get: function() {
@@ -2556,6 +2577,13 @@ Object.defineProperty(exports, "LeaferImage", {
2556
2577
  }
2557
2578
  });
2558
2579
 
2580
+ Object.defineProperty(exports, "LeaferVideo", {
2581
+ enumerable: true,
2582
+ get: function() {
2583
+ return core.LeaferVideo;
2584
+ }
2585
+ });
2586
+
2559
2587
  exports.Layouter = Layouter;
2560
2588
 
2561
2589
  exports.LeaferCanvas = LeaferCanvas;
@@ -1,8 +1,8 @@
1
- import { LeaferCanvasBase, isString, Platform, isNumber, canvasPatch, DataHelper, canvasSizeAttrs, isUndefined, ResizeEvent, FileHelper, Creator, LeaferImage, defineKey, LeafList, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, isArray, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, isObject, BoundsHelper, FourNumberHelper, Matrix, ImageEvent, MatrixHelper, MathHelper, AlignHelper, PointHelper, getMatrixData, AroundHelper, Direction4 } from "@leafer/core";
1
+ import { LeaferCanvasBase, isString, Platform, isNumber, canvasPatch, DataHelper, canvasSizeAttrs, isUndefined, ResizeEvent, Creator, LeaferImage, defineKey, FileHelper, LeafList, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, isArray, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, isObject, BoundsHelper, FourNumberHelper, Matrix, ImageEvent, MatrixHelper, MathHelper, AlignHelper, PointHelper, getMatrixData, AroundHelper, Direction4 } from "@leafer/core";
2
2
 
3
3
  export * from "@leafer/core";
4
4
 
5
- export { LeaferImage } from "@leafer/core";
5
+ export { LeaferFilm, LeaferImage, LeaferVideo } from "@leafer/core";
6
6
 
7
7
  import { Paint, PaintImage, ColorConvert, PaintGradient, Effect, Group, TextConvert } from "@leafer-ui/draw";
8
8
 
@@ -120,8 +120,6 @@ class LeaferCanvas extends LeaferCanvasBase {
120
120
  }
121
121
  }
122
122
 
123
- const {mineType: mineType, fileType: fileType} = FileHelper;
124
-
125
123
  Object.assign(Creator, {
126
124
  canvas: (options, manager) => new LeaferCanvas(options, manager),
127
125
  image: options => new LeaferImage(options)
@@ -137,12 +135,12 @@ function useCanvas(_canvasType, app) {
137
135
  };
138
136
  return app.createOffscreenCanvas ? app.createOffscreenCanvas(data) : app.createOffScreenCanvas(data);
139
137
  },
140
- canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(mineType(type), quality),
138
+ canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(FileHelper.mimeType(type), quality),
141
139
  canvasToBolb: (canvas, type, quality) => canvas.toBuffer(type, {
142
140
  quality: quality
143
141
  }),
144
142
  canvasSaveAs: (canvas, filePath, quality) => {
145
- let data = canvas.toDataURL(mineType(fileType(filePath)), quality);
143
+ let data = canvas.toDataURL(FileHelper.mimeType(FileHelper.fileType(filePath)), quality);
146
144
  data = data.substring(data.indexOf("64,") + 3);
147
145
  return Platform.origin.download(data, filePath);
148
146
  },
@@ -176,7 +174,7 @@ function useCanvas(_canvasType, app) {
176
174
  });
177
175
  });
178
176
  },
179
- loadImage(src) {
177
+ loadImage(src, _crossOrigin, _leaferImage) {
180
178
  return new Promise((resolve, reject) => {
181
179
  const img = Platform.canvas.view.createImage();
182
180
  img.onload = () => {
@@ -188,6 +186,14 @@ function useCanvas(_canvasType, app) {
188
186
  img.src = Platform.image.getRealURL(src);
189
187
  });
190
188
  },
189
+ loadContent(url, responseType = "text") {
190
+ return new Promise((resolve, reject) => app.request({
191
+ url: url,
192
+ responseType: responseType === "arrayBuffer" ? "arraybuffer" : "text",
193
+ success: res => resolve(responseType === "json" && typeof res.data === "string" ? JSON.parse(res.data) : res.data),
194
+ fail: reject
195
+ }));
196
+ },
191
197
  noRepeat: "repeat-x"
192
198
  };
193
199
  Platform.miniapp = {
@@ -739,7 +745,7 @@ class Renderer {
739
745
  getCellList() {
740
746
  return undefined;
741
747
  }
742
- addBlock(block) {
748
+ addBlock(block, _leafList) {
743
749
  if (!this.updateBlocks) this.updateBlocks = [];
744
750
  this.updateBlocks.push(block);
745
751
  }
@@ -787,7 +793,8 @@ class Renderer {
787
793
  __onLayoutEnd(event) {
788
794
  if (event.data) event.data.map(item => {
789
795
  let empty;
790
- if (item.updatedList) item.updatedList.list.some(leaf => {
796
+ const {updatedList: updatedList} = item;
797
+ if (updatedList) updatedList.list.some(leaf => {
791
798
  empty = !leaf.__world.width || !leaf.__world.height;
792
799
  if (empty) {
793
800
  if (!leaf.isLeafer) debug.tip(leaf.innerName, ": empty");
@@ -795,7 +802,7 @@ class Renderer {
795
802
  }
796
803
  return empty;
797
804
  });
798
- this.addBlock(empty ? this.canvas.bounds : item.updatedBounds);
805
+ this.addBlock(empty ? this.canvas.bounds : item.updatedBounds, updatedList);
799
806
  });
800
807
  }
801
808
  emitRender(type, bounds, options) {
@@ -1135,11 +1142,14 @@ function compute(attrName, ui) {
1135
1142
  function getLeafPaint(attrName, paint, ui) {
1136
1143
  if (!isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
1137
1144
  let leafPaint;
1138
- const {boxBounds: boxBounds} = ui.__layout;
1139
- switch (paint.type) {
1145
+ const {boxBounds: boxBounds} = ui.__layout, {type: type} = paint;
1146
+ switch (type) {
1140
1147
  case "image":
1148
+ case "film":
1149
+ case "video":
1141
1150
  if (!paint.url) return undefined;
1142
1151
  leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
1152
+ if (type !== "image") PaintImage[type](leafPaint);
1143
1153
  break;
1144
1154
 
1145
1155
  case "linear":
@@ -1155,7 +1165,7 @@ function getLeafPaint(attrName, paint, ui) {
1155
1165
  break;
1156
1166
 
1157
1167
  case "solid":
1158
- const {type: type, color: color, opacity: opacity} = paint;
1168
+ const {color: color, opacity: opacity} = paint;
1159
1169
  leafPaint = {
1160
1170
  type: type,
1161
1171
  style: ColorConvert.string(color, opacity)
@@ -1199,7 +1209,7 @@ const {isSame: isSame} = BoundsHelper;
1199
1209
 
1200
1210
  function image(ui, attrName, paint, boxBounds, firstUse) {
1201
1211
  let leafPaint, event;
1202
- const image = ImageManager.get(paint);
1212
+ const image = ImageManager.get(paint, paint.type);
1203
1213
  if (cache && paint === cache.paint && isSame(boxBounds, cache.boxBounds)) {
1204
1214
  leafPaint = cache.leafPaint;
1205
1215
  } else {
@@ -1260,8 +1270,8 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
1260
1270
  }
1261
1271
 
1262
1272
  function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
1263
- if (attrName === "fill" && !ui.__.__naturalWidth) {
1264
- const data = ui.__;
1273
+ const data = ui.__;
1274
+ if (attrName === "fill" && !data.__naturalWidth) {
1265
1275
  data.__naturalWidth = image.width / data.pixelRatio;
1266
1276
  data.__naturalHeight = image.height / data.pixelRatio;
1267
1277
  if (data.__autoSide) {
@@ -1273,7 +1283,12 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
1273
1283
  return false;
1274
1284
  }
1275
1285
  }
1276
- if (!leafPaint.data) PaintImage.createData(leafPaint, image, paint, boxBounds);
1286
+ if (!leafPaint.data) {
1287
+ PaintImage.createData(leafPaint, image, paint, boxBounds);
1288
+ const {transform: transform} = leafPaint.data, {opacity: opacity, blendMode: blendMode} = paint;
1289
+ const clip = transform && !transform.onlyScale || data.path || data.cornerRadius;
1290
+ if (clip || opacity && opacity < 1 || blendMode) leafPaint.complex = clip ? 2 : true;
1291
+ }
1277
1292
  return true;
1278
1293
  }
1279
1294
 
@@ -1316,7 +1331,7 @@ function getPatternData(paint, box, image) {
1316
1331
  if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
1317
1332
  if (paint.mode === "strench") paint.mode = "stretch";
1318
1333
  const {width: width, height: height} = image;
1319
- const {opacity: opacity, mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, filters: filters, interlace: interlace} = paint;
1334
+ const {mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, interlace: interlace} = paint;
1320
1335
  const sameBox = box.width === width && box.height === height;
1321
1336
  const data = {
1322
1337
  mode: mode
@@ -1379,8 +1394,6 @@ function getPatternData(paint, box, image) {
1379
1394
  data.scaleX = scaleX;
1380
1395
  data.scaleY = scaleY;
1381
1396
  }
1382
- if (opacity && opacity < 1) data.opacity = opacity;
1383
- if (filters) data.filters = filters;
1384
1397
  if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
1385
1398
  if (interlace) data.interlace = isNumber(interlace) || interlace.type === "percent" ? {
1386
1399
  type: "x",
@@ -1411,7 +1424,7 @@ const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translat
1411
1424
 
1412
1425
  function stretchMode(data, box, scaleX, scaleY) {
1413
1426
  const transform = get$2(), {x: x, y: y} = box;
1414
- if (x || y) translate(transform, x, y); else transform.onlyScale = true;
1427
+ if (x || y) translate(transform, x, y); else if (scaleX > 0 && scaleY > 0) transform.onlyScale = true;
1415
1428
  scaleHelper(transform, scaleX, scaleY);
1416
1429
  data.transform = transform;
1417
1430
  }
@@ -1533,10 +1546,10 @@ function createPatternTask(paint, ui, canvas, renderOptions) {
1533
1546
  }
1534
1547
 
1535
1548
  function createPattern(paint, ui, canvas, renderOptions) {
1536
- let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
1549
+ let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
1537
1550
  if (paint.patternId !== id && !ui.destroyed) {
1538
1551
  if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
1539
- const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
1552
+ const {image: image, data: data} = paint, {opacity: opacity, filters: filters} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
1540
1553
  let imageMatrix, xGap, yGap, {width: width, height: height} = image;
1541
1554
  if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
1542
1555
  width *= scaleX;
@@ -1552,7 +1565,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
1552
1565
  if (transform) copy$1(imageMatrix, transform);
1553
1566
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
1554
1567
  }
1555
- const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
1568
+ const imageCanvas = image.getCanvas(width, height, opacity, filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
1556
1569
  const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
1557
1570
  paint.style = pattern;
1558
1571
  paint.patternId = id;
@@ -1573,15 +1586,15 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
1573
1586
  }
1574
1587
 
1575
1588
  function checkImage(paint, drawImage, ui, canvas, renderOptions) {
1576
- const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
1589
+ const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
1577
1590
  const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
1578
- if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting || snapshot) {
1591
+ if (!data || paint.patternId === id && !exporting || snapshot) {
1579
1592
  return false;
1580
1593
  } else {
1581
1594
  if (drawImage) {
1582
1595
  if (data.repeat) {
1583
1596
  drawImage = false;
1584
- } else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
1597
+ } else if (!(originPaint.changeful || paint.film || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
1585
1598
  drawImage = Platform.image.isLarge(image, scaleX, scaleY) || image.width * scaleX > 8096 || image.height * scaleY > 8096;
1586
1599
  }
1587
1600
  }
@@ -1599,20 +1612,21 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
1599
1612
  }
1600
1613
  }
1601
1614
 
1602
- function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
1603
- const {data: data, image: image} = paint, {blendMode: blendMode} = paint.originPaint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
1604
- let {width: width, height: height} = image, clipUI;
1605
- if ((clipUI = transform && !transform.onlyScale || u.path || u.cornerRadius) || opacity || blendMode) {
1615
+ function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions) {
1616
+ const {data: data, image: image, complex: complex} = paint;
1617
+ let {width: width, height: height} = image;
1618
+ if (complex) {
1619
+ const {blendMode: blendMode, opacity: opacity} = paint.originPaint, {transform: transform} = data;
1606
1620
  canvas.save();
1607
- clipUI && canvas.clipUI(ui);
1621
+ complex === 2 && canvas.clipUI(ui);
1608
1622
  blendMode && (canvas.blendMode = blendMode);
1609
1623
  opacity && (canvas.opacity *= opacity);
1610
1624
  transform && canvas.transform(transform);
1611
- canvas.drawImage(view, 0, 0, width, height);
1625
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
1612
1626
  canvas.restore();
1613
1627
  } else {
1614
1628
  if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
1615
- canvas.drawImage(view, 0, 0, width, height);
1629
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
1616
1630
  }
1617
1631
  }
1618
1632
 
@@ -2332,7 +2346,7 @@ function layoutText(drawData, style) {
2332
2346
  let {x: x, y: y, width: width, height: height} = bounds, realHeight = __lineHeight * countRows + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
2333
2347
  let starY = __baseLine;
2334
2348
  if (__clipText && realHeight > height) {
2335
- realHeight = Math.max(height, __lineHeight);
2349
+ realHeight = Math.max(style.__autoHeight ? realHeight : height, __lineHeight);
2336
2350
  if (countRows > 1) drawData.overflow = countRows;
2337
2351
  } else if (height || autoSizeAlign) {
2338
2352
  switch (verticalAlign) {
@@ -2389,10 +2403,10 @@ function layoutText(drawData, style) {
2389
2403
  }
2390
2404
 
2391
2405
  function clipText(drawData, style, x, width) {
2392
- if (!width) return;
2393
2406
  const {rows: rows, overflow: overflow} = drawData;
2394
2407
  let {textOverflow: textOverflow} = style;
2395
- rows.splice(overflow);
2408
+ if (overflow) rows.splice(overflow);
2409
+ if (!width) return;
2396
2410
  if (textOverflow && textOverflow !== "show") {
2397
2411
  if (textOverflow === "hide") textOverflow = ""; else if (textOverflow === "ellipsis") textOverflow = "...";
2398
2412
  let char, charRight;