@visactor/vrender-core 0.22.7-alpha.0 → 0.23.0-alpha.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.
Files changed (192) hide show
  1. package/cjs/canvas/constants.js +1 -2
  2. package/cjs/color-string/index.js +1 -2
  3. package/cjs/color-string/interpolate.d.ts +1 -0
  4. package/cjs/color-string/interpolate.js +7 -2
  5. package/cjs/color-string/interpolate.js.map +1 -1
  6. package/cjs/color-string/store.js +2 -1
  7. package/cjs/common/path-svg.js +1 -2
  8. package/cjs/common/performance-raf.d.ts +6 -0
  9. package/cjs/common/performance-raf.js +26 -0
  10. package/cjs/common/performance-raf.js.map +1 -0
  11. package/cjs/common/render-area.js +1 -0
  12. package/cjs/common/store.js +1 -1
  13. package/cjs/common/text.js +1 -1
  14. package/cjs/common/utils.js +1 -1
  15. package/cjs/core/application.js +1 -1
  16. package/cjs/core/camera.js +1 -1
  17. package/cjs/core/constants.js +1 -1
  18. package/cjs/core/core-modules.js +1 -1
  19. package/cjs/core/global-module.js +0 -2
  20. package/cjs/core/stage.d.ts +2 -1
  21. package/cjs/core/stage.js +19 -15
  22. package/cjs/core/stage.js.map +1 -1
  23. package/cjs/event/event-system.js +7 -6
  24. package/cjs/event/event-system.js.map +1 -1
  25. package/cjs/event/federated-event/base-event.js +1 -1
  26. package/cjs/event/federated-event/base-event.js.map +1 -1
  27. package/cjs/graphic/graphic.d.ts +4 -3
  28. package/cjs/graphic/graphic.js +16 -22
  29. package/cjs/graphic/graphic.js.map +1 -1
  30. package/cjs/index.d.ts +1 -3
  31. package/cjs/index.js +16 -17
  32. package/cjs/index.js.map +1 -1
  33. package/cjs/interface/animate.d.ts +5 -0
  34. package/cjs/interface/animate.js.map +1 -1
  35. package/cjs/interface/graphic.d.ts +3 -1
  36. package/cjs/interface/graphic.js.map +1 -1
  37. package/cjs/interface/index.d.ts +1 -1
  38. package/cjs/interface/index.js +9 -9
  39. package/cjs/interface/index.js.map +1 -1
  40. package/cjs/interface/stage.d.ts +1 -0
  41. package/cjs/interface/stage.js.map +1 -1
  42. package/cjs/plugins/builtin-plugin/richtext-edit-plugin.d.ts +2 -2
  43. package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js +6 -5
  44. package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
  45. package/dist/index.es.js +2324 -5069
  46. package/es/canvas/constants.js +1 -2
  47. package/es/color-string/index.js +1 -2
  48. package/es/color-string/interpolate.d.ts +1 -0
  49. package/es/color-string/interpolate.js +4 -0
  50. package/es/color-string/interpolate.js.map +1 -1
  51. package/es/color-string/store.js +2 -1
  52. package/es/common/path-svg.js +1 -2
  53. package/es/common/performance-raf.d.ts +6 -0
  54. package/es/common/performance-raf.js +18 -0
  55. package/es/common/performance-raf.js.map +1 -0
  56. package/es/common/render-area.js +2 -1
  57. package/es/common/store.js +1 -1
  58. package/es/common/text.js +1 -1
  59. package/es/common/utils.js +1 -1
  60. package/es/core/application.js +1 -1
  61. package/es/core/camera.js +1 -1
  62. package/es/core/constants.js +1 -1
  63. package/es/core/core-modules.js +1 -1
  64. package/es/core/global-module.js +0 -2
  65. package/es/core/stage.d.ts +2 -1
  66. package/es/core/stage.js +18 -17
  67. package/es/core/stage.js.map +1 -1
  68. package/es/event/event-system.js +7 -6
  69. package/es/event/event-system.js.map +1 -1
  70. package/es/event/federated-event/base-event.js +1 -1
  71. package/es/event/federated-event/base-event.js.map +1 -1
  72. package/es/graphic/graphic.d.ts +4 -3
  73. package/es/graphic/graphic.js +17 -23
  74. package/es/graphic/graphic.js.map +1 -1
  75. package/es/index.d.ts +1 -3
  76. package/es/index.js +2 -6
  77. package/es/index.js.map +1 -1
  78. package/es/interface/animate.d.ts +5 -0
  79. package/es/interface/animate.js.map +1 -1
  80. package/es/interface/graphic.d.ts +3 -1
  81. package/es/interface/graphic.js.map +1 -1
  82. package/es/interface/index.d.ts +1 -1
  83. package/es/interface/index.js +2 -2
  84. package/es/interface/index.js.map +1 -1
  85. package/es/interface/stage.d.ts +1 -0
  86. package/es/interface/stage.js.map +1 -1
  87. package/es/plugins/builtin-plugin/richtext-edit-plugin.d.ts +2 -2
  88. package/es/plugins/builtin-plugin/richtext-edit-plugin.js +4 -5
  89. package/es/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
  90. package/package.json +1 -1
  91. package/cjs/animate/Ticker/default-ticker.d.ts +0 -40
  92. package/cjs/animate/Ticker/default-ticker.js +0 -140
  93. package/cjs/animate/Ticker/default-ticker.js.map +0 -1
  94. package/cjs/animate/Ticker/index.d.ts +0 -5
  95. package/cjs/animate/Ticker/index.js +0 -23
  96. package/cjs/animate/Ticker/index.js.map +0 -1
  97. package/cjs/animate/Ticker/manual-ticker-handler.d.ts +0 -15
  98. package/cjs/animate/Ticker/manual-ticker-handler.js +0 -36
  99. package/cjs/animate/Ticker/manual-ticker-handler.js.map +0 -1
  100. package/cjs/animate/Ticker/manual-ticker.d.ts +0 -19
  101. package/cjs/animate/Ticker/manual-ticker.js +0 -37
  102. package/cjs/animate/Ticker/manual-ticker.js.map +0 -1
  103. package/cjs/animate/Ticker/raf-tick-handler.d.ts +0 -9
  104. package/cjs/animate/Ticker/raf-tick-handler.js +0 -30
  105. package/cjs/animate/Ticker/raf-tick-handler.js.map +0 -1
  106. package/cjs/animate/Ticker/timeout-tick-handler.d.ts +0 -9
  107. package/cjs/animate/Ticker/timeout-tick-handler.js +0 -28
  108. package/cjs/animate/Ticker/timeout-tick-handler.js.map +0 -1
  109. package/cjs/animate/Ticker/type.d.ts +0 -6
  110. package/cjs/animate/Ticker/type.js +0 -11
  111. package/cjs/animate/Ticker/type.js.map +0 -1
  112. package/cjs/animate/animate.d.ts +0 -147
  113. package/cjs/animate/animate.js +0 -403
  114. package/cjs/animate/animate.js.map +0 -1
  115. package/cjs/animate/custom-animate.d.ts +0 -236
  116. package/cjs/animate/custom-animate.js +0 -722
  117. package/cjs/animate/custom-animate.js.map +0 -1
  118. package/cjs/animate/default-ticker.d.ts +0 -2
  119. package/cjs/animate/default-ticker.js +0 -14
  120. package/cjs/animate/default-ticker.js.map +0 -1
  121. package/cjs/animate/easing-func.d.ts +0 -1
  122. package/cjs/animate/easing-func.js +0 -16
  123. package/cjs/animate/easing-func.js.map +0 -1
  124. package/cjs/animate/easing.d.ts +0 -49
  125. package/cjs/animate/easing.js +0 -141
  126. package/cjs/animate/easing.js.map +0 -1
  127. package/cjs/animate/group-fade.d.ts +0 -16
  128. package/cjs/animate/group-fade.js +0 -66
  129. package/cjs/animate/group-fade.js.map +0 -1
  130. package/cjs/animate/index.d.ts +0 -8
  131. package/cjs/animate/index.js +0 -24
  132. package/cjs/animate/index.js.map +0 -1
  133. package/cjs/animate/morphing.d.ts +0 -52
  134. package/cjs/animate/morphing.js +0 -292
  135. package/cjs/animate/morphing.js.map +0 -1
  136. package/cjs/animate/timeline.d.ts +0 -17
  137. package/cjs/animate/timeline.js +0 -46
  138. package/cjs/animate/timeline.js.map +0 -1
  139. package/cjs/plugins/builtin-plugin/richtext-edit-plugin-old.d.ts +0 -1
  140. package/cjs/plugins/builtin-plugin/richtext-edit-plugin-old.js +0 -3
  141. package/cjs/plugins/builtin-plugin/richtext-edit-plugin-old.js.map +0 -1
  142. package/es/animate/Ticker/default-ticker.d.ts +0 -40
  143. package/es/animate/Ticker/default-ticker.js +0 -138
  144. package/es/animate/Ticker/default-ticker.js.map +0 -1
  145. package/es/animate/Ticker/index.d.ts +0 -5
  146. package/es/animate/Ticker/index.js +0 -10
  147. package/es/animate/Ticker/index.js.map +0 -1
  148. package/es/animate/Ticker/manual-ticker-handler.d.ts +0 -15
  149. package/es/animate/Ticker/manual-ticker-handler.js +0 -28
  150. package/es/animate/Ticker/manual-ticker-handler.js.map +0 -1
  151. package/es/animate/Ticker/manual-ticker.d.ts +0 -19
  152. package/es/animate/Ticker/manual-ticker.js +0 -31
  153. package/es/animate/Ticker/manual-ticker.js.map +0 -1
  154. package/es/animate/Ticker/raf-tick-handler.d.ts +0 -9
  155. package/es/animate/Ticker/raf-tick-handler.js +0 -22
  156. package/es/animate/Ticker/raf-tick-handler.js.map +0 -1
  157. package/es/animate/Ticker/timeout-tick-handler.d.ts +0 -9
  158. package/es/animate/Ticker/timeout-tick-handler.js +0 -20
  159. package/es/animate/Ticker/timeout-tick-handler.js.map +0 -1
  160. package/es/animate/Ticker/type.d.ts +0 -6
  161. package/es/animate/Ticker/type.js +0 -7
  162. package/es/animate/Ticker/type.js.map +0 -1
  163. package/es/animate/animate.d.ts +0 -147
  164. package/es/animate/animate.js +0 -398
  165. package/es/animate/animate.js.map +0 -1
  166. package/es/animate/custom-animate.d.ts +0 -236
  167. package/es/animate/custom-animate.js +0 -699
  168. package/es/animate/custom-animate.js.map +0 -1
  169. package/es/animate/default-ticker.d.ts +0 -2
  170. package/es/animate/default-ticker.js +0 -12
  171. package/es/animate/default-ticker.js.map +0 -1
  172. package/es/animate/easing-func.d.ts +0 -1
  173. package/es/animate/easing-func.js +0 -10
  174. package/es/animate/easing-func.js.map +0 -1
  175. package/es/animate/easing.d.ts +0 -49
  176. package/es/animate/easing.js +0 -134
  177. package/es/animate/easing.js.map +0 -1
  178. package/es/animate/group-fade.d.ts +0 -16
  179. package/es/animate/group-fade.js +0 -56
  180. package/es/animate/group-fade.js.map +0 -1
  181. package/es/animate/index.d.ts +0 -8
  182. package/es/animate/index.js +0 -16
  183. package/es/animate/index.js.map +0 -1
  184. package/es/animate/morphing.d.ts +0 -52
  185. package/es/animate/morphing.js +0 -295
  186. package/es/animate/morphing.js.map +0 -1
  187. package/es/animate/timeline.d.ts +0 -17
  188. package/es/animate/timeline.js +0 -42
  189. package/es/animate/timeline.js.map +0 -1
  190. package/es/plugins/builtin-plugin/richtext-edit-plugin-old.d.ts +0 -1
  191. package/es/plugins/builtin-plugin/richtext-edit-plugin-old.js +0 -3
  192. package/es/plugins/builtin-plugin/richtext-edit-plugin-old.js.map +0 -1
