leafer-ui 1.9.4 → 1.9.6

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/web.cjs CHANGED
@@ -95,10 +95,22 @@ class LeaferCanvas extends core.LeaferCanvasBase {
95
95
  updateViewSize() {
96
96
  const {width: width, height: height, pixelRatio: pixelRatio} = this;
97
97
  const {style: style} = this.view;
98
- style.width = width + "px";
99
- style.height = height + "px";
100
- this.view.width = Math.ceil(width * pixelRatio);
101
- this.view.height = Math.ceil(height * pixelRatio);
98
+ if (this.unreal) {
99
+ const {config: config, autoWidthStr: autoWidthStr, autoHeightStr: autoHeightStr} = this;
100
+ if (config.width) {
101
+ if (core.isUndefined(autoWidthStr)) this.autoWidthStr = style.width || "";
102
+ style.width = config.width + "px";
103
+ } else if (!core.isUndefined(autoWidthStr)) style.width = autoWidthStr;
104
+ if (config.height) {
105
+ if (core.isUndefined(autoHeightStr)) this.autoHeightStr = style.height || "";
106
+ style.height = config.height + "px";
107
+ } else if (!core.isUndefined(autoHeightStr)) style.height = autoHeightStr;
108
+ } else {
109
+ style.width = width + "px";
110
+ style.height = height + "px";
111
+ this.view.width = Math.ceil(width * pixelRatio);
112
+ this.view.height = Math.ceil(height * pixelRatio);
113
+ }
102
114
  }
103
115
  updateClientBounds() {
104
116
  if (this.view.parentElement) this.clientBounds = this.view.getBoundingClientRect();
@@ -107,6 +119,7 @@ class LeaferCanvas extends core.LeaferCanvasBase {
107
119
  this.resizeListener = listener;
108
120
  if (autoBounds) {
109
121
  this.autoBounds = autoBounds;
122
+ if (this.resizeObserver) return;
110
123
  try {
111
124
  this.resizeObserver = new ResizeObserver(entries => {
112
125
  this.updateClientBounds();
@@ -123,18 +136,10 @@ class LeaferCanvas extends core.LeaferCanvasBase {
123
136
  } catch (_a) {
124
137
  this.imitateResizeObserver();
125
138
  }
139
+ this.stopListenPixelRatio();
126
140
  } else {
127
- window.addEventListener("resize", this.windowListener = () => {
128
- const pixelRatio = core.Platform.devicePixelRatio;
129
- if (!this.config.pixelRatio && this.pixelRatio !== pixelRatio) {
130
- const {width: width, height: height} = this;
131
- this.emitResize({
132
- width: width,
133
- height: height,
134
- pixelRatio: pixelRatio
135
- });
136
- }
137
- });
141
+ this.listenPixelRatio();
142
+ if (this.unreal) this.updateViewSize();
138
143
  }
139
144
  }
140
145
  imitateResizeObserver() {
@@ -143,6 +148,25 @@ class LeaferCanvas extends core.LeaferCanvasBase {
143
148
  core.Platform.requestRender(this.imitateResizeObserver.bind(this));
144
149
  }
145
150
  }
151
+ listenPixelRatio() {
152
+ if (!this.windowListener) window.addEventListener("resize", this.windowListener = () => {
153
+ const pixelRatio = core.Platform.devicePixelRatio;
154
+ if (!this.config.pixelRatio && this.pixelRatio !== pixelRatio) {
155
+ const {width: width, height: height} = this;
156
+ this.emitResize({
157
+ width: width,
158
+ height: height,
159
+ pixelRatio: pixelRatio
160
+ });
161
+ }
162
+ });
163
+ }
164
+ stopListenPixelRatio() {
165
+ if (this.windowListener) {
166
+ window.removeEventListener("resize", this.windowListener);
167
+ this.windowListener = null;
168
+ }
169
+ }
146
170
  checkAutoBounds(parentSize) {
147
171
  const view = this.view;
148
172
  const {x: x, y: y, width: width, height: height} = this.autoBounds.getBoundsFrom(parentSize);
@@ -180,10 +204,7 @@ class LeaferCanvas extends core.LeaferCanvasBase {
180
204
  destroy() {
181
205
  if (this.view) {
182
206
  this.stopAutoLayout();
183
- if (this.windowListener) {
184
- window.removeEventListener("resize", this.windowListener);
185
- this.windowListener = null;
186
- }
207
+ this.stopListenPixelRatio();
187
208
  if (!this.unreal) {
188
209
  const view = this.view;
189
210
  if (view.parentElement) view.remove();
@@ -612,7 +633,7 @@ class Renderer {
612
633
  this.times = 0;
613
634
  this.config = {
614
635
  usePartRender: true,
615
- maxFPS: 60
636
+ maxFPS: 120
616
637
  };
617
638
  this.target = target;
618
639
  this.canvas = canvas;
@@ -767,11 +788,15 @@ class Renderer {
767
788
  if (this.requestTime || !target) return;
768
789
  if (target.parentApp) return target.parentApp.requestRender(false);
769
790
  const requestTime = this.requestTime = Date.now();
770
- core.Platform.requestRender(() => {
771
- this.FPS = Math.min(60, Math.ceil(1e3 / (Date.now() - requestTime)));
791
+ const render = () => {
792
+ const nowFPS = 1e3 / (Date.now() - requestTime);
793
+ const {maxFPS: maxFPS} = this.config;
794
+ if (maxFPS && nowFPS > maxFPS - .5) return core.Platform.requestRender(render);
795
+ this.FPS = Math.min(120, Math.ceil(nowFPS));
772
796
  this.requestTime = 0;
773
797
  this.checkRender();
774
- });
798
+ };
799
+ core.Platform.requestRender(render);
775
800
  }
776
801
  __onResize(e) {
777
802
  if (this.canvas.unreal) return;
@@ -814,7 +839,8 @@ class Renderer {
814
839
  if (this.target) {
815
840
  this.stop();
816
841
  this.__removeListenEvents();
817
- this.target = this.canvas = this.config = null;
842
+ this.config = {};
843
+ this.target = this.canvas = null;
818
844
  }
819
845
  }
820
846
  }
@@ -910,7 +936,7 @@ class Picker {
910
936
  item = path.list[i];
911
937
  if (!item.__.hittable) break;
912
938
  hittablePath.addAt(item, 0);
913
- if (!item.__.hitChildren) break;
939
+ if (!item.__.hitChildren || item.isLeafer && item.mode === "draw") break;
914
940
  }
915
941
  return hittablePath;
916
942
  }
@@ -1016,10 +1042,10 @@ core.Platform.layout = Layouter.fullLayout;
1016
1042
 
1017
1043
  const PointerEventHelper = {
1018
1044
  convert(e, local) {
1019
- const base = core$1.InteractionHelper.getBase(e);
1045
+ const base = core$1.InteractionHelper.getBase(e), {x: x, y: y} = local;
1020
1046
  const data = Object.assign(Object.assign({}, base), {
1021
- x: local.x,
1022
- y: local.y,
1047
+ x: x,
1048
+ y: y,
1023
1049
  width: e.width,
1024
1050
  height: e.height,
1025
1051
  pointerType: e.pointerType,
@@ -1034,10 +1060,10 @@ const PointerEventHelper = {
1034
1060
  return data;
1035
1061
  },
1036
1062
  convertMouse(e, local) {
1037
- const base = core$1.InteractionHelper.getBase(e);
1063
+ const base = core$1.InteractionHelper.getBase(e), {x: x, y: y} = local;
1038
1064
  return Object.assign(Object.assign({}, base), {
1039
- x: local.x,
1040
- y: local.y,
1065
+ x: x,
1066
+ y: y,
1041
1067
  width: 1,
1042
1068
  height: 1,
1043
1069
  pointerType: "mouse",
@@ -1046,10 +1072,10 @@ const PointerEventHelper = {
1046
1072
  },
1047
1073
  convertTouch(e, local) {
1048
1074
  const touch = PointerEventHelper.getTouch(e);
1049
- const base = core$1.InteractionHelper.getBase(e);
1075
+ const base = core$1.InteractionHelper.getBase(e), {x: x, y: y} = local;
1050
1076
  return Object.assign(Object.assign({}, base), {
1051
- x: local.x,
1052
- y: local.y,
1077
+ x: x,
1078
+ y: y,
1053
1079
  width: 1,
1054
1080
  height: 1,
1055
1081
  pointerType: "touch",
@@ -1964,7 +1990,7 @@ function ignoreRender(ui, value) {
1964
1990
 
1965
1991
  const {get: get$1, scale: scale, copy: copy$1} = core.MatrixHelper;
1966
1992
 
1967
- const {floor: floor, max: max, abs: abs} = Math;
1993
+ const {floor: floor, ceil: ceil, max: max, abs: abs} = Math;
1968
1994
 
1969
1995
  function createPattern(ui, paint, pixelRatio) {
1970
1996
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
@@ -1974,8 +2000,6 @@ function createPattern(ui, paint, pixelRatio) {
1974
2000
  let imageScale, imageMatrix, {width: width, height: height, scaleX: sx, scaleY: sy, transform: transform, repeat: repeat, gap: gap} = data;
1975
2001
  scaleX *= pixelRatio;
1976
2002
  scaleY *= pixelRatio;
1977
- const xGap = gap && gap.x * scaleX;
1978
- const yGap = gap && gap.y * scaleY;
1979
2003
  if (sx) {
1980
2004
  sx = abs(sx);
1981
2005
  sy = abs(sy);
@@ -1992,7 +2016,10 @@ function createPattern(ui, paint, pixelRatio) {
1992
2016
  if (size > core.Platform.image.maxCacheSize) return false;
1993
2017
  }
1994
2018
  let maxSize = core.Platform.image.maxPatternSize;
1995
- if (!image.isSVG) {
2019
+ if (image.isSVG) {
2020
+ const ws = width / image.width;
2021
+ if (ws > 1) imageScale = ws / ceil(ws);
2022
+ } else {
1996
2023
  const imageSize = image.width * image.height;
1997
2024
  if (maxSize > imageSize) maxSize = imageSize;
1998
2025
  }
@@ -2007,18 +2034,20 @@ function createPattern(ui, paint, pixelRatio) {
2007
2034
  scaleX /= sx;
2008
2035
  scaleY /= sy;
2009
2036
  }
2037
+ const xGap = gap && gap.x * scaleX;
2038
+ const yGap = gap && gap.y * scaleY;
2010
2039
  if (transform || scaleX !== 1 || scaleY !== 1) {
2040
+ const canvasWidth = width + (xGap || 0);
2041
+ const canvasHeight = height + (yGap || 0);
2042
+ scaleX /= canvasWidth / max(floor(canvasWidth), 1);
2043
+ scaleY /= canvasHeight / max(floor(canvasHeight), 1);
2011
2044
  if (!imageMatrix) {
2012
2045
  imageMatrix = get$1();
2013
2046
  if (transform) copy$1(imageMatrix, transform);
2014
2047
  }
2015
2048
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
2016
2049
  }
2017
- if (imageMatrix) {
2018
- const canvasWidth = width + (xGap || 0), canvasHeight = height + (yGap || 0);
2019
- scale(imageMatrix, canvasWidth / max(floor(canvasWidth), 1), canvasHeight / max(floor(canvasHeight), 1));
2020
- }
2021
- const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap);
2050
+ const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
2022
2051
  const pattern = image.getPattern(canvas, repeat || (core.Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
2023
2052
  paint.style = pattern;
2024
2053
  paint.patternId = id;
@@ -2293,12 +2322,18 @@ function shadow(ui, current, shape) {
2293
2322
  }
2294
2323
  worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, "destination-out") : other.copyWorld(shape.canvas, shapeBounds, bounds, "destination-out");
2295
2324
  }
2296
- core.LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
2325
+ if (draw.Effect.isTransformShadow(item)) draw.Effect.renderTransformShadow(ui, current, other, copyBounds, item); else core.LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
2297
2326
  if (end && index < end) other.clearWorld(copyBounds);
2298
2327
  });
2299
2328
  other.recycle(copyBounds);
2300
2329
  }
2301
2330
 
2331
+ function getShadowSpread(_ui, shadow) {
2332
+ let width = 0;
2333
+ shadow.forEach(item => width = Math.max(width, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread > 0 ? item.spread : 0) + item.blur * 1.5));
2334
+ return width;
2335
+ }
2336
+
2302
2337
  function drawWorldShadow(canvas, outBounds, spreadScale, shape) {
2303
2338
  const {bounds: bounds, shapeBounds: shapeBounds} = shape;
2304
2339
  if (core.Platform.fullImageShadow) {
@@ -2376,7 +2411,11 @@ const EffectModule = {
2376
2411
  shadow: shadow,
2377
2412
  innerShadow: innerShadow,
2378
2413
  blur: blur,
2379
- backgroundBlur: backgroundBlur
2414
+ backgroundBlur: backgroundBlur,
2415
+ getShadowSpread: getShadowSpread,
2416
+ isTransformShadow(_shadow) {
2417
+ return undefined;
2418
+ }
2380
2419
  };
2381
2420
 
2382
2421
  const {excludeRenderBounds: excludeRenderBounds} = core.LeafBoundsHelper;
@@ -2884,16 +2923,17 @@ function toTextChar(row) {
2884
2923
  }
2885
2924
 
2886
2925
  function decorationText(drawData, style) {
2887
- let type;
2926
+ let type, offset = 0;
2888
2927
  const {fontSize: fontSize, textDecoration: textDecoration} = style;
2889
2928
  drawData.decorationHeight = fontSize / 11;
2890
2929
  if (core.isObject(textDecoration)) {
2891
2930
  type = textDecoration.type;
2892
2931
  if (textDecoration.color) drawData.decorationColor = draw.ColorConvert.string(textDecoration.color);
2932
+ if (textDecoration.offset) offset = Math.min(fontSize * .3, Math.max(textDecoration.offset, -fontSize * .15));
2893
2933
  } else type = textDecoration;
2894
2934
  switch (type) {
2895
2935
  case "under":
2896
- drawData.decorationY = [ fontSize * .15 ];
2936
+ drawData.decorationY = [ fontSize * .15 + offset ];
2897
2937
  break;
2898
2938
 
2899
2939
  case "delete":
@@ -2901,7 +2941,7 @@ function decorationText(drawData, style) {
2901
2941
  break;
2902
2942
 
2903
2943
  case "under-delete":
2904
- drawData.decorationY = [ fontSize * .15, -fontSize * .35 ];
2944
+ drawData.decorationY = [ fontSize * .15 + offset, -fontSize * .35 ];
2905
2945
  }
2906
2946
  }
2907
2947
 
package/dist/web.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Debug, LeaferCanvasBase, Platform, isString, DataHelper, canvasSizeAttrs, isUndefined, ResizeEvent, canvasPatch, FileHelper, Creator, LeaferImage, defineKey, LeafList, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, isArray, LeafLevelList, LayoutEvent, Run, ImageManager, BoundsHelper, Plugin, MathHelper, isObject, Matrix, getMatrixData, MatrixHelper, AlignHelper, PointHelper, ImageEvent, AroundHelper, Direction4, isNumber } from "@leafer/core";
1
+ import { Debug, LeaferCanvasBase, Platform, isString, isUndefined, DataHelper, canvasSizeAttrs, ResizeEvent, canvasPatch, FileHelper, Creator, LeaferImage, defineKey, LeafList, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, isArray, LeafLevelList, LayoutEvent, Run, ImageManager, BoundsHelper, Plugin, MathHelper, isObject, Matrix, getMatrixData, MatrixHelper, AlignHelper, PointHelper, ImageEvent, AroundHelper, Direction4, isNumber } from "@leafer/core";
2
2
 
3
3
  export * from "@leafer/core";
4
4
 
@@ -8,7 +8,7 @@ import { InteractionHelper, InteractionBase, Cursor, HitCanvasManager } from "@l
8
8
 
9
9
  export * from "@leafer-ui/core";
10
10
 
11
- import { PaintImage, Paint, ColorConvert, PaintGradient, Export, Group, TextConvert, Effect } from "@leafer-ui/draw";
11
+ import { PaintImage, Paint, ColorConvert, PaintGradient, Export, Effect, Group, TextConvert } from "@leafer-ui/draw";
12
12
 
13
13
  const debug$2 = Debug.get("LeaferCanvas");
14
14
 
@@ -99,10 +99,22 @@ class LeaferCanvas extends LeaferCanvasBase {
99
99
  updateViewSize() {
100
100
  const {width: width, height: height, pixelRatio: pixelRatio} = this;
101
101
  const {style: style} = this.view;
102
- style.width = width + "px";
103
- style.height = height + "px";
104
- this.view.width = Math.ceil(width * pixelRatio);
105
- this.view.height = Math.ceil(height * pixelRatio);
102
+ if (this.unreal) {
103
+ const {config: config, autoWidthStr: autoWidthStr, autoHeightStr: autoHeightStr} = this;
104
+ if (config.width) {
105
+ if (isUndefined(autoWidthStr)) this.autoWidthStr = style.width || "";
106
+ style.width = config.width + "px";
107
+ } else if (!isUndefined(autoWidthStr)) style.width = autoWidthStr;
108
+ if (config.height) {
109
+ if (isUndefined(autoHeightStr)) this.autoHeightStr = style.height || "";
110
+ style.height = config.height + "px";
111
+ } else if (!isUndefined(autoHeightStr)) style.height = autoHeightStr;
112
+ } else {
113
+ style.width = width + "px";
114
+ style.height = height + "px";
115
+ this.view.width = Math.ceil(width * pixelRatio);
116
+ this.view.height = Math.ceil(height * pixelRatio);
117
+ }
106
118
  }
107
119
  updateClientBounds() {
108
120
  if (this.view.parentElement) this.clientBounds = this.view.getBoundingClientRect();
@@ -111,6 +123,7 @@ class LeaferCanvas extends LeaferCanvasBase {
111
123
  this.resizeListener = listener;
112
124
  if (autoBounds) {
113
125
  this.autoBounds = autoBounds;
126
+ if (this.resizeObserver) return;
114
127
  try {
115
128
  this.resizeObserver = new ResizeObserver(entries => {
116
129
  this.updateClientBounds();
@@ -127,18 +140,10 @@ class LeaferCanvas extends LeaferCanvasBase {
127
140
  } catch (_a) {
128
141
  this.imitateResizeObserver();
129
142
  }
143
+ this.stopListenPixelRatio();
130
144
  } else {
131
- window.addEventListener("resize", this.windowListener = () => {
132
- const pixelRatio = Platform.devicePixelRatio;
133
- if (!this.config.pixelRatio && this.pixelRatio !== pixelRatio) {
134
- const {width: width, height: height} = this;
135
- this.emitResize({
136
- width: width,
137
- height: height,
138
- pixelRatio: pixelRatio
139
- });
140
- }
141
- });
145
+ this.listenPixelRatio();
146
+ if (this.unreal) this.updateViewSize();
142
147
  }
143
148
  }
144
149
  imitateResizeObserver() {
@@ -147,6 +152,25 @@ class LeaferCanvas extends LeaferCanvasBase {
147
152
  Platform.requestRender(this.imitateResizeObserver.bind(this));
148
153
  }
149
154
  }
155
+ listenPixelRatio() {
156
+ if (!this.windowListener) window.addEventListener("resize", this.windowListener = () => {
157
+ const pixelRatio = Platform.devicePixelRatio;
158
+ if (!this.config.pixelRatio && this.pixelRatio !== pixelRatio) {
159
+ const {width: width, height: height} = this;
160
+ this.emitResize({
161
+ width: width,
162
+ height: height,
163
+ pixelRatio: pixelRatio
164
+ });
165
+ }
166
+ });
167
+ }
168
+ stopListenPixelRatio() {
169
+ if (this.windowListener) {
170
+ window.removeEventListener("resize", this.windowListener);
171
+ this.windowListener = null;
172
+ }
173
+ }
150
174
  checkAutoBounds(parentSize) {
151
175
  const view = this.view;
152
176
  const {x: x, y: y, width: width, height: height} = this.autoBounds.getBoundsFrom(parentSize);
@@ -184,10 +208,7 @@ class LeaferCanvas extends LeaferCanvasBase {
184
208
  destroy() {
185
209
  if (this.view) {
186
210
  this.stopAutoLayout();
187
- if (this.windowListener) {
188
- window.removeEventListener("resize", this.windowListener);
189
- this.windowListener = null;
190
- }
211
+ this.stopListenPixelRatio();
191
212
  if (!this.unreal) {
192
213
  const view = this.view;
193
214
  if (view.parentElement) view.remove();
@@ -616,7 +637,7 @@ class Renderer {
616
637
  this.times = 0;
617
638
  this.config = {
618
639
  usePartRender: true,
619
- maxFPS: 60
640
+ maxFPS: 120
620
641
  };
621
642
  this.target = target;
622
643
  this.canvas = canvas;
@@ -771,11 +792,15 @@ class Renderer {
771
792
  if (this.requestTime || !target) return;
772
793
  if (target.parentApp) return target.parentApp.requestRender(false);
773
794
  const requestTime = this.requestTime = Date.now();
774
- Platform.requestRender(() => {
775
- this.FPS = Math.min(60, Math.ceil(1e3 / (Date.now() - requestTime)));
795
+ const render = () => {
796
+ const nowFPS = 1e3 / (Date.now() - requestTime);
797
+ const {maxFPS: maxFPS} = this.config;
798
+ if (maxFPS && nowFPS > maxFPS - .5) return Platform.requestRender(render);
799
+ this.FPS = Math.min(120, Math.ceil(nowFPS));
776
800
  this.requestTime = 0;
777
801
  this.checkRender();
778
- });
802
+ };
803
+ Platform.requestRender(render);
779
804
  }
780
805
  __onResize(e) {
781
806
  if (this.canvas.unreal) return;
@@ -818,7 +843,8 @@ class Renderer {
818
843
  if (this.target) {
819
844
  this.stop();
820
845
  this.__removeListenEvents();
821
- this.target = this.canvas = this.config = null;
846
+ this.config = {};
847
+ this.target = this.canvas = null;
822
848
  }
823
849
  }
824
850
  }
@@ -914,7 +940,7 @@ class Picker {
914
940
  item = path.list[i];
915
941
  if (!item.__.hittable) break;
916
942
  hittablePath.addAt(item, 0);
917
- if (!item.__.hitChildren) break;
943
+ if (!item.__.hitChildren || item.isLeafer && item.mode === "draw") break;
918
944
  }
919
945
  return hittablePath;
920
946
  }
@@ -1020,10 +1046,10 @@ Platform.layout = Layouter.fullLayout;
1020
1046
 
1021
1047
  const PointerEventHelper = {
1022
1048
  convert(e, local) {
1023
- const base = InteractionHelper.getBase(e);
1049
+ const base = InteractionHelper.getBase(e), {x: x, y: y} = local;
1024
1050
  const data = Object.assign(Object.assign({}, base), {
1025
- x: local.x,
1026
- y: local.y,
1051
+ x: x,
1052
+ y: y,
1027
1053
  width: e.width,
1028
1054
  height: e.height,
1029
1055
  pointerType: e.pointerType,
@@ -1038,10 +1064,10 @@ const PointerEventHelper = {
1038
1064
  return data;
1039
1065
  },
1040
1066
  convertMouse(e, local) {
1041
- const base = InteractionHelper.getBase(e);
1067
+ const base = InteractionHelper.getBase(e), {x: x, y: y} = local;
1042
1068
  return Object.assign(Object.assign({}, base), {
1043
- x: local.x,
1044
- y: local.y,
1069
+ x: x,
1070
+ y: y,
1045
1071
  width: 1,
1046
1072
  height: 1,
1047
1073
  pointerType: "mouse",
@@ -1050,10 +1076,10 @@ const PointerEventHelper = {
1050
1076
  },
1051
1077
  convertTouch(e, local) {
1052
1078
  const touch = PointerEventHelper.getTouch(e);
1053
- const base = InteractionHelper.getBase(e);
1079
+ const base = InteractionHelper.getBase(e), {x: x, y: y} = local;
1054
1080
  return Object.assign(Object.assign({}, base), {
1055
- x: local.x,
1056
- y: local.y,
1081
+ x: x,
1082
+ y: y,
1057
1083
  width: 1,
1058
1084
  height: 1,
1059
1085
  pointerType: "touch",
@@ -1968,7 +1994,7 @@ function ignoreRender(ui, value) {
1968
1994
 
1969
1995
  const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
1970
1996
 
1971
- const {floor: floor, max: max, abs: abs} = Math;
1997
+ const {floor: floor, ceil: ceil, max: max, abs: abs} = Math;
1972
1998
 
1973
1999
  function createPattern(ui, paint, pixelRatio) {
1974
2000
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
@@ -1978,8 +2004,6 @@ function createPattern(ui, paint, pixelRatio) {
1978
2004
  let imageScale, imageMatrix, {width: width, height: height, scaleX: sx, scaleY: sy, transform: transform, repeat: repeat, gap: gap} = data;
1979
2005
  scaleX *= pixelRatio;
1980
2006
  scaleY *= pixelRatio;
1981
- const xGap = gap && gap.x * scaleX;
1982
- const yGap = gap && gap.y * scaleY;
1983
2007
  if (sx) {
1984
2008
  sx = abs(sx);
1985
2009
  sy = abs(sy);
@@ -1996,7 +2020,10 @@ function createPattern(ui, paint, pixelRatio) {
1996
2020
  if (size > Platform.image.maxCacheSize) return false;
1997
2021
  }
1998
2022
  let maxSize = Platform.image.maxPatternSize;
1999
- if (!image.isSVG) {
2023
+ if (image.isSVG) {
2024
+ const ws = width / image.width;
2025
+ if (ws > 1) imageScale = ws / ceil(ws);
2026
+ } else {
2000
2027
  const imageSize = image.width * image.height;
2001
2028
  if (maxSize > imageSize) maxSize = imageSize;
2002
2029
  }
@@ -2011,18 +2038,20 @@ function createPattern(ui, paint, pixelRatio) {
2011
2038
  scaleX /= sx;
2012
2039
  scaleY /= sy;
2013
2040
  }
2041
+ const xGap = gap && gap.x * scaleX;
2042
+ const yGap = gap && gap.y * scaleY;
2014
2043
  if (transform || scaleX !== 1 || scaleY !== 1) {
2044
+ const canvasWidth = width + (xGap || 0);
2045
+ const canvasHeight = height + (yGap || 0);
2046
+ scaleX /= canvasWidth / max(floor(canvasWidth), 1);
2047
+ scaleY /= canvasHeight / max(floor(canvasHeight), 1);
2015
2048
  if (!imageMatrix) {
2016
2049
  imageMatrix = get$1();
2017
2050
  if (transform) copy$1(imageMatrix, transform);
2018
2051
  }
2019
2052
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
2020
2053
  }
2021
- if (imageMatrix) {
2022
- const canvasWidth = width + (xGap || 0), canvasHeight = height + (yGap || 0);
2023
- scale(imageMatrix, canvasWidth / max(floor(canvasWidth), 1), canvasHeight / max(floor(canvasHeight), 1));
2024
- }
2025
- const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap);
2054
+ const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
2026
2055
  const pattern = image.getPattern(canvas, repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
2027
2056
  paint.style = pattern;
2028
2057
  paint.patternId = id;
@@ -2297,12 +2326,18 @@ function shadow(ui, current, shape) {
2297
2326
  }
2298
2327
  worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, "destination-out") : other.copyWorld(shape.canvas, shapeBounds, bounds, "destination-out");
2299
2328
  }
2300
- LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
2329
+ if (Effect.isTransformShadow(item)) Effect.renderTransformShadow(ui, current, other, copyBounds, item); else LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
2301
2330
  if (end && index < end) other.clearWorld(copyBounds);
2302
2331
  });
2303
2332
  other.recycle(copyBounds);
2304
2333
  }
2305
2334
 
2335
+ function getShadowSpread(_ui, shadow) {
2336
+ let width = 0;
2337
+ shadow.forEach(item => width = Math.max(width, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread > 0 ? item.spread : 0) + item.blur * 1.5));
2338
+ return width;
2339
+ }
2340
+
2306
2341
  function drawWorldShadow(canvas, outBounds, spreadScale, shape) {
2307
2342
  const {bounds: bounds, shapeBounds: shapeBounds} = shape;
2308
2343
  if (Platform.fullImageShadow) {
@@ -2380,7 +2415,11 @@ const EffectModule = {
2380
2415
  shadow: shadow,
2381
2416
  innerShadow: innerShadow,
2382
2417
  blur: blur,
2383
- backgroundBlur: backgroundBlur
2418
+ backgroundBlur: backgroundBlur,
2419
+ getShadowSpread: getShadowSpread,
2420
+ isTransformShadow(_shadow) {
2421
+ return undefined;
2422
+ }
2384
2423
  };
2385
2424
 
2386
2425
  const {excludeRenderBounds: excludeRenderBounds} = LeafBoundsHelper;
@@ -2888,16 +2927,17 @@ function toTextChar(row) {
2888
2927
  }
2889
2928
 
2890
2929
  function decorationText(drawData, style) {
2891
- let type;
2930
+ let type, offset = 0;
2892
2931
  const {fontSize: fontSize, textDecoration: textDecoration} = style;
2893
2932
  drawData.decorationHeight = fontSize / 11;
2894
2933
  if (isObject(textDecoration)) {
2895
2934
  type = textDecoration.type;
2896
2935
  if (textDecoration.color) drawData.decorationColor = ColorConvert.string(textDecoration.color);
2936
+ if (textDecoration.offset) offset = Math.min(fontSize * .3, Math.max(textDecoration.offset, -fontSize * .15));
2897
2937
  } else type = textDecoration;
2898
2938
  switch (type) {
2899
2939
  case "under":
2900
- drawData.decorationY = [ fontSize * .15 ];
2940
+ drawData.decorationY = [ fontSize * .15 + offset ];
2901
2941
  break;
2902
2942
 
2903
2943
  case "delete":
@@ -2905,7 +2945,7 @@ function decorationText(drawData, style) {
2905
2945
  break;
2906
2946
 
2907
2947
  case "under-delete":
2908
- drawData.decorationY = [ fontSize * .15, -fontSize * .35 ];
2948
+ drawData.decorationY = [ fontSize * .15 + offset, -fontSize * .35 ];
2909
2949
  }
2910
2950
  }
2911
2951