@leafer-draw/miniapp 2.0.1 → 2.0.3

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) {
@@ -856,8 +863,8 @@ function fills(fills, ui, canvas, renderOptions) {
856
863
  canvas.save();
857
864
  if (item.transform) canvas.transform(item.transform);
858
865
  if (originPaint.scaleFixed) {
859
- const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
860
- if (originPaint.scaleFixed === true || originPaint.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
866
+ const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, originPaint.scaleFixed, false);
867
+ if (scaleX !== 1) canvas.scale(scaleX, scaleY);
861
868
  }
862
869
  if (originPaint.blendMode) canvas.blendMode = originPaint.blendMode;
863
870
  fillPathOrText(ui, canvas, renderOptions);
@@ -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,13 @@ 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
+ }
1288
+ if (paint.filter) draw.PaintImage.applyFilter(leafPaint, image, paint.filter, ui);
1273
1289
  return true;
1274
1290
  }
1275
1291
 
@@ -1312,7 +1328,7 @@ function getPatternData(paint, box, image) {
1312
1328
  if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
1313
1329
  if (paint.mode === "strench") paint.mode = "stretch";
1314
1330
  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;
1331
+ 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
1332
  const sameBox = box.width === width && box.height === height;
1317
1333
  const data = {
1318
1334
  mode: mode
@@ -1375,8 +1391,6 @@ function getPatternData(paint, box, image) {
1375
1391
  data.scaleX = scaleX;
1376
1392
  data.scaleY = scaleY;
1377
1393
  }
1378
- if (opacity && opacity < 1) data.opacity = opacity;
1379
- if (filters) data.filters = filters;
1380
1394
  if (repeat) data.repeat = core.isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
1381
1395
  if (interlace) data.interlace = core.isNumber(interlace) || interlace.type === "percent" ? {
1382
1396
  type: "x",
@@ -1407,7 +1421,7 @@ const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translat
1407
1421
 
1408
1422
  function stretchMode(data, box, scaleX, scaleY) {
1409
1423
  const transform = get$2(), {x: x, y: y} = box;
1410
- if (x || y) translate(transform, x, y); else transform.onlyScale = true;
1424
+ if (x || y) translate(transform, x, y); else if (scaleX > 0 && scaleY > 0) transform.onlyScale = true;
1411
1425
  scaleHelper(transform, scaleX, scaleY);
1412
1426
  data.transform = transform;
1413
1427
  }
@@ -1529,10 +1543,10 @@ function createPatternTask(paint, ui, canvas, renderOptions) {
1529
1543
  }
1530
1544
 
1531
1545
  function createPattern(paint, ui, canvas, renderOptions) {
1532
- let {scaleX: scaleX, scaleY: scaleY} = draw.PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
1546
+ let {scaleX: scaleX, scaleY: scaleY} = draw.PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
1533
1547
  if (paint.patternId !== id && !ui.destroyed) {
1534
1548
  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);
1549
+ const {image: image, data: data} = paint, {opacity: opacity} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = draw.PaintImage.getPatternFixScale(paint, scaleX, scaleY);
1536
1550
  let imageMatrix, xGap, yGap, {width: width, height: height} = image;
1537
1551
  if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
1538
1552
  width *= scaleX;
@@ -1548,7 +1562,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
1548
1562
  if (transform) copy$1(imageMatrix, transform);
1549
1563
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
1550
1564
  }
1551
- const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
1565
+ const imageCanvas = image.getCanvas(width, height, opacity, undefined, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
1552
1566
  const pattern = image.getPattern(imageCanvas, data.repeat || (core.Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
1553
1567
  paint.style = pattern;
1554
1568
  paint.patternId = id;
@@ -1569,15 +1583,15 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
1569
1583
  }
1570
1584
 
1571
1585
  function checkImage(paint, drawImage, ui, canvas, renderOptions) {
1572
- const {scaleX: scaleX, scaleY: scaleY} = draw.PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
1586
+ const {scaleX: scaleX, scaleY: scaleY} = draw.PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
1573
1587
  const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
1574
- if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting || snapshot) {
1588
+ if (!data || paint.patternId === id && !exporting || snapshot) {
1575
1589
  return false;
1576
1590
  } else {
1577
1591
  if (drawImage) {
1578
1592
  if (data.repeat) {
1579
1593
  drawImage = false;
1580
- } else if (!(originPaint.changeful || core.Platform.name === "miniapp" && core.ResizeEvent.isResizing(ui) || exporting)) {
1594
+ } else if (!(originPaint.changeful || paint.film || core.Platform.name === "miniapp" && core.ResizeEvent.isResizing(ui) || exporting)) {
1581
1595
  drawImage = core.Platform.image.isLarge(image, scaleX, scaleY) || image.width * scaleX > 8096 || image.height * scaleY > 8096;
1582
1596
  }
1583
1597
  }
@@ -1595,20 +1609,21 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
1595
1609
  }
1596
1610
  }
1597
1611
 
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) {
1612
+ function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions) {
1613
+ const {data: data, image: image, complex: complex} = paint;
1614
+ let {width: width, height: height} = image;
1615
+ if (complex) {
1616
+ const {blendMode: blendMode, opacity: opacity} = paint.originPaint, {transform: transform} = data;
1602
1617
  canvas.save();
1603
- clipUI && canvas.clipUI(ui);
1618
+ complex === 2 && canvas.clipUI(ui);
1604
1619
  blendMode && (canvas.blendMode = blendMode);
1605
1620
  opacity && (canvas.opacity *= opacity);
1606
1621
  transform && canvas.transform(transform);
1607
- canvas.drawImage(view, 0, 0, width, height);
1622
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
1608
1623
  canvas.restore();
1609
1624
  } else {
1610
1625
  if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
1611
- canvas.drawImage(view, 0, 0, width, height);
1626
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
1612
1627
  }
1613
1628
  }
1614
1629
 
@@ -1638,6 +1653,7 @@ function recycleImage(attrName, data) {
1638
1653
  if (!recycleMap) recycleMap = {};
1639
1654
  recycleMap[url] = true;
1640
1655
  core.ImageManager.recyclePaint(paint);
1656
+ if (data.__willDestroy && image.parent) draw.PaintImage.recycleFilter(image, data.__leaf);
1641
1657
  if (image.loading) {
1642
1658
  if (!input) {
1643
1659
  input = data.__input && data.__input[attrName] || [];
@@ -2549,6 +2565,13 @@ try {
2549
2565
  if (wx) useCanvas("miniapp", wx);
2550
2566
  } catch (_a) {}
2551
2567
 
2568
+ Object.defineProperty(exports, "LeaferFilm", {
2569
+ enumerable: true,
2570
+ get: function() {
2571
+ return core.LeaferFilm;
2572
+ }
2573
+ });
2574
+
2552
2575
  Object.defineProperty(exports, "LeaferImage", {
2553
2576
  enumerable: true,
2554
2577
  get: function() {
@@ -2556,6 +2579,13 @@ Object.defineProperty(exports, "LeaferImage", {
2556
2579
  }
2557
2580
  });
2558
2581
 
2582
+ Object.defineProperty(exports, "LeaferVideo", {
2583
+ enumerable: true,
2584
+ get: function() {
2585
+ return core.LeaferVideo;
2586
+ }
2587
+ });
2588
+
2559
2589
  exports.Layouter = Layouter;
2560
2590
 
2561
2591
  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) {
@@ -860,8 +867,8 @@ function fills(fills, ui, canvas, renderOptions) {
860
867
  canvas.save();
861
868
  if (item.transform) canvas.transform(item.transform);
862
869
  if (originPaint.scaleFixed) {
863
- const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
864
- if (originPaint.scaleFixed === true || originPaint.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
870
+ const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, originPaint.scaleFixed, false);
871
+ if (scaleX !== 1) canvas.scale(scaleX, scaleY);
865
872
  }
866
873
  if (originPaint.blendMode) canvas.blendMode = originPaint.blendMode;
867
874
  fillPathOrText(ui, canvas, renderOptions);
@@ -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,13 @@ 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
+ }
1292
+ if (paint.filter) PaintImage.applyFilter(leafPaint, image, paint.filter, ui);
1277
1293
  return true;
1278
1294
  }
1279
1295
 
@@ -1316,7 +1332,7 @@ function getPatternData(paint, box, image) {
1316
1332
  if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
1317
1333
  if (paint.mode === "strench") paint.mode = "stretch";
1318
1334
  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;
1335
+ 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
1336
  const sameBox = box.width === width && box.height === height;
1321
1337
  const data = {
1322
1338
  mode: mode
@@ -1379,8 +1395,6 @@ function getPatternData(paint, box, image) {
1379
1395
  data.scaleX = scaleX;
1380
1396
  data.scaleY = scaleY;
1381
1397
  }
1382
- if (opacity && opacity < 1) data.opacity = opacity;
1383
- if (filters) data.filters = filters;
1384
1398
  if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
1385
1399
  if (interlace) data.interlace = isNumber(interlace) || interlace.type === "percent" ? {
1386
1400
  type: "x",
@@ -1411,7 +1425,7 @@ const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translat
1411
1425
 
1412
1426
  function stretchMode(data, box, scaleX, scaleY) {
1413
1427
  const transform = get$2(), {x: x, y: y} = box;
1414
- if (x || y) translate(transform, x, y); else transform.onlyScale = true;
1428
+ if (x || y) translate(transform, x, y); else if (scaleX > 0 && scaleY > 0) transform.onlyScale = true;
1415
1429
  scaleHelper(transform, scaleX, scaleY);
1416
1430
  data.transform = transform;
1417
1431
  }
@@ -1533,10 +1547,10 @@ function createPatternTask(paint, ui, canvas, renderOptions) {
1533
1547
  }
1534
1548
 
1535
1549
  function createPattern(paint, ui, canvas, renderOptions) {
1536
- let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
1550
+ let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
1537
1551
  if (paint.patternId !== id && !ui.destroyed) {
1538
1552
  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);
1553
+ const {image: image, data: data} = paint, {opacity: opacity} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
1540
1554
  let imageMatrix, xGap, yGap, {width: width, height: height} = image;
1541
1555
  if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
1542
1556
  width *= scaleX;
@@ -1552,7 +1566,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
1552
1566
  if (transform) copy$1(imageMatrix, transform);
1553
1567
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
1554
1568
  }
1555
- const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
1569
+ const imageCanvas = image.getCanvas(width, height, opacity, undefined, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
1556
1570
  const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
1557
1571
  paint.style = pattern;
1558
1572
  paint.patternId = id;
@@ -1573,15 +1587,15 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
1573
1587
  }
1574
1588
 
1575
1589
  function checkImage(paint, drawImage, ui, canvas, renderOptions) {
1576
- const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
1590
+ const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
1577
1591
  const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
1578
- if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting || snapshot) {
1592
+ if (!data || paint.patternId === id && !exporting || snapshot) {
1579
1593
  return false;
1580
1594
  } else {
1581
1595
  if (drawImage) {
1582
1596
  if (data.repeat) {
1583
1597
  drawImage = false;
1584
- } else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
1598
+ } else if (!(originPaint.changeful || paint.film || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
1585
1599
  drawImage = Platform.image.isLarge(image, scaleX, scaleY) || image.width * scaleX > 8096 || image.height * scaleY > 8096;
1586
1600
  }
1587
1601
  }
@@ -1599,20 +1613,21 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
1599
1613
  }
1600
1614
  }
1601
1615
 
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) {
1616
+ function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions) {
1617
+ const {data: data, image: image, complex: complex} = paint;
1618
+ let {width: width, height: height} = image;
1619
+ if (complex) {
1620
+ const {blendMode: blendMode, opacity: opacity} = paint.originPaint, {transform: transform} = data;
1606
1621
  canvas.save();
1607
- clipUI && canvas.clipUI(ui);
1622
+ complex === 2 && canvas.clipUI(ui);
1608
1623
  blendMode && (canvas.blendMode = blendMode);
1609
1624
  opacity && (canvas.opacity *= opacity);
1610
1625
  transform && canvas.transform(transform);
1611
- canvas.drawImage(view, 0, 0, width, height);
1626
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
1612
1627
  canvas.restore();
1613
1628
  } else {
1614
1629
  if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
1615
- canvas.drawImage(view, 0, 0, width, height);
1630
+ image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
1616
1631
  }
1617
1632
  }
1618
1633
 
@@ -1642,6 +1657,7 @@ function recycleImage(attrName, data) {
1642
1657
  if (!recycleMap) recycleMap = {};
1643
1658
  recycleMap[url] = true;
1644
1659
  ImageManager.recyclePaint(paint);
1660
+ if (data.__willDestroy && image.parent) PaintImage.recycleFilter(image, data.__leaf);
1645
1661
  if (image.loading) {
1646
1662
  if (!input) {
1647
1663
  input = data.__input && data.__input[attrName] || [];