@@ -3,5 +3,4 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  }), exports.Context2dFactory = exports.CanvasFactory = void 0, exports.CanvasFactory = Symbol.for("CanvasFactory"),
6
- exports.Context2dFactory = Symbol.for("Context2dFactory");
7
- //# sourceMappingURL=constants.js.map
6
+ exports.Context2dFactory = Symbol.for("Context2dFactory");
@@ -18,5 +18,4 @@ var __createBinding = this && this.__createBinding || (Object.create ? function(
18
18
  Object.defineProperty(exports, "__esModule", {
19
19
  value: !0
20
20
  }), __exportStar(require("./interpolate"), exports), __exportStar(require("./store"), exports),
21
- __exportStar(require("./colorName"), exports);
22
- //# sourceMappingURL=index.js.map
21
+ __exportStar(require("./colorName"), exports);
@@ -5,4 +5,5 @@ export declare function interpolateGradientLinearColor(fc: ILinearGradient, tc:
5
5
  export declare function interpolateGradientRadialColor(fc: IRadialGradient, tc: IRadialGradient, ratio: number): false | IRadialGradient;
6
6
  export declare function interpolateGradientConicalColor(fc: IConicalGradient, tc: IConicalGradient, ratio: number): false | IConicalGradient;
7
7
  export declare function interpolatePureColorArray(from: [number, number, number, number], to: [number, number, number, number], ratio: number): [number, number, number, number];
8
+ export declare function interpolatePureColorArrayToStr(from: [number, number, number, number], to: [number, number, number, number], ratio: number): string;
8
9
  export declare function colorStringInterpolationToStr(fromColor: string, toColor: string, ratio: number): string;
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
- }), exports.colorStringInterpolationToStr = exports.interpolatePureColorArray = exports.interpolateGradientConicalColor = exports.interpolateGradientRadialColor = exports.interpolateGradientLinearColor = exports._interpolateColor = exports.interpolateColor = void 0;
5
+ }), exports.colorStringInterpolationToStr = exports.interpolatePureColorArrayToStr = exports.interpolatePureColorArray = exports.interpolateGradientConicalColor = exports.interpolateGradientRadialColor = exports.interpolateGradientLinearColor = exports._interpolateColor = exports.interpolateColor = void 0;
6
6
 
7
7
  const store_1 = require("./store"), vutils_1 = require("@visactor/vutils");
8
8
 
@@ -97,9 +97,14 @@ function interpolatePureColorArray(from, to, ratio) {
97
97
  return [ from[0] + (to[0] - from[0]) * ratio, from[1] + (to[1] - from[1]) * ratio, from[2] + (to[2] - from[2]) * ratio, from[3] + (to[3] - from[3]) * ratio ];
98
98
  }
99
99
 
100
+ function interpolatePureColorArrayToStr(from, to, ratio) {
101
+ return `rgba(${from[0] + (to[0] - from[0]) * ratio},${from[1] + (to[1] - from[1]) * ratio},${from[2] + (to[2] - from[2]) * ratio},${from[3] + (to[3] - from[3]) * ratio})`;
102
+ }
103
+
100
104
  exports.interpolateColor = interpolateColor, exports._interpolateColor = _interpolateColor,
101
105
  exports.interpolateGradientLinearColor = interpolateGradientLinearColor, exports.interpolateGradientRadialColor = interpolateGradientRadialColor,
102
- exports.interpolateGradientConicalColor = interpolateGradientConicalColor, exports.interpolatePureColorArray = interpolatePureColorArray;
106
+ exports.interpolateGradientConicalColor = interpolateGradientConicalColor, exports.interpolatePureColorArray = interpolatePureColorArray,
107
+ exports.interpolatePureColorArrayToStr = interpolatePureColorArrayToStr;
103
108
 
104
109
  const _fromColorRGB = [ 0, 0, 0, 0 ], _toColorRGB = [ 0, 0, 0, 0 ];
105
110
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/color-string/interpolate.ts"],"names":[],"mappings":";;;AAAA,mCAAgD;AAEhD,6CAAqD;AAErD,SAAS,kBAAkB,CACzB,KAAiE,EACjE,eAAwB,KAAK;IAE7B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,IAAA,iBAAQ,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;QAC9C,OAAO,YAAY;YACjB,CAAC,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO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AG,aAAa,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,CACrG,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAC/D,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,IAC7E,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,GAAG,KAC3D,GAAG,CAAC;AACN,CAAC;AARD,sEAQC","file":"interpolate.js","sourcesContent":["import { ColorStore, ColorType } from './store';\nimport type { IGradientColor, ILinearGradient, IRadialGradient, IConicalGradient } from '../interface';\nimport { isArray, isNumber } from '@visactor/vutils';\n\nfunction colorArrayToString(\n color: string | IGradientColor | [number, number, number, number],\n alphaChannel: boolean = false\n) {\n if (Array.isArray(color) && isNumber(color[0])) {\n return alphaChannel\n ? `rgb(${Math.round(color[0])},${Math.round(color[1])},${Math.round(color[2])},${color[3].toFixed(2)})`\n : `rgb(${Math.round(color[0])},${Math.round(color[1])},${Math.round(color[2])})`;\n }\n return color;\n}\n\nexport function interpolateColor(\n from: [number, number, number, number] | [string, string, string, string] | string | IGradientColor,\n to: [number, number, number, number] | [string, string, string, string] | string | IGradientColor,\n ratio: number,\n alphaChannel: boolean,\n cb?: (fromArray: [number, number, number, number], toArray: [number, number, number, number]) => void\n): false | string | IGradientColor | string[] {\n if ((Array.isArray(from) && !isNumber(from[0])) || (Array.isArray(to) && !isNumber(to[0]))) {\n // 待性能优化\n const out: string[] = new Array(4).fill(0).map((_, index) => {\n return _interpolateColor(\n isArray(from) ? (from[index] as string) : from,\n isArray(to) ? (to[index] as string) : to,\n ratio,\n alphaChannel\n ) as string;\n });\n return out;\n // cb && cb(from!, to!);\n }\n return _interpolateColor(from as any, to as any, ratio, alphaChannel, cb);\n}\n\nexport function _interpolateColor(\n from: [number, number, number, number] | string | IGradientColor,\n to: [number, number, number, number] | string | IGradientColor,\n ratio: number,\n alphaChannel: boolean,\n cb?: (fromArray: [number, number, number, number], toArray: [number, number, number, number]) => void\n): false | string | IGradientColor | string[] {\n if (!(from && to)) {\n return (from && colorArrayToString(from)) || (to && colorArrayToString(to)) || (false as any);\n }\n let fromArray: [number, number, number, number];\n let toArray: [number, number, number, number];\n let fromGradient: boolean = false;\n let toGradient: boolean = false;\n if (Array.isArray(from)) {\n fromArray = from as [number, number, number, number];\n } else if (typeof from === 'string') {\n fromArray = ColorStore.Get(from, ColorType.Color255);\n } else {\n fromGradient = true;\n }\n if (Array.isArray(to)) {\n toArray = to as [number, number, number, number];\n } else if (typeof to === 'string') {\n toArray = ColorStore.Get(to, ColorType.Color255);\n } else {\n toGradient = true;\n }\n if (fromGradient !== toGradient) {\n // 纯色到渐变色,那就将纯色转成渐变色\n const gradient: IGradientColor = (fromGradient ? from : to) as IGradientColor;\n const pure = (fromGradient ? to : from) as string | [number, number, number, number];\n const gradientFromPure: IGradientColor = {\n ...gradient,\n stops: gradient.stops.map(v => ({ ...v, color: colorArrayToString(pure) as string }))\n };\n return fromGradient\n ? interpolateColor(gradient, gradientFromPure, ratio, alphaChannel, cb)\n : interpolateColor(gradientFromPure, gradient, ratio, alphaChannel, cb);\n }\n\n if (fromGradient) {\n if ((from as IGradientColor).gradient === (to as IGradientColor).gradient) {\n const fc: IGradientColor = from as IGradientColor;\n const tc: IGradientColor = to as IGradientColor;\n // 渐变色插值,只支持相同数量stopColor的插值,并且认为当前的stopColor数量是和from、to相同\n const fromStops = fc.stops;\n const toStops = tc.stops;\n if (fromStops.length !== toStops.length) {\n return false;\n }\n if (fc.gradient === 'linear') {\n return interpolateGradientLinearColor(fc, tc as ILinearGradient, ratio);\n } else if (fc.gradient === 'radial') {\n return interpolateGradientRadialColor(fc, tc as IRadialGradient, ratio);\n } else if (fc.gradient === 'conical') {\n return interpolateGradientConicalColor(fc, tc as IConicalGradient, ratio);\n }\n }\n return false;\n }\n cb && cb(fromArray!, toArray!);\n const result = interpolatePureColorArray(fromArray!, toArray!, ratio);\n return colorArrayToString(result, alphaChannel) as any;\n}\n\nexport function interpolateGradientLinearColor(\n fc: ILinearGradient,\n tc: ILinearGradient,\n ratio: number\n): false | ILinearGradient {\n const fStops = fc.stops;\n const tStops = tc.stops;\n const color: ILinearGradient = {\n gradient: 'linear',\n x0: fc.x0 + (tc.x0 - fc.x0) * ratio,\n x1: fc.x1 + (tc.x1 - fc.x1) * ratio,\n y0: fc.y0 + (tc.y0 - fc.y0) * ratio,\n y1: fc.y1 + (tc.y1 - fc.y1) * ratio,\n stops: new Array(fStops.length).fill(0).map((_, i) => {\n return {\n color: colorStringInterpolationToStr(fStops[i].color, tStops[i].color, ratio),\n offset: fStops[i].offset + (tStops[i].offset - fStops[i].offset) * ratio\n };\n })\n };\n return color;\n}\n\nexport function interpolateGradientRadialColor(\n fc: IRadialGradient,\n tc: IRadialGradient,\n ratio: number\n): false | IRadialGradient {\n const fStops = fc.stops;\n const tStops = tc.stops;\n const color: IRadialGradient = {\n gradient: 'radial',\n x0: fc.x0 + (tc.x0 - fc.x0) * ratio,\n x1: fc.x1 + (tc.x1 - fc.x1) * ratio,\n y0: fc.y0 + (tc.y0 - fc.y0) * ratio,\n y1: fc.y1 + (tc.y1 - fc.y1) * ratio,\n r0: fc.r0 + (tc.r0 - fc.r0) * ratio,\n r1: fc.r1 + (tc.r1 - fc.r1) * ratio,\n stops: new Array(fStops.length).fill(0).map((_, i) => {\n return {\n color: colorStringInterpolationToStr(fStops[i].color, tStops[i].color, ratio),\n offset: fStops[i].offset + (tStops[i].offset - fStops[i].offset) * ratio\n };\n })\n };\n return color;\n}\n\nexport function interpolateGradientConicalColor(\n fc: IConicalGradient,\n tc: IConicalGradient,\n ratio: number\n): false | IConicalGradient {\n const fStops = fc.stops;\n const tStops = tc.stops;\n const color: IConicalGradient = {\n gradient: 'conical',\n startAngle: fc.startAngle + (tc.startAngle - fc.startAngle) * ratio,\n endAngle: fc.endAngle + (tc.endAngle - fc.endAngle) * ratio,\n x: fc.x + (tc.x - fc.x) * ratio,\n y: fc.y + (tc.y - fc.y) * ratio,\n stops: new Array(fStops.length).fill(0).map((_, i) => {\n return {\n color: colorStringInterpolationToStr(fStops[i].color, tStops[i].color, ratio),\n offset: fStops[i].offset + (tStops[i].offset - fStops[i].offset) * ratio\n };\n })\n };\n return color;\n}\n\nexport function interpolatePureColorArray(\n from: [number, number, number, number],\n to: [number, number, number, number],\n ratio: number\n): [number, number, number, number] {\n return [\n from[0] + (to[0] - from[0]) * ratio,\n from[1] + (to[1] - from[1]) * ratio,\n from[2] + (to[2] - from[2]) * ratio,\n from[3] + (to[3] - from[3]) * ratio\n ];\n}\n\nconst _fromColorRGB: [number, number, number, number] = [0, 0, 0, 0];\nconst _toColorRGB: [number, number, number, number] = [0, 0, 0, 0];\nexport function colorStringInterpolationToStr(fromColor: string, toColor: string, ratio: number): string {\n ColorStore.Get(fromColor, ColorType.Color255, _fromColorRGB);\n ColorStore.Get(toColor, ColorType.Color255, _toColorRGB);\n return `rgba(${Math.round(_fromColorRGB[0] + (_toColorRGB[0] - _fromColorRGB[0]) * ratio)},${Math.round(\n _fromColorRGB[1] + (_toColorRGB[1] - _fromColorRGB[1]) * ratio\n )},${Math.round(_fromColorRGB[2] + (_toColorRGB[2] - _fromColorRGB[2]) * ratio)},${\n _fromColorRGB[3] + (_toColorRGB[3] - _fromColorRGB[3]) * ratio\n })`;\n}\n"]}
1
+ {"version":3,"sources":["../src/color-string/interpolate.ts"],"names":[],"mappings":";;;AAAA,mCAAgD;AAEhD,6CAAqD;AAErD,SAAS,kBAAkB,CACzB,KAAiE,EACjE,eAAwB,KAAK;IAE7B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,IA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a,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,GAAG,KAC3D,GAAG,CAAC;AACN,CAAC;AARD,sEAQC","file":"interpolate.js","sourcesContent":["import { ColorStore, ColorType } from './store';\nimport type { IGradientColor, ILinearGradient, IRadialGradient, IConicalGradient } from '../interface';\nimport { isArray, isNumber } from '@visactor/vutils';\n\nfunction colorArrayToString(\n color: string | IGradientColor | [number, number, number, number],\n alphaChannel: boolean = false\n) {\n if (Array.isArray(color) && isNumber(color[0])) {\n return alphaChannel\n ? `rgb(${Math.round(color[0])},${Math.round(color[1])},${Math.round(color[2])},${color[3].toFixed(2)})`\n : `rgb(${Math.round(color[0])},${Math.round(color[1])},${Math.round(color[2])})`;\n }\n return color;\n}\n\nexport function interpolateColor(\n from: [number, number, number, number] | [string, string, string, string] | string | IGradientColor,\n to: [number, number, number, number] | [string, string, string, string] | string | IGradientColor,\n ratio: number,\n alphaChannel: boolean,\n cb?: (fromArray: [number, number, number, number], toArray: [number, number, number, number]) => void\n): false | string | IGradientColor | string[] {\n if ((Array.isArray(from) && !isNumber(from[0])) || (Array.isArray(to) && !isNumber(to[0]))) {\n // 待性能优化\n const out: string[] = new Array(4).fill(0).map((_, index) => {\n return _interpolateColor(\n isArray(from) ? (from[index] as string) : from,\n isArray(to) ? (to[index] as string) : to,\n ratio,\n alphaChannel\n ) as string;\n });\n return out;\n // cb && cb(from!, to!);\n }\n return _interpolateColor(from as any, to as any, ratio, alphaChannel, cb);\n}\n\nexport function _interpolateColor(\n from: [number, number, number, number] | string | IGradientColor,\n to: [number, number, number, number] | string | IGradientColor,\n ratio: number,\n alphaChannel: boolean,\n cb?: (fromArray: [number, number, number, number], toArray: [number, number, number, number]) => void\n): false | string | IGradientColor | string[] {\n if (!(from && to)) {\n return (from && colorArrayToString(from)) || (to && colorArrayToString(to)) || (false as any);\n }\n let fromArray: [number, number, number, number];\n let toArray: [number, number, number, number];\n let fromGradient: boolean = false;\n let toGradient: boolean = false;\n if (Array.isArray(from)) {\n fromArray = from as [number, number, number, number];\n } else if (typeof from === 'string') {\n fromArray = ColorStore.Get(from, ColorType.Color255);\n } else {\n fromGradient = true;\n }\n if (Array.isArray(to)) {\n toArray = to as [number, number, number, number];\n } else if (typeof to === 'string') {\n toArray = ColorStore.Get(to, ColorType.Color255);\n } else {\n toGradient = true;\n }\n if (fromGradient !== toGradient) {\n // 纯色到渐变色,那就将纯色转成渐变色\n const gradient: IGradientColor = (fromGradient ? from : to) as IGradientColor;\n const pure = (fromGradient ? to : from) as string | [number, number, number, number];\n const gradientFromPure: IGradientColor = {\n ...gradient,\n stops: gradient.stops.map(v => ({ ...v, color: colorArrayToString(pure) as string }))\n };\n return fromGradient\n ? interpolateColor(gradient, gradientFromPure, ratio, alphaChannel, cb)\n : interpolateColor(gradientFromPure, gradient, ratio, alphaChannel, cb);\n }\n\n if (fromGradient) {\n if ((from as IGradientColor).gradient === (to as IGradientColor).gradient) {\n const fc: IGradientColor = from as IGradientColor;\n const tc: IGradientColor = to as IGradientColor;\n // 渐变色插值,只支持相同数量stopColor的插值,并且认为当前的stopColor数量是和from、to相同\n const fromStops = fc.stops;\n const toStops = tc.stops;\n if (fromStops.length !== toStops.length) {\n return false;\n }\n if (fc.gradient === 'linear') {\n return interpolateGradientLinearColor(fc, tc as ILinearGradient, ratio);\n } else if (fc.gradient === 'radial') {\n return interpolateGradientRadialColor(fc, tc as IRadialGradient, ratio);\n } else if (fc.gradient === 'conical') {\n return interpolateGradientConicalColor(fc, tc as IConicalGradient, ratio);\n }\n }\n return false;\n }\n cb && cb(fromArray!, toArray!);\n const result = interpolatePureColorArray(fromArray!, toArray!, ratio);\n return colorArrayToString(result, alphaChannel) as any;\n}\n\nexport function interpolateGradientLinearColor(\n fc: ILinearGradient,\n tc: ILinearGradient,\n ratio: number\n): false | ILinearGradient {\n const fStops = fc.stops;\n const tStops = tc.stops;\n const color: ILinearGradient = {\n gradient: 'linear',\n x0: fc.x0 + (tc.x0 - fc.x0) * ratio,\n x1: fc.x1 + (tc.x1 - fc.x1) * ratio,\n y0: fc.y0 + (tc.y0 - fc.y0) * ratio,\n y1: fc.y1 + (tc.y1 - fc.y1) * ratio,\n stops: new Array(fStops.length).fill(0).map((_, i) => {\n return {\n color: colorStringInterpolationToStr(fStops[i].color, tStops[i].color, ratio),\n offset: fStops[i].offset + (tStops[i].offset - fStops[i].offset) * ratio\n };\n })\n };\n return color;\n}\n\nexport function interpolateGradientRadialColor(\n fc: IRadialGradient,\n tc: IRadialGradient,\n ratio: number\n): false | IRadialGradient {\n const fStops = fc.stops;\n const tStops = tc.stops;\n const color: IRadialGradient = {\n gradient: 'radial',\n x0: fc.x0 + (tc.x0 - fc.x0) * ratio,\n x1: fc.x1 + (tc.x1 - fc.x1) * ratio,\n y0: fc.y0 + (tc.y0 - fc.y0) * ratio,\n y1: fc.y1 + (tc.y1 - fc.y1) * ratio,\n r0: fc.r0 + (tc.r0 - fc.r0) * ratio,\n r1: fc.r1 + (tc.r1 - fc.r1) * ratio,\n stops: new Array(fStops.length).fill(0).map((_, i) => {\n return {\n color: colorStringInterpolationToStr(fStops[i].color, tStops[i].color, ratio),\n offset: fStops[i].offset + (tStops[i].offset - fStops[i].offset) * ratio\n };\n })\n };\n return color;\n}\n\nexport function interpolateGradientConicalColor(\n fc: IConicalGradient,\n tc: IConicalGradient,\n ratio: number\n): false | IConicalGradient {\n const fStops = fc.stops;\n const tStops = tc.stops;\n const color: IConicalGradient = {\n gradient: 'conical',\n startAngle: fc.startAngle + (tc.startAngle - fc.startAngle) * ratio,\n endAngle: fc.endAngle + (tc.endAngle - fc.endAngle) * ratio,\n x: fc.x + (tc.x - fc.x) * ratio,\n y: fc.y + (tc.y - fc.y) * ratio,\n stops: new Array(fStops.length).fill(0).map((_, i) => {\n return {\n color: colorStringInterpolationToStr(fStops[i].color, tStops[i].color, ratio),\n offset: fStops[i].offset + (tStops[i].offset - fStops[i].offset) * ratio\n };\n })\n };\n return color;\n}\n\nexport function interpolatePureColorArray(\n from: [number, number, number, number],\n to: [number, number, number, number],\n ratio: number\n): [number, number, number, number] {\n return [\n from[0] + (to[0] - from[0]) * ratio,\n from[1] + (to[1] - from[1]) * ratio,\n from[2] + (to[2] - from[2]) * ratio,\n from[3] + (to[3] - from[3]) * ratio\n ];\n}\nexport function interpolatePureColorArrayToStr(\n from: [number, number, number, number],\n to: [number, number, number, number],\n ratio: number\n): string {\n // eslint-disable-next-line max-len\n return `rgba(${from[0] + (to[0] - from[0]) * ratio},${from[1] + (to[1] - from[1]) * ratio},${\n from[2] + (to[2] - from[2]) * ratio\n },${from[3] + (to[3] - from[3]) * ratio})`;\n}\n\nconst _fromColorRGB: [number, number, number, number] = [0, 0, 0, 0];\nconst _toColorRGB: [number, number, number, number] = [0, 0, 0, 0];\nexport function colorStringInterpolationToStr(fromColor: string, toColor: string, ratio: number): string {\n ColorStore.Get(fromColor, ColorType.Color255, _fromColorRGB);\n ColorStore.Get(toColor, ColorType.Color255, _toColorRGB);\n return `rgba(${Math.round(_fromColorRGB[0] + (_toColorRGB[0] - _fromColorRGB[0]) * ratio)},${Math.round(\n _fromColorRGB[1] + (_toColorRGB[1] - _fromColorRGB[1]) * ratio\n )},${Math.round(_fromColorRGB[2] + (_toColorRGB[2] - _fromColorRGB[2]) * ratio)},${\n _fromColorRGB[3] + (_toColorRGB[3] - _fromColorRGB[3]) * ratio\n })`;\n}\n"]}
@@ -50,4 +50,5 @@ class ColorStore {
50
50
  }
51
51
  }
52
52
 
53
- exports.ColorStore = ColorStore, ColorStore.store255 = {}, ColorStore.store1 = {};
53
+ exports.ColorStore = ColorStore, ColorStore.store255 = {}, ColorStore.store1 = {};
54
+ //# sourceMappingURL=store.js.map
@@ -60,5 +60,4 @@ exports.enumCommandMap = {
60
60
  M: 6,
61
61
  Q: 7,
62
62
  R: 8
63
- }, exports.parseSvgPath = parseSvgPath;
64
- //# sourceMappingURL=path-svg.js.map
63
+ }, exports.parseSvgPath = parseSvgPath;
@@ -0,0 +1,6 @@
1
+ export declare class PerformanceRAF {
2
+ nextAnimationFrameCbs: FrameRequestCallback[];
3
+ addAnimationFrameCb(callback: FrameRequestCallback): number;
4
+ protected runAnimationFrame: (time: number) => void;
5
+ protected tryRunAnimationFrameNextFrame: () => void;
6
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.PerformanceRAF = void 0;
6
+
7
+ const modules_1 = require("../modules");
8
+
9
+ class PerformanceRAF {
10
+ constructor() {
11
+ this.nextAnimationFrameCbs = [], this.runAnimationFrame = time => {
12
+ const cbs = this.nextAnimationFrameCbs;
13
+ this.nextAnimationFrameCbs = [];
14
+ for (let i = 0; i < cbs.length; i++) cbs[i](time);
15
+ }, this.tryRunAnimationFrameNextFrame = () => {
16
+ this.nextAnimationFrameCbs && 1 === this.nextAnimationFrameCbs.length && modules_1.vglobal.getRequestAnimationFrame()(this.runAnimationFrame);
17
+ };
18
+ }
19
+ addAnimationFrameCb(callback) {
20
+ return this.nextAnimationFrameCbs.push(callback), this.tryRunAnimationFrameNextFrame(),
21
+ this.nextAnimationFrameCbs.length - 1;
22
+ }
23
+ }
24
+
25
+ exports.PerformanceRAF = PerformanceRAF;
26
+ //# sourceMappingURL=performance-raf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/common/performance-raf.ts"],"names":[],"mappings":";;;AAAA,wCAAqC;AAKrC,MAAa,cAAc;IAA3B;QACE,0BAAqB,GAA2B,EAAE,CAAC;QASzC,sBAAiB,GAAG,CAAC,IAAY,EAAE,EAAE;YAC7C,MAAM,GAAG,GAAG,IAAI,CAAC,qBAAqB,CAAC;YACvC,IAAI,CAAC,qBAAqB,GAAG,EAAE,CAAC;YAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBACnC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;aACd;QACH,CAAC,CAAC;QAEQ,kCAA6B,GAAG,GAAG,EAAE;YAC7C,IAAI,CAAC,CAAC,IAAI,CAAC,qBAAqB,IAAI,IAAI,CAAC,qBAAqB,CAAC,MAAM,KAAK,CAAC,CAAC,EAAE;gBAC5E,OAAO;aACR;YACD,iBAAO,CAAC,wBAAwB,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAC7D,CAAC,CAAC;IACJ,CAAC;IArBC,mBAAmB,CAAC,QAA8B;QAChD,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAE1C,IAAI,CAAC,6BAA6B,EAAE,CAAC;QACrC,OAAO,IAAI,CAAC,qBAAqB,CAAC,MAAM,GAAG,CAAC,CAAC;IAC/C,CAAC;CAgBF;AAxBD,wCAwBC","file":"performance-raf.js","sourcesContent":["import { vglobal } from '../modules';\n\n/**\n * 性能优化,将requestAnimationFrame的回调函数存储起来,在下一帧执行\n */\nexport class PerformanceRAF {\n nextAnimationFrameCbs: FrameRequestCallback[] = [];\n\n addAnimationFrameCb(callback: FrameRequestCallback) {\n this.nextAnimationFrameCbs.push(callback);\n // 下一帧执行nextAnimationFrameCbs\n this.tryRunAnimationFrameNextFrame();\n return this.nextAnimationFrameCbs.length - 1;\n }\n\n protected runAnimationFrame = (time: number) => {\n const cbs = this.nextAnimationFrameCbs;\n this.nextAnimationFrameCbs = [];\n for (let i = 0; i < cbs.length; i++) {\n cbs[i](time);\n }\n };\n\n protected tryRunAnimationFrameNextFrame = () => {\n if (!(this.nextAnimationFrameCbs && this.nextAnimationFrameCbs.length === 1)) {\n return;\n }\n vglobal.getRequestAnimationFrame()(this.runAnimationFrame);\n };\n}\n"]}
@@ -61,4 +61,5 @@ function drawAreaBlock(path, topList, bottomList, params) {
61
61
  path.closePath();
62
62
  }
63
63
 
64
+ //# sourceMappingURL=render-area.js.map
64
65
  exports.drawAreaSegments = drawAreaSegments;
@@ -1,2 +1,2 @@
1
1
  class StageStore {}
2
- //# sourceMappingURL=store.js.map
2
+ //# sourceMappingURL=store.js.map
@@ -34,4 +34,4 @@ function textAttributesToStyle(attrs) {
34
34
 
35
35
  exports.textDrawOffsetY = textDrawOffsetY, exports.textDrawOffsetX = textDrawOffsetX,
36
36
  exports.textLayoutOffsetY = textLayoutOffsetY, exports.textAttributesToStyle = textAttributesToStyle;
37
- //# sourceMappingURL=text.js.map
37
+ //# sourceMappingURL=text.js.map
@@ -167,4 +167,4 @@ const calculateLineHeight = (lineHeight, fontSize) => {
167
167
  };
168
168
 
169
169
  exports.calculateLineHeight = calculateLineHeight;
170
- //# sourceMappingURL=utils.js.map
170
+ //# sourceMappingURL=utils.js.map
@@ -3,4 +3,4 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  }), exports.ApplicationContribution = void 0, exports.ApplicationContribution = Symbol("ApplicationContribution");
6
- //# sourceMappingURL=application.js.map
6
+ //# sourceMappingURL=application.js.map
@@ -71,4 +71,4 @@ const registerOrthoCamera = () => {
71
71
  };
72
72
 
73
73
  exports.registerOrthoCamera = registerOrthoCamera;
74
- //# sourceMappingURL=camera.js.map
74
+ //# sourceMappingURL=camera.js.map
@@ -7,4 +7,4 @@ exports.TransformUtil = Symbol.for("TransformUtil"), exports.GraphicUtil = Symbo
7
7
  exports.LayerService = Symbol.for("LayerService"), exports.StaticLayerHandlerContribution = Symbol.for("StaticLayerHandlerContribution"),
8
8
  exports.DynamicLayerHandlerContribution = Symbol.for("DynamicLayerHandlerContribution"),
9
9
  exports.VirtualLayerHandlerContribution = Symbol.for("VirtualLayerHandlerContribution");
10
- //# sourceMappingURL=constants.js.map
10
+ //# sourceMappingURL=constants.js.map
@@ -12,4 +12,4 @@ exports.default = new inversify_lite_1.ContainerModule((bind => {
12
12
  bind(constants_1.TransformUtil).to(graphic_utils_1.DefaultTransformUtil).inSingletonScope(),
13
13
  bind(constants_1.LayerService).to(layer_service_1.DefaultLayerService).inSingletonScope();
14
14
  }));
15
- //# sourceMappingURL=core-modules.js.map
15
+ //# sourceMappingURL=core-modules.js.map
@@ -1,3 +1 @@
1
-
2
-
3
1
  //# sourceMappingURL=global-module.js.map
@@ -66,6 +66,8 @@ export declare class Stage extends Group implements IStage {
66
66
  params: Partial<IStageParams>;
67
67
  protected tickedBeforeRender: boolean;
68
68
  constructor(params?: Partial<IStageParams>);
69
+ initAnimate(params: Partial<IStageParams>): void;
70
+ startAnimate(): void;
69
71
  pauseRender(sr?: number): void;
70
72
  resumeRender(): void;
71
73
  protected tryInitEventSystem(): void;
@@ -141,7 +143,6 @@ export declare class Stage extends Group implements IStage {
141
143
  setOrigin(x: number, y: number): void;
142
144
  export(type: IExportType): HTMLCanvasElement | ImageData;
143
145
  pick(x: number, y: number): PickResult | false;
144
- startAnimate(t: number): void;
145
146
  setToFrame(t: number): void;
146
147
  release(): void;
147
148
  setStage(stage?: IStage): void;
package/cjs/core/stage.js CHANGED
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  }), exports.Stage = void 0;
6
6
 
7
- const vutils_1 = require("@visactor/vutils"), window_1 = require("./window"), event_1 = require("../event"), container_1 = require("../container"), render_1 = require("../render"), group_1 = require("../graphic/group"), theme_1 = require("../graphic/theme"), constants_1 = require("../picker/constants"), constants_2 = require("../plugins/constants"), auto_render_plugin_1 = require("../plugins/builtin-plugin/auto-render-plugin"), auto_refresh_plugin_1 = require("../plugins/builtin-plugin/auto-refresh-plugin"), incremental_auto_render_plugin_1 = require("../plugins/builtin-plugin/incremental-auto-render-plugin"), dirty_bounds_plugin_1 = require("../plugins/builtin-plugin/dirty-bounds-plugin"), default_ticker_1 = require("../animate/default-ticker"), tapable_1 = require("../tapable"), constants_3 = require("./constants"), animate_1 = require("../animate"), application_1 = require("../application"), env_check_1 = require("../env-check"), factory_1 = require("../factory"), DefaultConfig = {
7
+ const vutils_1 = require("@visactor/vutils"), window_1 = require("./window"), event_1 = require("../event"), container_1 = require("../container"), render_1 = require("../render"), group_1 = require("../graphic/group"), theme_1 = require("../graphic/theme"), constants_1 = require("../picker/constants"), constants_2 = require("../plugins/constants"), auto_render_plugin_1 = require("../plugins/builtin-plugin/auto-render-plugin"), auto_refresh_plugin_1 = require("../plugins/builtin-plugin/auto-refresh-plugin"), incremental_auto_render_plugin_1 = require("../plugins/builtin-plugin/incremental-auto-render-plugin"), dirty_bounds_plugin_1 = require("../plugins/builtin-plugin/dirty-bounds-plugin"), tapable_1 = require("../tapable"), constants_3 = require("./constants"), application_1 = require("../application"), env_check_1 = require("../env-check"), factory_1 = require("../factory"), DefaultConfig = {
8
8
  WIDTH: 500,
9
9
  HEIGHT: 500,
10
10
  X: 0,
@@ -119,12 +119,18 @@ class Stage extends group_1.Group {
119
119
  params.ReactDOM && this.enableReactAttribute(params.ReactDOM), params.enableLayout && this.enableLayout(),
120
120
  this.hooks.beforeRender.tap("constructor", this.beforeRender), this.hooks.afterRender.tap("constructor", this.afterRender),
121
121
  this._beforeRender = params.beforeRender, this._afterRender = params.afterRender,
122
- this.ticker = params.ticker || default_ticker_1.defaultTicker, this.supportInteractiveLayer = !1 !== params.interactiveLayer,
123
- this.timeline = new animate_1.DefaultTimeline, this.ticker.addTimeline(this.timeline),
124
- this.timeline.pause(), params.optimize || (params.optimize = {}), this.optmize(params.optimize),
125
- params.background && (0, vutils_1.isString)(this._background) && this._background.includes("/") && this.setAttributes({
122
+ this.supportInteractiveLayer = !1 !== params.interactiveLayer, params.optimize || (params.optimize = {
123
+ animateMode: "performance"
124
+ }), this.optmize(params.optimize), params.background && (0, vutils_1.isString)(this._background) && this._background.includes("/") && this.setAttributes({
126
125
  background: this._background
127
- }), this.ticker.on("afterTick", this.afterTickCb);
126
+ }), this.initAnimate(params);
127
+ }
128
+ initAnimate(params) {
129
+ this.createTicker && this.createTimeline && (this.ticker = params.ticker || this.createTicker(this),
130
+ this.timeline = this.createTimeline(), this.ticker.addTimeline(this.timeline), this.ticker.on("tick", this.afterTickCb));
131
+ }
132
+ startAnimate() {
133
+ this.ticker && this.timeline && (this.ticker.start(), this.timeline.resume());
128
134
  }
129
135
  pauseRender(sr = -1) {
130
136
  this._skipRender = sr;
@@ -328,10 +334,9 @@ class Stage extends group_1.Group {
328
334
  }
329
335
  render(layers, params) {
330
336
  if ("released" === this.releaseStatus) return;
331
- this.ticker.start(), this.timeline.resume();
337
+ this.startAnimate();
332
338
  const state = this.state;
333
- this.state = "rendering", this.tickedBeforeRender || this.ticker.trySyncTickStatus(),
334
- this.layerService.prepareStageLayer(this), this._skipRender || (this.lastRenderparams = params,
339
+ this.state = "rendering", this.layerService.prepareStageLayer(this), this._skipRender || (this.lastRenderparams = params,
335
340
  this.hooks.beforeRender.call(this), this._skipRender || (this.renderLayerList(this.children),
336
341
  this.combineLayersToWindow(), this.nextFrameRenderLayerSet.clear()), this.hooks.afterRender.call(this)),
337
342
  this.state = state, this._skipRender && this._skipRender++;
@@ -356,7 +361,7 @@ class Stage extends group_1.Group {
356
361
  }
357
362
  _doRenderInThisFrame() {
358
363
  if ("released" === this.releaseStatus) return;
359
- this.timeline.resume(), this.ticker.start();
364
+ this.startAnimate();
360
365
  const state = this.state;
361
366
  this.state = "rendering", this.layerService.prepareStageLayer(this), this.nextFrameRenderLayerSet.size && !this._skipRender && (this.hooks.beforeRender.call(this),
362
367
  this._skipRender || (this.renderLayerList(Array.from(this.nextFrameRenderLayerSet.values()), this.lastRenderparams || {}),
@@ -434,21 +439,20 @@ class Stage extends group_1.Group {
434
439
  });
435
440
  return !(!(null == result ? void 0 : result.graphic) && !(null == result ? void 0 : result.group)) && result;
436
441
  }
437
- startAnimate(t) {
438
- throw new Error("暂不支持");
439
- }
440
442
  setToFrame(t) {
441
443
  throw new Error("暂不支持");
442
444
  }
443
445
  release() {
446
+ var _a, _b;
444
447
  super.release(), this.hooks.beforeRender.unTap("constructor", this.beforeRender),
445
448
  this.hooks.afterRender.unTap("constructor", this.afterRender), this.eventSystem && this.eventSystem.release(),
446
449
  this.layerService.releaseStage(this), this.pluginService.release(), this.forEach((layer => {
447
450
  layer.release();
448
451
  })), this.interactiveLayer && (this.interactiveLayer.forEachChildren((item => {
449
452
  item.setStage && item.setStage(null, null), this.interactiveLayer.removeChild(item);
450
- })), this.interactiveLayer.release()), this.window.release(), this.ticker.remTimeline(this.timeline),
451
- this.ticker.removeListener("afterTick", this.afterTickCb), this.renderService.renderTreeRoots = [];
453
+ })), this.interactiveLayer.release()), this.window.release(), null === (_a = this.ticker) || void 0 === _a || _a.remTimeline(null == this ? void 0 : this.timeline),
454
+ null === (_b = this.ticker) || void 0 === _b || _b.removeListener("afterTick", this.afterTickCb),
455
+ this.renderService.renderTreeRoots = [];
452
456
  }
453
457
  setStage(stage) {}
454
458
  dirty(b, matrix) {