@visactor/vrender-core 0.20.13-alpha.3 → 0.20.13
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/cjs/animate/custom-animate.js +2 -1
- package/cjs/animate/morphing.js +1 -1
- package/cjs/animate/timeline.js +1 -1
- package/cjs/canvas/empty-context.js +1 -2
- package/cjs/common/3d-interceptor.js +2 -1
- package/cjs/common/generator.js +1 -2
- package/cjs/common/render-command-list.js +2 -1
- package/cjs/common/text.js +1 -1
- package/cjs/common/utils.js +1 -2
- package/cjs/core/contributions/textMeasure/AtextMeasure.js +13 -5
- package/cjs/core/contributions/textMeasure/AtextMeasure.js.map +1 -1
- package/cjs/core/stage.d.ts +3 -0
- package/cjs/core/stage.js +11 -2
- package/cjs/core/stage.js.map +1 -1
- package/cjs/interface/stage.d.ts +1 -0
- package/cjs/interface/stage.js.map +1 -1
- package/cjs/plugins/builtin-plugin/auto-refresh-plugin.d.ts +16 -0
- package/cjs/plugins/builtin-plugin/auto-refresh-plugin.js +48 -0
- package/cjs/plugins/builtin-plugin/auto-refresh-plugin.js.map +1 -0
- package/dist/index.es.js +85 -4
- package/es/animate/custom-animate.js +2 -1
- package/es/animate/morphing.js +1 -1
- package/es/animate/timeline.js +1 -1
- package/es/canvas/empty-context.js +1 -2
- package/es/common/3d-interceptor.js +2 -1
- package/es/common/generator.js +1 -2
- package/es/common/render-command-list.js +2 -1
- package/es/common/text.js +1 -1
- package/es/common/utils.js +1 -2
- package/es/core/contributions/textMeasure/AtextMeasure.js +14 -4
- package/es/core/contributions/textMeasure/AtextMeasure.js.map +1 -1
- package/es/core/stage.d.ts +3 -0
- package/es/core/stage.js +12 -1
- package/es/core/stage.js.map +1 -1
- package/es/interface/stage.d.ts +1 -0
- package/es/interface/stage.js.map +1 -1
- package/es/plugins/builtin-plugin/auto-refresh-plugin.d.ts +16 -0
- package/es/plugins/builtin-plugin/auto-refresh-plugin.js +41 -0
- package/es/plugins/builtin-plugin/auto-refresh-plugin.js.map +1 -0
- package/package.json +1 -1
package/es/common/utils.js
CHANGED
|
@@ -10,6 +10,8 @@ import { DefaultTextAttribute, DefaultTextStyle } from "../../../graphic/config"
|
|
|
10
10
|
|
|
11
11
|
import { testLetter } from "../../../graphic/richtext/utils";
|
|
12
12
|
|
|
13
|
+
import { Logger } from "@visactor/vutils";
|
|
14
|
+
|
|
13
15
|
let ATextMeasure = class {
|
|
14
16
|
configure(service, env) {
|
|
15
17
|
this.canvas = service.canvas, this.context = service.context, service.bindTextMeasure(this);
|
|
@@ -117,6 +119,14 @@ let ATextMeasure = class {
|
|
|
117
119
|
return data;
|
|
118
120
|
}
|
|
119
121
|
_clipTextEnd(text, options, width, leftIdx, rightIdx) {
|
|
122
|
+
if (leftIdx === rightIdx) {
|
|
123
|
+
Logger.getInstance().warn(`【_clipTextEnd】不应该走到这里${text}, ${leftIdx}, ${rightIdx}`);
|
|
124
|
+
const subText = text.substring(0, rightIdx + 1);
|
|
125
|
+
return {
|
|
126
|
+
str: subText,
|
|
127
|
+
width: this.measureTextWidth(subText, options)
|
|
128
|
+
};
|
|
129
|
+
}
|
|
120
130
|
const middleIdx = Math.floor((leftIdx + rightIdx) / 2), subText = text.substring(0, middleIdx + 1), strWidth = this.measureTextWidth(subText, options);
|
|
121
131
|
let length;
|
|
122
132
|
if (strWidth > width) {
|
|
@@ -147,25 +157,25 @@ let ATextMeasure = class {
|
|
|
147
157
|
};
|
|
148
158
|
}
|
|
149
159
|
_clipTextStart(text, options, width, leftIdx, rightIdx) {
|
|
150
|
-
const middleIdx = Math.ceil((leftIdx + rightIdx) / 2), subText = text.substring(middleIdx - 1, text.length
|
|
160
|
+
const middleIdx = Math.ceil((leftIdx + rightIdx) / 2), subText = text.substring(middleIdx - 1, text.length), strWidth = this.measureTextWidth(subText, options);
|
|
151
161
|
let length;
|
|
152
162
|
if (strWidth > width) {
|
|
153
163
|
if (subText.length <= 1) return {
|
|
154
164
|
str: "",
|
|
155
165
|
width: 0
|
|
156
166
|
};
|
|
157
|
-
const str = text.substring(middleIdx, text.length
|
|
167
|
+
const str = text.substring(middleIdx, text.length);
|
|
158
168
|
return length = this.measureTextWidth(str, options), length <= width ? {
|
|
159
169
|
str: str,
|
|
160
170
|
width: length
|
|
161
|
-
} : this._clipTextStart(text, options, width, middleIdx, text.length
|
|
171
|
+
} : this._clipTextStart(text, options, width, middleIdx, text.length);
|
|
162
172
|
}
|
|
163
173
|
if (strWidth < width) {
|
|
164
174
|
if (middleIdx <= 0) return {
|
|
165
175
|
str: text,
|
|
166
176
|
width: this.measureTextWidth(text, options)
|
|
167
177
|
};
|
|
168
|
-
const str = text.substring(middleIdx - 2, text.length
|
|
178
|
+
const str = text.substring(middleIdx - 2, text.length);
|
|
169
179
|
return length = this.measureTextWidth(str, options), length >= width ? {
|
|
170
180
|
str: subText,
|
|
171
181
|
width: strWidth
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/contributions/textMeasure/AtextMeasure.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAI5D,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAGtD,IAAM,YAAY,GAAlB,MAAM,YAAY;IAKvB,SAAS,CAAC,OAAqB,EAAE,GAAY;QAC3C,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAOD,gBAAgB,CAAC,IAAY,EAAE,OAAwB;QACrD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC;SAC3C;QAC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,IAAI,EAAE;YAClC,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAChD,IAAI,KAAK,KAAK,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE;gBAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;gBACvC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;aACvD;SACF;aAAM,IAAI,WAAW,IAAI,IAAI,CAAC,GAAG,KAAK,IAAI,EAAE;YAC3C,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,MAAM,CAAC;SAC7B;QACD,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,MAAO,CAAC;QACxB,IAAI,CAAC,KAAK,IAAI,WAAW,CAAC;QAC1B,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAvdY,YAAY;IADxB,UAAU,EAAE;GACA,YAAY,CAudxB;SAvdY,YAAY","file":"AtextMeasure.js","sourcesContent":["import { injectable } from '../../../common/inversify-lite';\nimport type { IGraphicUtil } from '../../../interface/core';\nimport type { ICanvas, IContext2d, EnvType } from '../../../interface';\nimport type { TextOptionsType, ITextMeasure } from '../../../interface/text';\nimport { DefaultTextAttribute, DefaultTextStyle } from '../../../graphic/config';\nimport { testLetter } from '../../../graphic/richtext/utils';\n\n@injectable()\nexport class ATextMeasure implements ITextMeasure {\n release: (...params: any) => void;\n protected canvas?: ICanvas;\n protected context?: IContext2d | null;\n\n configure(service: IGraphicUtil, env: EnvType): void {\n this.canvas = service.canvas;\n this.context = service.context;\n service.bindTextMeasure(this);\n }\n\n /**\n * 获取text宽度,measureText.width\n * @param text\n * @param options\n */\n measureTextWidth(text: string, options: TextOptionsType): number {\n if (!this.context) {\n return this.estimate(text, options).width;\n }\n this.context.setTextStyleWithoutAlignBaseline(options);\n const textMeasure = this.context.measureText(text);\n return textMeasure.width;\n }\n\n // 估算文字长度\n estimate(\n text: string,\n { fontSize = DefaultTextAttribute.fontSize }: TextOptionsType\n ): { width: number; height: number } {\n // 假设只有英文和中文字符\n let eCharLen = 0; // 英文字符\n let cCharLen = 0; // 中文字符\n // 判断ascii码,如果是\n for (let i = 0; i < text.length; i++) {\n text.charCodeAt(i) < 128 ? eCharLen++ : cCharLen++;\n }\n return {\n width: ~~(0.8 * eCharLen * fontSize + cCharLen * fontSize),\n height: fontSize\n };\n }\n\n /**\n * 获取text像素高度,基于actualBoundingBoxAscent和actualBoundingBoxDescent\n * @param text\n * @param options\n */\n measureTextPixelHeight(text: string, options: TextOptionsType): number {\n if (!this.context) {\n return options.fontSize ?? DefaultTextStyle.fontSize;\n }\n this.context.setTextStyleWithoutAlignBaseline(options);\n const textMeasure = this.context.measureText(text);\n return Math.abs((textMeasure as any).actualBoundingBoxAscent - (textMeasure as any).actualBoundingBoxDescent);\n }\n\n /**\n * 获取text包围盒的高度,基于fontBoundingBoxAscent和fontBoundingBoxDescent\n * @param text\n * @param options\n */\n measureTextBoundHieght(text: string, options: TextOptionsType): number {\n if (!this.context) {\n return options.fontSize ?? DefaultTextStyle.fontSize;\n }\n this.context.setTextStyleWithoutAlignBaseline(options);\n const textMeasure = this.context.measureText(text);\n return Math.abs((textMeasure as any).fontBoundingBoxAscent - (textMeasure as any).fontBoundingBoxDescent);\n }\n\n /**\n * 获取text测量对象\n * @param text\n * @param options\n */\n measureText(text: string, options: TextOptionsType): TextMetrics | { width: number } {\n if (!this.context) {\n return this.estimate(text, options);\n }\n this.context.setTextStyleWithoutAlignBaseline(options);\n return this.context.measureText(text);\n }\n\n clipTextVertical(\n verticalList: { text: string; width?: number; direction: number }[],\n options: TextOptionsType,\n width: number,\n wordBreak: boolean\n ): {\n verticalList: { text: string; width?: number; direction: number }[];\n width: number;\n } {\n if (verticalList.length === 0) {\n return { verticalList, width: 0 };\n }\n const { fontSize = 12 } = options;\n // 计算每一个区域的width\n verticalList.forEach(item => {\n item.width = item.direction === 0 ? fontSize : this.measureTextWidth(item.text, options);\n });\n const out: { text: string; width?: number; direction: number }[] = [];\n let length = 0;\n let i = 0;\n for (; i < verticalList.length; i++) {\n if (length + verticalList[i].width < width) {\n length += verticalList[i].width;\n out.push(verticalList[i]);\n } else {\n break;\n }\n }\n if (verticalList[i] && verticalList[i].text.length > 1) {\n const clipedData = this._clipText(\n verticalList[i].text,\n options,\n width - length,\n 0,\n verticalList[i].text.length - 1,\n 'end',\n false\n );\n if (wordBreak && clipedData.str !== verticalList[i].text) {\n let text = '';\n let length = 0;\n for (let j = 0; j < i; j++) {\n const item = verticalList[j];\n text += item.text;\n length += item.text.length;\n }\n text += verticalList[i].text;\n const totalLength = length + clipedData.str.length;\n let index = testLetter(text, totalLength);\n index = index - length;\n if (index !== clipedData.str.length - 1) {\n clipedData.str = clipedData.str.substring(0, index);\n clipedData.width = this.measureTextWidth(clipedData.str, options);\n }\n }\n out.push({ ...verticalList[i], text: clipedData.str, width: clipedData.width });\n length += clipedData.width;\n }\n\n return {\n verticalList: out,\n width: length\n };\n }\n\n /**\n * 将文本裁剪到width宽\n * @param text\n * @param options\n * @param width\n */\n clipText(\n text: string,\n options: TextOptionsType,\n width: number,\n wordBreak: boolean,\n keepAllBreak?: boolean\n ): {\n str: string;\n width: number;\n wordBreaked?: number;\n } {\n if (text.length === 0) {\n return { str: '', width: 0 };\n }\n let length = this.measureTextWidth(text, options);\n if (length <= width) {\n return { str: text, width: length };\n }\n length = this.measureTextWidth(text[0], options);\n if (length > width) {\n return { str: '', width: 0 };\n }\n const data = this._clipText(text, options, width, 0, text.length - 1, 'end', false);\n // 如果需要文字截断\n if (wordBreak && data.str !== text) {\n let index = testLetter(text, data.str.length, keepAllBreak);\n if (index !== data.str.length) {\n if (index > data.str.length) {\n (data as any).wordBreaked = index;\n index = data.str.length;\n }\n data.str = text.substring(0, index);\n data.width = this.measureTextWidth(data.str, options);\n }\n }\n return data;\n }\n\n // 二分法找到最佳宽\n // TODO: 后续考虑代码合并\n private _clipText(\n text: string,\n options: TextOptionsType,\n width: number,\n leftIdx: number,\n rightIdx: number,\n position: 'start' | 'end' | 'middle',\n suffix: string | false\n ): { str: string; width: number; result?: string } {\n let data: { str: string; width: number; result?: string };\n if (position === 'start') {\n data = this._clipTextStart(text, options, width, leftIdx, rightIdx);\n suffix && (data.result = suffix + data.str);\n } else if (position === 'middle') {\n const d = this._clipTextMiddle(text, options, width, '', '', 0, 0, 1);\n data = { str: 'none', width: d.width, result: d.left + suffix + d.right };\n } else {\n data = this._clipTextEnd(text, options, width, leftIdx, rightIdx);\n suffix && (data.result = data.str + suffix);\n }\n return data;\n }\n\n private _clipTextEnd(\n text: string,\n options: TextOptionsType,\n width: number,\n leftIdx: number,\n rightIdx: number\n ): { str: string; width: number } {\n const middleIdx = Math.floor((leftIdx + rightIdx) / 2);\n const subText = text.substring(0, middleIdx + 1);\n const strWidth = this.measureTextWidth(subText, options);\n let length: number;\n if (strWidth > width) {\n // 如果字符串的宽度大于限制宽度\n if (subText.length <= 1) {\n return { str: '', width: 0 };\n } // 如果子字符串长度小于1,而且大于给定宽的话,返回空字符串\n // 先判断是不是左侧的那个字符\n const str = text.substring(0, middleIdx);\n // 如果到左侧的字符小于或等于width,那么说明就是左侧的字符\n length = this.measureTextWidth(str, options);\n if (length <= width) {\n return { str, width: length };\n }\n // 返回leftIdx到middleIdx\n return this._clipTextEnd(text, options, width, leftIdx, middleIdx);\n } else if (strWidth < width) {\n // 如果字符串的宽度小于限制宽度\n if (middleIdx >= text.length - 1) {\n return { str: text, width: this.measureTextWidth(text, options) };\n } // 如果已经到结尾了,返回text\n // 先判断是不是右侧的那个字符\n const str = text.substring(0, middleIdx + 2);\n // 如果到右侧的字符大于或等于width,那么说明就是这个字符串\n length = this.measureTextWidth(str, options);\n if (length >= width) {\n return { str: subText, width: strWidth };\n }\n // 返回middleIdx到rightIdx\n return this._clipTextEnd(text, options, width, middleIdx, rightIdx);\n }\n // 如果相同,那么就找到text\n return { str: subText, width: strWidth };\n }\n\n private _clipTextStart(\n text: string,\n options: TextOptionsType,\n width: number,\n leftIdx: number,\n rightIdx: number\n ): { str: string; width: number } {\n const middleIdx = Math.ceil((leftIdx + rightIdx) / 2);\n const subText = text.substring(middleIdx - 1, text.length - 1);\n const strWidth = this.measureTextWidth(subText, options);\n let length: number;\n if (strWidth > width) {\n // 如果字符串的宽度大于限制宽度\n if (subText.length <= 1) {\n return { str: '', width: 0 };\n } // 如果子字符串长度小于1,而且大于给定宽的话,返回空字符串\n // 先判断是不是左侧的那个字符\n const str = text.substring(middleIdx, text.length - 1);\n // 如果到左侧的字符小于或等于width,那么说明就是左侧的字符\n length = this.measureTextWidth(str, options);\n if (length <= width) {\n return { str, width: length };\n }\n // 返回leftIdx到middleIdx\n return this._clipTextStart(text, options, width, middleIdx, text.length - 1);\n } else if (strWidth < width) {\n // 如果字符串的宽度小于限制宽度\n if (middleIdx <= 0) {\n return { str: text, width: this.measureTextWidth(text, options) };\n } // 如果已经到结尾了,返回text\n // 先判断是不是右侧的那个字符\n const str = text.substring(middleIdx - 2, text.length - 1);\n // 如果到右侧的字符大于或等于width,那么说明就是这个字符串\n length = this.measureTextWidth(str, options);\n if (length >= width) {\n return { str: subText, width: strWidth };\n }\n // 返回middleIdx到rightIdx\n return this._clipTextStart(text, options, width, leftIdx, middleIdx);\n }\n // 如果相同,那么就找到text\n return { str: subText, width: strWidth };\n }\n\n private _clipTextMiddle(\n text: string,\n options: TextOptionsType,\n width: number,\n left: string,\n right: string,\n leftW: number,\n rightW: number,\n buffer: number\n ): { left: string; right: string; width: number } {\n const subLeftText = text.substring(0, buffer);\n const strLeftWidth = this.measureTextWidth(subLeftText, options);\n if (strLeftWidth + rightW > width) {\n return { left, right, width: leftW + rightW };\n }\n const subRightText = text.substring(text.length - buffer, text.length);\n const strRightWidth = this.measureTextWidth(subRightText, options);\n if (strLeftWidth + strRightWidth > width) {\n return { left: subLeftText, right, width: strLeftWidth + rightW };\n }\n return this._clipTextMiddle(\n text,\n options,\n width,\n subLeftText,\n subRightText,\n strLeftWidth,\n strRightWidth,\n buffer + 1\n );\n }\n\n clipTextWithSuffixVertical(\n verticalList: { text: string; width?: number; direction: number }[],\n options: TextOptionsType,\n width: number,\n suffix: string,\n wordBreak: boolean,\n suffixPosition: 'start' | 'end' | 'middle'\n ): {\n verticalList: { text: string; width?: number; direction: number }[];\n width: number;\n } {\n if (suffix === '') {\n return this.clipTextVertical(verticalList, options, width, wordBreak);\n }\n if (verticalList.length === 0) {\n return { verticalList, width: 0 };\n }\n\n const output = this.clipTextVertical(verticalList, options, width, wordBreak);\n if (\n output.verticalList.length === verticalList.length &&\n output.verticalList[output.verticalList.length - 1].width === verticalList[verticalList.length - 1].width\n ) {\n return output;\n }\n\n const suffixWidth = this.measureTextWidth(suffix, options);\n if (suffixWidth > width) {\n return output;\n }\n\n width -= suffixWidth;\n\n let out;\n if (suffixPosition === 'start') {\n const nextVerticalList = this.revertVerticalList(verticalList);\n out = this.clipTextVertical(nextVerticalList, options, width, wordBreak);\n const v = this.revertVerticalList(out.verticalList);\n v.unshift({\n text: suffix,\n direction: 1,\n width: suffixWidth\n });\n out.verticalList = v;\n } else if (suffixPosition === 'middle') {\n const leftOut = this.clipTextVertical(verticalList, options, width / 2, wordBreak);\n const nextVerticalList = this.revertVerticalList(verticalList);\n const rightOut = this.clipTextVertical(nextVerticalList, options, width / 2, wordBreak);\n // 添加suffix\n leftOut.verticalList.push({\n text: suffix,\n direction: 1,\n width: suffixWidth\n });\n this.revertVerticalList(rightOut.verticalList).forEach(v => leftOut.verticalList.push(v));\n out = {\n verticalList: leftOut.verticalList,\n width: leftOut.width + rightOut.width\n };\n } else {\n out = this.clipTextVertical(verticalList, options, width, wordBreak);\n out.verticalList.push({\n text: suffix,\n direction: 1,\n width: suffixWidth\n });\n }\n out.width += suffixWidth;\n return out;\n }\n\n revertVerticalList(\n verticalList: {\n text: string;\n width?: number;\n direction: number;\n }[]\n ) {\n return verticalList.reverse().map(l => {\n const t = l.text.split('').reverse().join('');\n return {\n ...l,\n text: t\n };\n });\n }\n\n clipTextWithSuffix(\n text: string,\n options: TextOptionsType,\n width: number,\n suffix: string,\n wordBreak: boolean,\n position: 'start' | 'end' | 'middle',\n forceSuffix: boolean = false\n ): {\n str: string;\n width: number;\n } {\n if (suffix === '') {\n return this.clipText(text, options, width, wordBreak);\n }\n if (text.length === 0) {\n return { str: '', width: 0 };\n }\n const length = this.measureTextWidth(text, options);\n if (!forceSuffix && length <= width) {\n return { str: text, width: length };\n }\n const suffixWidth = this.measureTextWidth(suffix, options);\n if (suffixWidth > width) {\n return { str: '', width: 0 };\n }\n if (forceSuffix && length + suffixWidth <= width) {\n return { str: text + suffix, width: length + suffixWidth };\n }\n width -= suffixWidth;\n const data = this._clipText(text, options, width, 0, text.length - 1, position, suffix);\n\n // 如果需要文字截断\n if (wordBreak && data.str !== text) {\n const index = testLetter(text, data.str.length);\n if (index !== data.str.length) {\n data.result = text.substring(0, index);\n data.width = this.measureTextWidth(data.str, options);\n }\n } else if (forceSuffix && data.str === text) {\n data.result = text + suffix;\n }\n data.str = data.result!;\n data.width += suffixWidth;\n return data;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/core/contributions/textMeasure/AtextMeasure.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAI5D,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAGnC,IAAM,YAAY,GAAlB,MAAM,YAAY;IAKvB,SAAS,CAAC,OAAqB,EAAE,GAAY;QAC3C,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,C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B;SA9dY,YAAY","file":"AtextMeasure.js","sourcesContent":["import { injectable } from '../../../common/inversify-lite';\nimport type { IGraphicUtil } from '../../../interface/core';\nimport type { ICanvas, IContext2d, EnvType } from '../../../interface';\nimport type { TextOptionsType, ITextMeasure } from '../../../interface/text';\nimport { DefaultTextAttribute, DefaultTextStyle } from '../../../graphic/config';\nimport { testLetter } from '../../../graphic/richtext/utils';\nimport { Logger } from '@visactor/vutils';\n\n@injectable()\nexport class ATextMeasure implements ITextMeasure {\n release: (...params: any) => void;\n protected canvas?: ICanvas;\n protected context?: IContext2d | null;\n\n configure(service: IGraphicUtil, env: EnvType): void {\n this.canvas = service.canvas;\n this.context = service.context;\n service.bindTextMeasure(this);\n }\n\n /**\n * 获取text宽度,measureText.width\n * @param text\n * @param options\n */\n measureTextWidth(text: string, options: TextOptionsType): number {\n if (!this.context) {\n return this.estimate(text, options).width;\n }\n this.context.setTextStyleWithoutAlignBaseline(options);\n const textMeasure = this.context.measureText(text);\n return textMeasure.width;\n }\n\n // 估算文字长度\n estimate(\n text: string,\n { fontSize = DefaultTextAttribute.fontSize }: TextOptionsType\n ): { width: number; height: number } {\n // 假设只有英文和中文字符\n let eCharLen = 0; // 英文字符\n let cCharLen = 0; // 中文字符\n // 判断ascii码,如果是\n for (let i = 0; i < text.length; i++) {\n text.charCodeAt(i) < 128 ? eCharLen++ : cCharLen++;\n }\n return {\n width: ~~(0.8 * eCharLen * fontSize + cCharLen * fontSize),\n height: fontSize\n };\n }\n\n /**\n * 获取text像素高度,基于actualBoundingBoxAscent和actualBoundingBoxDescent\n * @param text\n * @param options\n */\n measureTextPixelHeight(text: string, options: TextOptionsType): number {\n if (!this.context) {\n return options.fontSize ?? DefaultTextStyle.fontSize;\n }\n this.context.setTextStyleWithoutAlignBaseline(options);\n const textMeasure = this.context.measureText(text);\n return Math.abs((textMeasure as any).actualBoundingBoxAscent - (textMeasure as any).actualBoundingBoxDescent);\n }\n\n /**\n * 获取text包围盒的高度,基于fontBoundingBoxAscent和fontBoundingBoxDescent\n * @param text\n * @param options\n */\n measureTextBoundHieght(text: string, options: TextOptionsType): number {\n if (!this.context) {\n return options.fontSize ?? DefaultTextStyle.fontSize;\n }\n this.context.setTextStyleWithoutAlignBaseline(options);\n const textMeasure = this.context.measureText(text);\n return Math.abs((textMeasure as any).fontBoundingBoxAscent - (textMeasure as any).fontBoundingBoxDescent);\n }\n\n /**\n * 获取text测量对象\n * @param text\n * @param options\n */\n measureText(text: string, options: TextOptionsType): TextMetrics | { width: number } {\n if (!this.context) {\n return this.estimate(text, options);\n }\n this.context.setTextStyleWithoutAlignBaseline(options);\n return this.context.measureText(text);\n }\n\n clipTextVertical(\n verticalList: { text: string; width?: number; direction: number }[],\n options: TextOptionsType,\n width: number,\n wordBreak: boolean\n ): {\n verticalList: { text: string; width?: number; direction: number }[];\n width: number;\n } {\n if (verticalList.length === 0) {\n return { verticalList, width: 0 };\n }\n const { fontSize = 12 } = options;\n // 计算每一个区域的width\n verticalList.forEach(item => {\n item.width = item.direction === 0 ? fontSize : this.measureTextWidth(item.text, options);\n });\n const out: { text: string; width?: number; direction: number }[] = [];\n let length = 0;\n let i = 0;\n for (; i < verticalList.length; i++) {\n if (length + verticalList[i].width < width) {\n length += verticalList[i].width;\n out.push(verticalList[i]);\n } else {\n break;\n }\n }\n if (verticalList[i] && verticalList[i].text.length > 1) {\n const clipedData = this._clipText(\n verticalList[i].text,\n options,\n width - length,\n 0,\n verticalList[i].text.length - 1,\n 'end',\n false\n );\n if (wordBreak && clipedData.str !== verticalList[i].text) {\n let text = '';\n let length = 0;\n for (let j = 0; j < i; j++) {\n const item = verticalList[j];\n text += item.text;\n length += item.text.length;\n }\n text += verticalList[i].text;\n const totalLength = length + clipedData.str.length;\n let index = testLetter(text, totalLength);\n index = index - length;\n if (index !== clipedData.str.length - 1) {\n clipedData.str = clipedData.str.substring(0, index);\n clipedData.width = this.measureTextWidth(clipedData.str, options);\n }\n }\n out.push({ ...verticalList[i], text: clipedData.str, width: clipedData.width });\n length += clipedData.width;\n }\n\n return {\n verticalList: out,\n width: length\n };\n }\n\n /**\n * 将文本裁剪到width宽\n * @param text\n * @param options\n * @param width\n */\n clipText(\n text: string,\n options: TextOptionsType,\n width: number,\n wordBreak: boolean,\n keepAllBreak?: boolean\n ): {\n str: string;\n width: number;\n wordBreaked?: number;\n } {\n if (text.length === 0) {\n return { str: '', width: 0 };\n }\n let length = this.measureTextWidth(text, options);\n if (length <= width) {\n return { str: text, width: length };\n }\n length = this.measureTextWidth(text[0], options);\n if (length > width) {\n return { str: '', width: 0 };\n }\n const data = this._clipText(text, options, width, 0, text.length - 1, 'end', false);\n // 如果需要文字截断\n if (wordBreak && data.str !== text) {\n let index = testLetter(text, data.str.length, keepAllBreak);\n if (index !== data.str.length) {\n if (index > data.str.length) {\n (data as any).wordBreaked = index;\n index = data.str.length;\n }\n data.str = text.substring(0, index);\n data.width = this.measureTextWidth(data.str, options);\n }\n }\n return data;\n }\n\n // 二分法找到最佳宽\n // TODO: 后续考虑代码合并\n private _clipText(\n text: string,\n options: TextOptionsType,\n width: number,\n leftIdx: number,\n rightIdx: number,\n position: 'start' | 'end' | 'middle',\n suffix: string | false\n ): { str: string; width: number; result?: string } {\n let data: { str: string; width: number; result?: string };\n if (position === 'start') {\n data = this._clipTextStart(text, options, width, leftIdx, rightIdx);\n suffix && (data.result = suffix + data.str);\n } else if (position === 'middle') {\n const d = this._clipTextMiddle(text, options, width, '', '', 0, 0, 1);\n data = { str: 'none', width: d.width, result: d.left + suffix + d.right };\n } else {\n data = this._clipTextEnd(text, options, width, leftIdx, rightIdx);\n suffix && (data.result = data.str + suffix);\n }\n return data;\n }\n\n private _clipTextEnd(\n text: string,\n options: TextOptionsType,\n width: number,\n leftIdx: number,\n rightIdx: number\n ): { str: string; width: number } {\n // 添加退出条件,如果leftIdx和rightIdx相等,那么就返回这个字符串(理论上这时出问题了)\n if (leftIdx === rightIdx) {\n Logger.getInstance().warn(`【_clipTextEnd】不应该走到这里${text}, ${leftIdx}, ${rightIdx}`);\n // console.warn(`【_clipTextEnd】不应该走到这里${text}, ${leftIdx}, ${rightIdx}`);\n const subText = text.substring(0, rightIdx + 1);\n return { str: subText, width: this.measureTextWidth(subText, options) };\n }\n const middleIdx = Math.floor((leftIdx + rightIdx) / 2);\n const subText = text.substring(0, middleIdx + 1);\n const strWidth = this.measureTextWidth(subText, options);\n let length: number;\n if (strWidth > width) {\n // 如果字符串的宽度大于限制宽度\n if (subText.length <= 1) {\n return { str: '', width: 0 };\n } // 如果子字符串长度小于1,而且大于给定宽的话,返回空字符串\n // 先判断是不是左侧的那个字符\n const str = text.substring(0, middleIdx);\n // 如果到左侧的字符小于或等于width,那么说明就是左侧的字符\n length = this.measureTextWidth(str, options);\n if (length <= width) {\n return { str, width: length };\n }\n // 返回leftIdx到middleIdx\n return this._clipTextEnd(text, options, width, leftIdx, middleIdx);\n } else if (strWidth < width) {\n // 如果字符串的宽度小于限制宽度\n if (middleIdx >= text.length - 1) {\n return { str: text, width: this.measureTextWidth(text, options) };\n } // 如果已经到结尾了,返回text\n // 先判断是不是右侧的那个字符\n const str = text.substring(0, middleIdx + 2);\n // 如果到右侧的字符大于或等于width,那么说明就是这个字符串\n length = this.measureTextWidth(str, options);\n if (length >= width) {\n return { str: subText, width: strWidth };\n }\n // 返回middleIdx到rightIdx\n return this._clipTextEnd(text, options, width, middleIdx, rightIdx);\n }\n // 如果相同,那么就找到text\n return { str: subText, width: strWidth };\n }\n\n private _clipTextStart(\n text: string,\n options: TextOptionsType,\n width: number,\n leftIdx: number,\n rightIdx: number\n ): { str: string; width: number } {\n const middleIdx = Math.ceil((leftIdx + rightIdx) / 2);\n const subText = text.substring(middleIdx - 1, text.length);\n const strWidth = this.measureTextWidth(subText, options);\n let length: number;\n if (strWidth > width) {\n // 如果字符串的宽度大于限制宽度\n if (subText.length <= 1) {\n return { str: '', width: 0 };\n } // 如果子字符串长度小于1,而且大于给定宽的话,返回空字符串\n // 先判断是不是左侧的那个字符\n const str = text.substring(middleIdx, text.length);\n // 如果到左侧的字符小于或等于width,那么说明就是左侧的字符\n length = this.measureTextWidth(str, options);\n if (length <= width) {\n return { str, width: length };\n }\n // 返回leftIdx到middleIdx\n return this._clipTextStart(text, options, width, middleIdx, text.length);\n } else if (strWidth < width) {\n // 如果字符串的宽度小于限制宽度\n if (middleIdx <= 0) {\n return { str: text, width: this.measureTextWidth(text, options) };\n } // 如果已经到结尾了,返回text\n // 先判断是不是右侧的那个字符\n const str = text.substring(middleIdx - 2, text.length);\n // 如果到右侧的字符大于或等于width,那么说明就是这个字符串\n length = this.measureTextWidth(str, options);\n if (length >= width) {\n return { str: subText, width: strWidth };\n }\n // 返回middleIdx到rightIdx\n return this._clipTextStart(text, options, width, leftIdx, middleIdx);\n }\n // 如果相同,那么就找到text\n return { str: subText, width: strWidth };\n }\n\n private _clipTextMiddle(\n text: string,\n options: TextOptionsType,\n width: number,\n left: string,\n right: string,\n leftW: number,\n rightW: number,\n buffer: number\n ): { left: string; right: string; width: number } {\n const subLeftText = text.substring(0, buffer);\n const strLeftWidth = this.measureTextWidth(subLeftText, options);\n if (strLeftWidth + rightW > width) {\n return { left, right, width: leftW + rightW };\n }\n const subRightText = text.substring(text.length - buffer, text.length);\n const strRightWidth = this.measureTextWidth(subRightText, options);\n if (strLeftWidth + strRightWidth > width) {\n return { left: subLeftText, right, width: strLeftWidth + rightW };\n }\n return this._clipTextMiddle(\n text,\n options,\n width,\n subLeftText,\n subRightText,\n strLeftWidth,\n strRightWidth,\n buffer + 1\n );\n }\n\n clipTextWithSuffixVertical(\n verticalList: { text: string; width?: number; direction: number }[],\n options: TextOptionsType,\n width: number,\n suffix: string,\n wordBreak: boolean,\n suffixPosition: 'start' | 'end' | 'middle'\n ): {\n verticalList: { text: string; width?: number; direction: number }[];\n width: number;\n } {\n if (suffix === '') {\n return this.clipTextVertical(verticalList, options, width, wordBreak);\n }\n if (verticalList.length === 0) {\n return { verticalList, width: 0 };\n }\n\n const output = this.clipTextVertical(verticalList, options, width, wordBreak);\n if (\n output.verticalList.length === verticalList.length &&\n output.verticalList[output.verticalList.length - 1].width === verticalList[verticalList.length - 1].width\n ) {\n return output;\n }\n\n const suffixWidth = this.measureTextWidth(suffix, options);\n if (suffixWidth > width) {\n return output;\n }\n\n width -= suffixWidth;\n\n let out;\n if (suffixPosition === 'start') {\n const nextVerticalList = this.revertVerticalList(verticalList);\n out = this.clipTextVertical(nextVerticalList, options, width, wordBreak);\n const v = this.revertVerticalList(out.verticalList);\n v.unshift({\n text: suffix,\n direction: 1,\n width: suffixWidth\n });\n out.verticalList = v;\n } else if (suffixPosition === 'middle') {\n const leftOut = this.clipTextVertical(verticalList, options, width / 2, wordBreak);\n const nextVerticalList = this.revertVerticalList(verticalList);\n const rightOut = this.clipTextVertical(nextVerticalList, options, width / 2, wordBreak);\n // 添加suffix\n leftOut.verticalList.push({\n text: suffix,\n direction: 1,\n width: suffixWidth\n });\n this.revertVerticalList(rightOut.verticalList).forEach(v => leftOut.verticalList.push(v));\n out = {\n verticalList: leftOut.verticalList,\n width: leftOut.width + rightOut.width\n };\n } else {\n out = this.clipTextVertical(verticalList, options, width, wordBreak);\n out.verticalList.push({\n text: suffix,\n direction: 1,\n width: suffixWidth\n });\n }\n out.width += suffixWidth;\n return out;\n }\n\n revertVerticalList(\n verticalList: {\n text: string;\n width?: number;\n direction: number;\n }[]\n ) {\n return verticalList.reverse().map(l => {\n const t = l.text.split('').reverse().join('');\n return {\n ...l,\n text: t\n };\n });\n }\n\n clipTextWithSuffix(\n text: string,\n options: TextOptionsType,\n width: number,\n suffix: string,\n wordBreak: boolean,\n position: 'start' | 'end' | 'middle',\n forceSuffix: boolean = false\n ): {\n str: string;\n width: number;\n } {\n if (suffix === '') {\n return this.clipText(text, options, width, wordBreak);\n }\n if (text.length === 0) {\n return { str: '', width: 0 };\n }\n const length = this.measureTextWidth(text, options);\n if (!forceSuffix && length <= width) {\n return { str: text, width: length };\n }\n const suffixWidth = this.measureTextWidth(suffix, options);\n if (suffixWidth > width) {\n return { str: '', width: 0 };\n }\n if (forceSuffix && length + suffixWidth <= width) {\n return { str: text + suffix, width: length + suffixWidth };\n }\n width -= suffixWidth;\n const data = this._clipText(text, options, width, 0, text.length - 1, position, suffix);\n\n // 如果需要文字截断\n if (wordBreak && data.str !== text) {\n const index = testLetter(text, data.str.length);\n if (index !== data.str.length) {\n data.result = text.substring(0, index);\n data.width = this.measureTextWidth(data.str, options);\n }\n } else if (forceSuffix && data.str === text) {\n data.result = text + suffix;\n }\n data.str = data.result!;\n data.width += suffixWidth;\n return data;\n }\n}\n"]}
|
package/es/core/stage.d.ts
CHANGED
|
@@ -41,6 +41,7 @@ export declare class Stage extends Group implements IStage {
|
|
|
41
41
|
get defaultLayer(): ILayer;
|
|
42
42
|
ticker: ITicker;
|
|
43
43
|
autoRender: boolean;
|
|
44
|
+
autoRefresh: boolean;
|
|
44
45
|
_enableLayout: boolean;
|
|
45
46
|
htmlAttribute: boolean | string | any;
|
|
46
47
|
reactAttribute: boolean | string | any;
|
|
@@ -104,6 +105,8 @@ export declare class Stage extends Group implements IStage {
|
|
|
104
105
|
disableView3dTranform(): void;
|
|
105
106
|
enableAutoRender(): void;
|
|
106
107
|
disableAutoRender(): void;
|
|
108
|
+
enableAutoRefresh(): void;
|
|
109
|
+
disableAutoRefresh(): void;
|
|
107
110
|
enableIncrementalAutoRender(): void;
|
|
108
111
|
disableIncrementalAutoRender(): void;
|
|
109
112
|
enableDirtyBounds(): void;
|
package/es/core/stage.js
CHANGED
|
@@ -18,6 +18,8 @@ import { PluginService } from "../plugins/constants";
|
|
|
18
18
|
|
|
19
19
|
import { AutoRenderPlugin } from "../plugins/builtin-plugin/auto-render-plugin";
|
|
20
20
|
|
|
21
|
+
import { AutoRefreshPlugin } from "../plugins/builtin-plugin/auto-refresh-plugin";
|
|
22
|
+
|
|
21
23
|
import { IncrementalAutoRenderPlugin } from "../plugins/builtin-plugin/incremental-auto-render-plugin";
|
|
22
24
|
|
|
23
25
|
import { DirtyBoundsPlugin } from "../plugins/builtin-plugin/dirty-bounds-plugin";
|
|
@@ -143,7 +145,8 @@ export class Stage extends Group {
|
|
|
143
145
|
main: !0
|
|
144
146
|
})), this.nextFrameRenderLayerSet = new Set, this.willNextFrameRender = !1, this.stage = this,
|
|
145
147
|
this.renderStyle = params.renderStyle, params.autoRender && this.enableAutoRender(),
|
|
146
|
-
|
|
148
|
+
params.autoRefresh && this.enableAutoRefresh(), !1 === params.disableDirtyBounds && this.enableDirtyBounds(),
|
|
149
|
+
params.enableHtmlAttribute && this.enableHtmlAttribute(params.enableHtmlAttribute),
|
|
147
150
|
params.ReactDOM && this.enableReactAttribute(params.ReactDOM), params.enableLayout && this.enableLayout(),
|
|
148
151
|
this.hooks.beforeRender.tap("constructor", this.beforeRender), this.hooks.afterRender.tap("constructor", this.afterRender),
|
|
149
152
|
this._beforeRender = params.beforeRender, this._afterRender = params.afterRender,
|
|
@@ -257,6 +260,14 @@ export class Stage extends Group {
|
|
|
257
260
|
this.pluginService.unRegister(plugin);
|
|
258
261
|
})));
|
|
259
262
|
}
|
|
263
|
+
enableAutoRefresh() {
|
|
264
|
+
this.autoRefresh || (this.autoRefresh = !0, this.pluginService.register(new AutoRefreshPlugin));
|
|
265
|
+
}
|
|
266
|
+
disableAutoRefresh() {
|
|
267
|
+
this.autoRefresh && (this.autoRefresh = !1, this.pluginService.findPluginsByName("AutoRefreshPlugin").forEach((plugin => {
|
|
268
|
+
this.pluginService.unRegister(plugin);
|
|
269
|
+
})));
|
|
270
|
+
}
|
|
260
271
|
enableIncrementalAutoRender() {
|
|
261
272
|
this.increaseAutoRender || (this.increaseAutoRender = !0, this.pluginService.register(new IncrementalAutoRenderPlugin));
|
|
262
273
|
}
|
package/es/core/stage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/stage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAk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or/vutils';\nimport { Bounds, Point, isString } from '@visactor/vutils';\nimport type {\n IGraphic,\n IExportType,\n IStage,\n IStageParams,\n ILayer,\n IColor,\n IGlobal,\n IOption3D,\n ICamera,\n vec3,\n IDirectionLight,\n ITicker,\n IRenderService,\n IPickerService,\n IPluginService,\n ISyncHook,\n IDrawContext,\n IWindow,\n ILayerService,\n ITimeline,\n IOptimizeType,\n LayerMode,\n PickResult,\n IPlugin\n} from '../interface';\nimport { VWindow } from './window';\nimport type { Layer } from './layer';\nimport { EventSystem } from '../event';\nimport { container } from '../container';\nimport { RenderService } from '../render';\nimport { Group } from '../graphic/group';\nimport { Theme } from '../graphic/theme';\nimport { PickerService } from '../picker/constants';\nimport { PluginService } from '../plugins/constants';\nimport { AutoRenderPlugin } from '../plugins/builtin-plugin/auto-render-plugin';\nimport { IncrementalAutoRenderPlugin } from '../plugins/builtin-plugin/incremental-auto-render-plugin';\nimport { DirtyBoundsPlugin } from '../plugins/builtin-plugin/dirty-bounds-plugin';\nimport { defaultTicker } from '../animate/default-ticker';\nimport { SyncHook } from '../tapable';\nimport { LayerService } from './constants';\nimport { DefaultTimeline } from '../animate';\nimport { application } from '../application';\nimport { isBrowserEnv } from '../env-check';\nimport { Factory } from '../factory';\n\nconst DefaultConfig = {\n WIDTH: 500,\n HEIGHT: 500,\n X: 0,\n Y: 0,\n BACKGROUND: 'white'\n};\n\ntype IStageState = 'rendering' | 'normal';\n\n/**\n * Stage是一个舞台或一个视口,并不直接对应一个或多个Canvas,逻辑上和Canvas无关\n *\n * 1. Stage对应一个Canvas的整体,Stage的宽高即为Canvas的宽高\n * 2. Stage小于Canvas,Stage作为Canvas某个区域的视口,只管理这个区域\n * 3. 多图层时Stage的多个图层对应多个Canvas\n *\n * 原生环境下Stage可以拥有一个Window或者使用Window的一块区域\n *\n * 【注】如果希望获取完整的Canvas或窗口或者调整窗口信息,请使用Window模块\n */\nexport class Stage extends Group implements IStage {\n declare parent: IStage | null;\n\n declare state: IStageState;\n\n private _background: string | IColor;\n protected nextFrameRenderLayerSet: Set<Layer>;\n protected willNextFrameRender: boolean;\n protected _cursor: string;\n renderCount: number;\n dirtyBounds: IBounds | null;\n option3d?: IOption3D;\n declare light?: IDirectionLight;\n declare camera?: ICamera;\n declare renderStyle?: string;\n\n declare hooks: {\n beforeRender: ISyncHook<[IStage]>;\n afterRender: ISyncHook<[IStage]>;\n };\n\n set viewBox(b: IBoundsLike) {\n this.window.setViewBox(b);\n }\n get viewBox(): IAABBBounds {\n return this.window.getViewBox();\n }\n\n /**\n * @deprecated 不建议使用\n */\n get x(): number {\n return this.window.getViewBox().x1;\n }\n /**\n * @deprecated 不建议使用\n */\n set x(x: number) {\n const b = this.window.getViewBox();\n b.translate(x - b.x1, 0);\n this.window.setViewBox(b);\n }\n /**\n * @deprecated 不建议使用\n */\n get y(): number {\n return this.window.getViewBox().y1;\n }\n /**\n * @deprecated 不建议使用\n */\n set y(y: number) {\n const b = this.window.getViewBox();\n b.translate(0, y - b.y1);\n this.window.setViewBox(b);\n }\n get width(): number {\n return this.window.width;\n }\n set width(w: number) {\n this.resize(w, this.height);\n }\n get viewWidth(): number {\n return this.window.getViewBox().width();\n }\n set viewWidth(w: number) {\n this.resizeView(w, this.viewHeight);\n }\n get viewHeight(): number {\n return this.window.getViewBox().height();\n }\n set viewHeight(h: number) {\n this.resizeView(this.viewWidth, h);\n }\n get height(): number {\n return this.window.height;\n }\n set height(h: number) {\n this.resize(this.width, h);\n }\n get dpr(): number {\n return this.window.dpr;\n }\n set dpr(r: number) {\n this.setDpr(r);\n }\n get background(): string | IColor {\n return this._background ?? DefaultConfig.BACKGROUND;\n }\n set background(b: string | IColor) {\n this._background = b;\n }\n get defaultLayer(): ILayer {\n return this.at(0) as unknown as ILayer;\n }\n\n ticker: ITicker;\n\n autoRender: boolean;\n _enableLayout: boolean;\n htmlAttribute: boolean | string | any;\n reactAttribute: boolean | string | any;\n increaseAutoRender: boolean;\n view3dTranform: boolean;\n readonly window: IWindow;\n private readonly global: IGlobal;\n readonly renderService: IRenderService;\n protected pickerService?: IPickerService;\n readonly pluginService: IPluginService;\n readonly layerService: ILayerService;\n private _eventSystem?: EventSystem;\n private get eventSystem(): EventSystem {\n return this._eventSystem;\n }\n\n protected _beforeRender?: (stage: IStage) => void;\n protected _afterRender?: (stage: IStage) => void;\n // 0: 正常渲染, > 0: 跳过隐藏canvas的渲染, < 0: 禁止渲染\n protected _skipRender?: number;\n protected _afterNextRenderCbs?: ((stage: IStage) => void)[];\n protected lastRenderparams?: Partial<IDrawContext>;\n\n protected interactiveLayer?: ILayer;\n protected supportInteractiveLayer: boolean;\n protected timeline: ITimeline;\n\n declare params: Partial<IStageParams>;\n\n /**\n * 所有属性都具有默认值。\n * Canvas为字符串或者Canvas元素,那么默认图层就会绑定到这个Canvas上\n * 如果不传入Canvas,那么会新建一个Canvas,用户可以通过Window模块管理这个Canvas\n * 1. 如果没有传入宽高,那么默认为canvas宽高,如果传入了宽高则stage使用传入宽高作为视口宽高\n * @param params\n */\n constructor(params: Partial<IStageParams> = {}) {\n super({});\n this.params = params;\n this.theme = new Theme();\n this.hooks = {\n beforeRender: new SyncHook(['stage']),\n afterRender: new SyncHook(['stage'])\n };\n this.global = application.global;\n if (!this.global.env && isBrowserEnv()) {\n // 如果是浏览器环境,默认设置env\n this.global.setEnv('browser');\n }\n this.window = container.get<IWindow>(VWindow);\n this.renderService = container.get<IRenderService>(RenderService);\n this.pluginService = container.get<IPluginService>(PluginService);\n this.layerService = container.get<ILayerService>(LayerService);\n this.pluginService.active(this, params);\n\n this.window.create({\n width: params.width,\n height: params.height,\n viewBox: params.viewBox,\n container: params.container,\n dpr: params.dpr || this.global.devicePixelRatio,\n canvasControled: params.canvasControled !== false,\n title: params.title || '',\n canvas: params.canvas\n });\n\n this.state = 'normal';\n this.renderCount = 0;\n this.tryInitEventSystem();\n // // 没有传入xy就默认为0\n // this._x = params.x ?? DefaultConfig.X;\n // this._y = params.y ?? DefaultConfig.Y;\n // // 没有传入view的宽高则默认为window的宽高\n // this._viewWidth = params.viewWidth ?? this.window.width;\n // this._viewHeight = params.viewHeight ?? this.window.height;\n // this._AABBBounds.set(this._x, this._y, this._viewWidth + this._x, this._viewHeight + this._y);\n // 背景色默认为纯白色\n this._background = params.background ?? DefaultConfig.BACKGROUND;\n\n // 创建一个默认layer图层\n // this.appendChild(new Layer(this, this.global, this.window, { main: true }));\n this.appendChild(this.layerService.createLayer(this, { main: true }));\n\n this.nextFrameRenderLayerSet = new Set();\n this.willNextFrameRender = false;\n this.stage = this;\n this.renderStyle = params.renderStyle;\n\n // this.autoRender = params.autoRender;\n if (params.autoRender) {\n this.enableAutoRender();\n }\n // 默认不开启dirtyBounds\n if (params.disableDirtyBounds === false) {\n this.enableDirtyBounds();\n }\n\n if (params.enableHtmlAttribute) {\n this.enableHtmlAttribute(params.enableHtmlAttribute);\n }\n if (params.ReactDOM) {\n this.enableReactAttribute(params.ReactDOM);\n }\n\n params.enableLayout && this.enableLayout();\n this.hooks.beforeRender.tap('constructor', this.beforeRender);\n this.hooks.afterRender.tap('constructor', this.afterRender);\n this._beforeRender = params.beforeRender;\n this._afterRender = params.afterRender;\n this.ticker = params.ticker || defaultTicker;\n this.supportInteractiveLayer = params.interactiveLayer !== false;\n this.timeline = new DefaultTimeline();\n this.ticker.addTimeline(this.timeline);\n this.timeline.pause();\n if (!params.optimize) {\n params.optimize = {};\n }\n this.optmize(params.optimize);\n // 如果背景是图片,触发加载图片操作\n if (params.background && isString(this._background) && this._background.includes('/')) {\n this.setAttributes({ background: this._background });\n }\n }\n\n pauseRender(sr: number = -1) {\n this._skipRender = sr;\n }\n\n resumeRender() {\n this._skipRender = 0;\n }\n\n protected tryInitEventSystem() {\n if (this.global.supportEvent && !this._eventSystem) {\n this._eventSystem = new EventSystem({\n targetElement: this.window,\n resolution: this.window.dpr || this.global.devicePixelRatio,\n rootNode: this as any,\n global: this.global,\n supportsPointerEvents: this.params.supportsPointerEvents,\n supportsTouchEvents: this.params.supportsTouchEvents,\n ...this.params.event\n });\n }\n }\n\n preventRender(prevent: boolean) {\n if (prevent) {\n this._skipRender = -Infinity;\n } else {\n // 判断是否需要outRange优化\n if (this.params.optimize.skipRenderWithOutRange !== false) {\n this._skipRender = this.window.isVisible() ? 0 : 1;\n } else {\n this._skipRender = 0;\n }\n }\n }\n\n // 优化策略\n optmize(params: IOptimizeType) {\n this.optmizeRender(params.skipRenderWithOutRange);\n this.params.optimize = params;\n }\n\n // 优化渲染\n protected optmizeRender(skipRenderWithOutRange: boolean = false) {\n if (!skipRenderWithOutRange) {\n return;\n }\n // 不在视口内的时候,跳过渲染\n this._skipRender = this._skipRender < 0 ? this._skipRender : this.window.isVisible() ? 0 : 1;\n this.window.onVisibleChange(this._onVisibleChange);\n }\n\n protected _onVisibleChange = (visible: boolean) => {\n if (this._skipRender < 0) {\n return;\n }\n if (visible) {\n if (this.dirtyBounds) {\n const b = this.window.getViewBox();\n this.dirtyBounds.setValue(b.x1, b.y1, b.width(), b.height());\n }\n if (this._skipRender > 1) {\n this.renderNextFrame();\n }\n this._skipRender = 0;\n } else {\n this._skipRender = 1;\n }\n };\n\n getTimeline() {\n return this.timeline;\n }\n\n get3dOptions(options: IOption3D) {\n const {\n center = { x: this.width / 2, y: this.height / 2, z: 0, dx: 0, dy: 0, dz: 0 },\n light = {},\n alpha = 0,\n beta = 0,\n camera,\n fieldRatio = 1,\n fieldDepth\n } = options;\n\n return {\n ...options,\n center,\n light,\n alpha,\n beta,\n camera,\n fieldRatio,\n fieldDepth\n };\n }\n\n set3dOptions(options: IOption3D) {\n this.option3d = options;\n const options3d = this.get3dOptions(options);\n const { light, center, camera, alpha, beta, fieldRatio, fieldDepth } = options3d;\n const { dir = [1, 1, -1], color = 'white', ambient } = light;\n\n const centerX = (center.x ?? this.width / 2) + (center.dx ?? 0);\n const centerY = (center.y ?? this.height / 2) + (center.dy ?? 0);\n const centerZ = (center.z ?? 0) + (center.dz ?? 0);\n const centerVec3: vec3 = [centerX, centerY, centerZ];\n const z = 1;\n let cameraX = 0;\n let cameraY = 0;\n let cameraZ = 0;\n if (!camera) {\n cameraX = Math.sin(alpha) + centerX;\n cameraY = Math.sin(beta) + centerY;\n cameraZ = Math.cos(alpha) * Math.cos(beta) * z;\n }\n\n const DirectionalLight = Factory.getPlugin('DirectionalLight');\n\n if (DirectionalLight) {\n this.light = new DirectionalLight(dir, color, ambient);\n }\n const cameraParams = {\n left: 0,\n right: this.width,\n top: 0,\n bottom: this.height,\n fieldRatio: fieldRatio,\n fieldDepth,\n viewParams: {\n pos: [cameraX, cameraY, cameraZ] as vec3,\n center: centerVec3,\n up: [0, 1, 0] as vec3\n }\n };\n if (this.camera) {\n this.camera.params = cameraParams;\n } else {\n const OrthoCamera = Factory.getPlugin('OrthoCamera');\n if (OrthoCamera) {\n this.camera = new OrthoCamera(cameraParams);\n }\n }\n\n if (options.enableView3dTransform) {\n this.enableView3dTransform();\n }\n }\n\n protected beforeRender = (stage: IStage) => {\n this._beforeRender && this._beforeRender(stage);\n };\n\n protected afterRender = (stage: IStage) => {\n this.renderCount++;\n this._afterRender && this._afterRender(stage);\n this._afterNextRenderCbs && this._afterNextRenderCbs.forEach(cb => cb(stage));\n this._afterNextRenderCbs = null;\n };\n\n setBeforeRender(cb: (stage: IStage) => void) {\n this._beforeRender = cb;\n }\n\n setAfterRender(cb: (stage: IStage) => void) {\n this._afterRender = cb;\n }\n\n afterNextRender(cb: (stage: IStage) => void) {\n if (!this._afterNextRenderCbs) {\n this._afterNextRenderCbs = [];\n }\n this._afterNextRenderCbs.push(cb);\n }\n\n enableView3dTransform() {\n if (this.view3dTranform) {\n return;\n }\n this.view3dTranform = true;\n const ViewTransform3dPlugin = Factory.getPlugin('ViewTransform3dPlugin');\n\n if (ViewTransform3dPlugin) {\n this.pluginService.register(new ViewTransform3dPlugin());\n }\n }\n\n disableView3dTranform() {\n if (!this.view3dTranform) {\n return;\n }\n this.view3dTranform = false;\n this.pluginService.findPluginsByName('ViewTransform3dPlugin').forEach(plugin => {\n this.pluginService.unRegister(plugin);\n });\n }\n\n enableAutoRender() {\n if (this.autoRender) {\n return;\n }\n this.autoRender = true;\n this.pluginService.register(new AutoRenderPlugin());\n }\n disableAutoRender() {\n if (!this.autoRender) {\n return;\n }\n this.autoRender = false;\n this.pluginService.findPluginsByName('AutoRenderPlugin').forEach(plugin => {\n this.pluginService.unRegister(plugin);\n });\n }\n enableIncrementalAutoRender() {\n if (this.increaseAutoRender) {\n return;\n }\n this.increaseAutoRender = true;\n this.pluginService.register(new IncrementalAutoRenderPlugin());\n }\n disableIncrementalAutoRender() {\n if (!this.increaseAutoRender) {\n return;\n }\n this.increaseAutoRender = false;\n this.pluginService.findPluginsByName('IncrementalAutoRenderPlugin').forEach(plugin => {\n this.pluginService.unRegister(plugin);\n });\n }\n enableDirtyBounds() {\n if (this.dirtyBounds) {\n return;\n }\n this.dirtyBounds = new Bounds();\n let plugin = this.pluginService.findPluginsByName('DirtyBoundsPlugin')[0];\n if (!plugin) {\n plugin = new DirtyBoundsPlugin();\n this.pluginService.register(plugin);\n } else {\n plugin.activate(this.pluginService);\n }\n }\n disableDirtyBounds() {\n if (!this.dirtyBounds) {\n return;\n }\n this.dirtyBounds = null;\n this.pluginService.findPluginsByName('DirtyBoundsPlugin').forEach(plugin => {\n this.pluginService.unRegister(plugin);\n });\n }\n enableLayout() {\n if (this._enableLayout) {\n return;\n }\n this._enableLayout = true;\n\n const FlexLayoutPlugin = Factory.getPlugin('FlexLayoutPlugin');\n\n if (FlexLayoutPlugin) {\n this.pluginService.register(new FlexLayoutPlugin());\n }\n }\n disableLayout() {\n if (!this._enableLayout) {\n return;\n }\n this._enableLayout = false;\n this.pluginService.findPluginsByName('FlexLayoutPlugin').forEach(plugin => {\n this.pluginService.unRegister(plugin);\n });\n }\n enableHtmlAttribute(container?: any) {\n if (this.htmlAttribute) {\n return;\n }\n const HtmlAttributePlugin = Factory.getPlugin('HtmlAttributePlugin');\n\n if (HtmlAttributePlugin) {\n this.htmlAttribute = container;\n this.pluginService.register(new HtmlAttributePlugin());\n }\n }\n disableHtmlAttribute() {\n if (!this.htmlAttribute) {\n return;\n }\n this.htmlAttribute = false;\n this.pluginService.findPluginsByName('HtmlAttributePlugin').forEach(plugin => {\n this.pluginService.unRegister(plugin);\n });\n }\n enableReactAttribute(container?: any) {\n if (this.reactAttribute) {\n return;\n }\n const ReactAttributePlugin = Factory.getPlugin('ReactAttributePlugin');\n\n if (ReactAttributePlugin) {\n this.reactAttribute = container;\n this.pluginService.register(new ReactAttributePlugin());\n }\n }\n disableReactAttribute() {\n if (!this.reactAttribute) {\n return;\n }\n this.reactAttribute = false;\n this.pluginService.findPluginsByName('ReactAttributePlugin').forEach(plugin => {\n this.pluginService.unRegister(plugin);\n });\n }\n\n getPluginsByName(name: string): IPlugin[] {\n return this.pluginService.findPluginsByName(name);\n }\n\n // /**\n // * stage的appendChild,add\n // * @param node\n // * @returns\n // */\n // appendChild<T extends Node>(node: T): T | null {\n // const layer = this.at(0);\n // if (!layer) {\n // return null;\n // }\n // return layer.appendChild<T>(node);\n // }\n\n protected tryUpdateAABBBounds(): IAABBBounds {\n const viewBox = this.window.getViewBox();\n this._AABBBounds.setValue(viewBox.x1, viewBox.y1, viewBox.x2, viewBox.y2);\n return this._AABBBounds;\n }\n\n combineLayer(ILayer1: ILayer, ILayer2: ILayer): ILayer {\n throw new Error('暂不支持');\n }\n // 如果传入CanvasId,如果存在相同Id,说明这两个图层使用相同的Canvas绘制\n // 但需要注意的是依然是两个图层(用于解决Table嵌入ChartSpace不影响Table的绘制)\n createLayer(canvasId?: string, layerMode?: LayerMode): ILayer {\n if (this.releaseStatus === 'released') {\n return;\n }\n // 创建一个默认layer图层\n const layer = this.layerService.createLayer(this, {\n main: false,\n layerMode,\n canvasId\n });\n this.appendChild(layer);\n return layer;\n // const layer = new Layer(this, this.global, this.window, {\n // main: false,\n // canvasId\n // });\n // this.appendChild(layer);\n // return layer;\n }\n sortLayer(cb: (ILayer1: ILayer, layer2: ILayer) => number): void {\n const children = this.children;\n children.sort(cb);\n this.removeAllChild();\n children.forEach(c => {\n this.appendChild(c);\n });\n }\n removeLayer(ILayerId: number): ILayer | false {\n return this.removeChild(this.findChildByUid(ILayerId) as IGraphic) as ILayer;\n }\n tryInitInteractiveLayer() {\n if (this.releaseStatus === 'released') {\n return;\n }\n // TODO:顺序可能会存在问题\n // 支持交互层,且没有创建过,那就创建\n if (this.supportInteractiveLayer && !this.interactiveLayer) {\n this.interactiveLayer = this.createLayer();\n this.interactiveLayer.name = '_builtin_interactive';\n this.interactiveLayer.attribute.pickable = false;\n this.nextFrameRenderLayerSet.add(this.interactiveLayer as any); // to be fixed\n }\n // this.interactiveLayer.afterDraw(l => {\n // l.removeAllChild();\n // });\n }\n\n clearViewBox(color?: string) {\n this.window.clearViewBox(color);\n }\n\n render(layers?: ILayer[], params?: Partial<IDrawContext>): void {\n if (this.releaseStatus === 'released') {\n return;\n }\n this.ticker.start();\n this.timeline.resume();\n const state = this.state;\n this.state = 'rendering';\n this.layerService.prepareStageLayer(this);\n if (!this._skipRender) {\n this.lastRenderparams = params;\n this.hooks.beforeRender.call(this);\n if (!this._skipRender) {\n this.renderLayerList(this.children as ILayer[]);\n this.combineLayersToWindow();\n this.nextFrameRenderLayerSet.clear();\n }\n this.hooks.afterRender.call(this);\n }\n this.state = state;\n this._skipRender && this._skipRender++;\n }\n\n protected combineLayersToWindow() {\n // TODO 后续支持通用的渲染模型\n if (this.global.env === 'harmony') {\n const ctx = this.window.getContext().nativeContext;\n this.forEachChildren<ILayer>((layer, i) => {\n if (i > 0) {\n const image = layer\n .getNativeHandler()\n .getContext()\n .canvas.nativeCanvas.nativeCanvas._c.transferToImageBitmap();\n ctx.transferFromImageBitmap(image);\n }\n });\n }\n return;\n // this.forEach<ILayer>((layer, i) => {\n // layer.combineTo(this.window, {\n // clear: i === 0,\n // x: this.x,\n // y: this.y,\n // width: this.viewWidth,\n // height: this.viewHeight,\n // renderService: this.renderService,\n // background: layer === this.defaultLayer ? this.background : undefined,\n // updateBounds: !!this.dirtyBounds\n // });\n // });\n }\n\n renderNextFrame(layers?: ILayer[], force?: boolean): void {\n // render状态中调用的不会触发nextFrame,避免loop\n // if (this.state === 'rendering' && !force) {\n // console.log('abc');\n // return;\n // }\n // 性能优化,避免重复add\n if (this.nextFrameRenderLayerSet.size !== this.childrenCount) {\n (layers || this).forEach<ILayer>((layer: any) => {\n this.nextFrameRenderLayerSet.add(layer);\n });\n }\n if (!this.willNextFrameRender) {\n this.willNextFrameRender = true;\n this.global.getRequestAnimationFrame()(() => {\n this._doRenderInThisFrame(), (this.willNextFrameRender = false);\n });\n }\n }\n\n _doRenderInThisFrame() {\n if (this.releaseStatus === 'released') {\n return;\n }\n this.timeline.resume();\n this.ticker.start();\n const state = this.state;\n this.state = 'rendering';\n this.layerService.prepareStageLayer(this);\n if (this.nextFrameRenderLayerSet.size && !this._skipRender) {\n this.hooks.beforeRender.call(this);\n if (!this._skipRender) {\n this.renderLayerList(Array.from(this.nextFrameRenderLayerSet.values()), this.lastRenderparams || {});\n this.combineLayersToWindow();\n this.nextFrameRenderLayerSet.clear();\n }\n this.hooks.afterRender.call(this);\n }\n this.state = state;\n this._skipRender && this._skipRender++;\n }\n\n protected renderLayerList(layerList: ILayer[], params?: Partial<IDrawContext>) {\n const list: ILayer[] = [];\n // 只需要render main layer即可\n for (let i = 0; i < layerList.length; i++) {\n let l = layerList[i];\n if (l.layerMode === 'virtual') {\n l = l.getNativeHandler().mainHandler.layer;\n }\n if (!list.includes(l)) {\n list.push(l);\n }\n }\n list.forEach(layer => {\n // 记录当前的stamp,避免重复绘制layer(如果存在virtual layer)\n if (layer.renderCount > this.renderCount) {\n return;\n }\n layer.renderCount = this.renderCount + 1;\n\n if (layer === this.interactiveLayer) {\n // 交互层由于其特殊性,不使用dirtyBounds\n this.dirtyBounds && this.dirtyBounds.clear();\n }\n layer.render(\n {\n renderService: this.renderService,\n background: layer === this.defaultLayer ? this.background : undefined,\n updateBounds: !!(this.dirtyBounds && !this.dirtyBounds.empty()),\n viewBox: this.window.getViewBox(),\n transMatrix: this.window.getViewBoxTransform()\n },\n { renderStyle: this.renderStyle, ...params }\n );\n });\n\n // 添加交互层渲染\n if (this.interactiveLayer && !layerList.includes(this.interactiveLayer)) {\n // 交互层由于其特殊性,不使用dirtyBounds\n this.dirtyBounds && this.dirtyBounds.clear();\n this.interactiveLayer.render(\n {\n renderService: this.renderService,\n updateBounds: !!(this.dirtyBounds && !this.dirtyBounds.empty()),\n viewBox: this.window.getViewBox(),\n transMatrix: this.window.getViewBoxTransform()\n },\n { renderStyle: this.renderStyle, ...params }\n );\n }\n }\n\n resizeWindow(w: number, h: number, rerender: boolean = true) {\n this.window.resize(w, h);\n rerender && this.render();\n }\n\n /**\n * 语法糖,如果viewBox和window宽高一样的话,那么会同时缩放window和viewBox\n * @param w\n * @param h\n * @param rerender\n */\n resize(w: number, h: number, rerender: boolean = true): void {\n if (this.releaseStatus === 'released') {\n return;\n }\n // 如果不是子图的stage,那么认为用户也想要resize view\n if (!this.window.hasSubView()) {\n this.viewBox.setValue(this.viewBox.x1, this.viewBox.y1, this.viewBox.x1 + w, this.viewBox.y1 + h);\n }\n this.window.resize(w, h);\n this.forEachChildren<ILayer>(c => {\n c.resize(w, h);\n });\n // 设置camera\n // this.camera && (this.camera.params = { ...this.camera.params, right: this.width, bottom: this.height });\n this.camera && this.option3d && this.set3dOptions(this.option3d);\n rerender && this.render();\n }\n resizeView(w: number, h: number, rerender: boolean = true) {\n if (this.releaseStatus === 'released') {\n return;\n }\n this.viewBox.setValue(this.viewBox.x1, this.viewBox.y1, this.viewBox.x1 + w, this.viewBox.y1 + h);\n this.forEachChildren<ILayer>(c => {\n c.resizeView(w, h);\n });\n // 设置camera\n this.camera && (this.camera.params = { ...this.camera.params, right: this.width, bottom: this.height });\n rerender && this.render();\n }\n setViewBox(viewBox: IBoundsLike, rerender: boolean): void;\n setViewBox(x: number, y: number, w: number, h: number, rerender: boolean): void;\n setViewBox(x: number | IBoundsLike, y: number | boolean, w?: number, h?: number, rerender?: boolean): void {\n let isRerender: boolean = true;\n\n if (typeof x === 'object') {\n this.viewBox.setValue(x.x1, x.y1, x.x2, x.y2);\n if (y === false) {\n isRerender = false;\n }\n } else {\n this.viewBox.setValue(x, y as number, x + w, (y as number) + h);\n\n if (rerender === false) {\n isRerender = false;\n }\n }\n\n this.forEachChildren<ILayer>(c => {\n c.resizeView(this.viewBox.width(), this.viewBox.height());\n });\n isRerender && this.render();\n }\n setDpr(dpr: number, rerender: boolean = true): void {\n // this.window.setDpr(dpr);\n this.forEachChildren<ILayer>(c => {\n c.setDpr(dpr);\n });\n\n rerender && this.render();\n }\n setOrigin(x: number, y: number): void {\n throw new Error('暂不支持');\n }\n export(type: IExportType): HTMLCanvasElement | ImageData {\n throw new Error('暂不支持');\n }\n pick(x: number, y: number): PickResult | false {\n if (this.releaseStatus === 'released') {\n return;\n }\n // 暂时不提供layer的pick\n const result = this.getPickerService().pick(this.children as unknown as IGraphic[], new Point(x, y), {\n bounds: this.AABBBounds\n });\n if (result?.graphic || result?.group) {\n return result;\n }\n return false;\n }\n\n // 动画相关\n startAnimate(t: number): void {\n throw new Error('暂不支持');\n }\n setToFrame(t: number): void {\n throw new Error('暂不支持');\n }\n\n release() {\n super.release();\n\n this.hooks.beforeRender.unTap('constructor', this.beforeRender);\n this.hooks.afterRender.unTap('constructor', this.afterRender);\n\n this.eventSystem && this.eventSystem.release();\n this.layerService.releaseStage(this);\n this.pluginService.release();\n this.forEach(layer => {\n layer.release();\n });\n // 额外删除掉interactiveLayer的节点\n if (this.interactiveLayer) {\n this.interactiveLayer.forEachChildren((item: IGraphic) => {\n item.setStage && item.setStage(null, null);\n this.interactiveLayer.removeChild(item);\n });\n this.interactiveLayer.release();\n }\n this.window.release();\n this.ticker.remTimeline(this.timeline);\n this.renderService.renderTreeRoots = [];\n }\n\n setStage(stage?: IStage) {\n return;\n // this.stage = this;\n // this.forEachChildren(item => {\n // (item as Layer).setStage(this);\n // });\n }\n\n /**\n * 添加dirty区域,会修改参数b\n * @param b\n * @param matrix\n */\n dirty(b: IBounds, matrix?: IMatrix) {\n if (this.releaseStatus === 'released') {\n return;\n }\n if (matrix) {\n b.transformWithMatrix(matrix);\n }\n if (this.dirtyBounds.empty()) {\n this.dirtyBounds.setValue(b.x1, b.y1, b.x2, b.y2);\n }\n this.dirtyBounds.union(b);\n }\n\n getLayer(name: string): undefined | ILayer {\n const layer = this.children.filter(layer => layer.name === name);\n return layer[0] as ILayer;\n }\n\n renderTo(window: IWindow) {\n if (this.releaseStatus === 'released') {\n return;\n }\n this.forEachChildren<ILayer>((layer, i) => {\n layer.drawTo(window, {\n // ...params,\n renderService: this.renderService,\n viewBox: window.getViewBox(),\n transMatrix: window.getViewBoxTransform(),\n background: layer === this.defaultLayer ? this.background : undefined,\n clear: i === 0, // 第一个layer需要clear\n updateBounds: !!(this.dirtyBounds && !this.dirtyBounds.empty())\n });\n });\n }\n\n /**\n * 渲染到新的window上去\n * @param fullImage 是否是全量的image,因为可能之前的window有一部分场景树超过window的帧缓冲了\n * @returns\n */\n renderToNewWindow(fullImage: boolean = true, viewBox?: IAABBBounds): IWindow {\n if (this.releaseStatus === 'released') {\n return;\n }\n const window = container.get<IWindow>(VWindow);\n const x1 = viewBox ? -viewBox.x1 : 0;\n const y1 = viewBox ? -viewBox.y1 : 0;\n const x2 = viewBox ? viewBox.x2 : this.viewWidth;\n const y2 = viewBox ? viewBox.y2 : this.viewHeight;\n const width = viewBox ? viewBox.width() : this.viewWidth;\n const height = viewBox ? viewBox.height() : this.viewHeight;\n if (fullImage) {\n window.create({\n viewBox: { x1, y1, x2, y2 },\n width,\n height,\n dpr: this.window.dpr,\n canvasControled: true,\n offscreen: true,\n title: ''\n });\n } else {\n window.create({\n viewBox: { x1, y1, x2, y2 },\n width,\n height,\n dpr: this.window.dpr,\n canvasControled: true,\n offscreen: true,\n title: ''\n });\n }\n\n this.renderTo(window);\n return window;\n }\n\n toCanvas(fullImage: boolean = true, viewBox?: IAABBBounds): HTMLCanvasElement | null {\n if (this.releaseStatus === 'released') {\n return;\n }\n const window = this.renderToNewWindow(fullImage, viewBox);\n const c = window.getNativeHandler();\n if (c.nativeCanvas) {\n return c.nativeCanvas;\n }\n return null;\n }\n\n setCursor(mode?: string): void {\n this._cursor = mode;\n this.eventSystem.setCursor(mode, 'ignore');\n }\n\n getCursor() {\n return this._cursor;\n }\n\n eventPointTransform(e: PointerEvent | WheelEvent | TouchEvent): { x: number; y: number } {\n const point = this.global.mapToCanvasPoint(e, this.window.getContext().canvas.nativeCanvas);\n\n return this.stage.window.pointTransform(point.x, point.y);\n }\n\n pauseTriggerEvent() {\n this._eventSystem && this._eventSystem.pauseTriggerEvent();\n }\n resumeTriggerEvent() {\n this._eventSystem && this._eventSystem.resumeTriggerEvent();\n }\n\n getPickerService() {\n if (!this.pickerService) {\n this.pickerService = container.get<IPickerService>(PickerService);\n }\n return this.pickerService;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/core/stage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AA2B3D,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AACl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ACD,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;CACF","file":"stage.js","sourcesContent":["import type { IAABBBounds, IBounds, IBoundsLike, IMatrix } from '@visactor/vutils';\nimport { Bounds, Point, isString } from '@visactor/vutils';\nimport type {\n IGraphic,\n IExportType,\n IStage,\n IStageParams,\n ILayer,\n IColor,\n IGlobal,\n IOption3D,\n ICamera,\n vec3,\n IDirectionLight,\n ITicker,\n IRenderService,\n IPickerService,\n IPluginService,\n ISyncHook,\n IDrawContext,\n IWindow,\n ILayerService,\n ITimeline,\n IOptimizeType,\n LayerMode,\n PickResult,\n IPlugin\n} from '../interface';\nimport { VWindow } from './window';\nimport type { Layer } from './layer';\nimport { EventSystem } from '../event';\nimport { container } from '../container';\nimport { RenderService } from '../render';\nimport { Group } from '../graphic/group';\nimport { Theme } from '../graphic/theme';\nimport { PickerService } from '../picker/constants';\nimport { PluginService } from '../plugins/constants';\nimport { AutoRenderPlugin } from '../plugins/builtin-plugin/auto-render-plugin';\nimport { AutoRefreshPlugin } from '../plugins/builtin-plugin/auto-refresh-plugin';\nimport { IncrementalAutoRenderPlugin } from '../plugins/builtin-plugin/incremental-auto-render-plugin';\nimport { DirtyBoundsPlugin } from '../plugins/builtin-plugin/dirty-bounds-plugin';\nimport { defaultTicker } from '../animate/default-ticker';\nimport { SyncHook } from '../tapable';\nimport { LayerService } from './constants';\nimport { DefaultTimeline } from '../animate';\nimport { application } from '../application';\nimport { isBrowserEnv } from '../env-check';\nimport { Factory } from '../factory';\n\nconst DefaultConfig = {\n WIDTH: 500,\n HEIGHT: 500,\n X: 0,\n Y: 0,\n BACKGROUND: 'white'\n};\n\ntype IStageState = 'rendering' | 'normal';\n\n/**\n * Stage是一个舞台或一个视口,并不直接对应一个或多个Canvas,逻辑上和Canvas无关\n *\n * 1. Stage对应一个Canvas的整体,Stage的宽高即为Canvas的宽高\n * 2. Stage小于Canvas,Stage作为Canvas某个区域的视口,只管理这个区域\n * 3. 多图层时Stage的多个图层对应多个Canvas\n *\n * 原生环境下Stage可以拥有一个Window或者使用Window的一块区域\n *\n * 【注】如果希望获取完整的Canvas或窗口或者调整窗口信息,请使用Window模块\n */\nexport class Stage extends Group implements IStage {\n declare parent: IStage | null;\n\n declare state: IStageState;\n\n private _background: string | IColor;\n protected nextFrameRenderLayerSet: Set<Layer>;\n protected willNextFrameRender: boolean;\n protected _cursor: string;\n renderCount: number;\n dirtyBounds: IBounds | null;\n option3d?: IOption3D;\n declare light?: IDirectionLight;\n declare camera?: ICamera;\n declare renderStyle?: string;\n\n declare hooks: {\n beforeRender: ISyncHook<[IStage]>;\n afterRender: ISyncHook<[IStage]>;\n };\n\n set viewBox(b: IBoundsLike) {\n this.window.setViewBox(b);\n }\n get viewBox(): IAABBBounds {\n return this.window.getViewBox();\n }\n\n /**\n * @deprecated 不建议使用\n */\n get x(): number {\n return this.window.getViewBox().x1;\n }\n /**\n * @deprecated 不建议使用\n */\n set x(x: number) {\n const b = this.window.getViewBox();\n b.translate(x - b.x1, 0);\n this.window.setViewBox(b);\n }\n /**\n * @deprecated 不建议使用\n */\n get y(): number {\n return this.window.getViewBox().y1;\n }\n /**\n * @deprecated 不建议使用\n */\n set y(y: number) {\n const b = this.window.getViewBox();\n b.translate(0, y - b.y1);\n this.window.setViewBox(b);\n }\n get width(): number {\n return this.window.width;\n }\n set width(w: number) {\n this.resize(w, this.height);\n }\n get viewWidth(): number {\n return this.window.getViewBox().width();\n }\n set viewWidth(w: number) {\n this.resizeView(w, this.viewHeight);\n }\n get viewHeight(): number {\n return this.window.getViewBox().height();\n }\n set viewHeight(h: number) {\n this.resizeView(this.viewWidth, h);\n }\n get height(): number {\n return this.window.height;\n }\n set height(h: number) {\n this.resize(this.width, h);\n }\n get dpr(): number {\n return this.window.dpr;\n }\n set dpr(r: number) {\n this.setDpr(r);\n }\n get background(): string | IColor {\n return this._background ?? DefaultConfig.BACKGROUND;\n }\n set background(b: string | IColor) {\n this._background = b;\n }\n get defaultLayer(): ILayer {\n return this.at(0) as unknown as ILayer;\n }\n\n ticker: ITicker;\n\n autoRender: boolean;\n autoRefresh: boolean;\n _enableLayout: boolean;\n htmlAttribute: boolean | string | any;\n reactAttribute: boolean | string | any;\n increaseAutoRender: boolean;\n view3dTranform: boolean;\n readonly window: IWindow;\n private readonly global: IGlobal;\n readonly renderService: IRenderService;\n protected pickerService?: IPickerService;\n readonly pluginService: IPluginService;\n readonly layerService: ILayerService;\n private _eventSystem?: EventSystem;\n private get eventSystem(): EventSystem {\n return this._eventSystem;\n }\n\n protected _beforeRender?: (stage: IStage) => void;\n protected _afterRender?: (stage: IStage) => void;\n // 0: 正常渲染, > 0: 跳过隐藏canvas的渲染, < 0: 禁止渲染\n protected _skipRender?: number;\n protected _afterNextRenderCbs?: ((stage: IStage) => void)[];\n protected lastRenderparams?: Partial<IDrawContext>;\n\n protected interactiveLayer?: ILayer;\n protected supportInteractiveLayer: boolean;\n protected timeline: ITimeline;\n\n declare params: Partial<IStageParams>;\n\n /**\n * 所有属性都具有默认值。\n * Canvas为字符串或者Canvas元素,那么默认图层就会绑定到这个Canvas上\n * 如果不传入Canvas,那么会新建一个Canvas,用户可以通过Window模块管理这个Canvas\n * 1. 如果没有传入宽高,那么默认为canvas宽高,如果传入了宽高则stage使用传入宽高作为视口宽高\n * @param params\n */\n constructor(params: Partial<IStageParams> = {}) {\n super({});\n this.params = params;\n this.theme = new Theme();\n this.hooks = {\n beforeRender: new SyncHook(['stage']),\n afterRender: new SyncHook(['stage'])\n };\n this.global = application.global;\n if (!this.global.env && isBrowserEnv()) {\n // 如果是浏览器环境,默认设置env\n this.global.setEnv('browser');\n }\n this.window = container.get<IWindow>(VWindow);\n this.renderService = container.get<IRenderService>(RenderService);\n this.pluginService = container.get<IPluginService>(PluginService);\n this.layerService = container.get<ILayerService>(LayerService);\n this.pluginService.active(this, params);\n\n this.window.create({\n width: params.width,\n height: params.height,\n viewBox: params.viewBox,\n container: params.container,\n dpr: params.dpr || this.global.devicePixelRatio,\n canvasControled: params.canvasControled !== false,\n title: params.title || '',\n canvas: params.canvas\n });\n\n this.state = 'normal';\n this.renderCount = 0;\n this.tryInitEventSystem();\n // // 没有传入xy就默认为0\n // this._x = params.x ?? DefaultConfig.X;\n // this._y = params.y ?? DefaultConfig.Y;\n // // 没有传入view的宽高则默认为window的宽高\n // this._viewWidth = params.viewWidth ?? this.window.width;\n // this._viewHeight = params.viewHeight ?? this.window.height;\n // this._AABBBounds.set(this._x, this._y, this._viewWidth + this._x, this._viewHeight + this._y);\n // 背景色默认为纯白色\n this._background = params.background ?? DefaultConfig.BACKGROUND;\n\n // 创建一个默认layer图层\n // this.appendChild(new Layer(this, this.global, this.window, { main: true }));\n this.appendChild(this.layerService.createLayer(this, { main: true }));\n\n this.nextFrameRenderLayerSet = new Set();\n this.willNextFrameRender = false;\n this.stage = this;\n this.renderStyle = params.renderStyle;\n\n // this.autoRender = params.autoRender;\n if (params.autoRender) {\n this.enableAutoRender();\n }\n if (params.autoRefresh) {\n this.enableAutoRefresh();\n }\n // 默认不开启dirtyBounds\n if (params.disableDirtyBounds === false) {\n this.enableDirtyBounds();\n }\n\n if (params.enableHtmlAttribute) {\n this.enableHtmlAttribute(params.enableHtmlAttribute);\n }\n if (params.ReactDOM) {\n this.enableReactAttribute(params.ReactDOM);\n }\n\n params.enableLayout && this.enableLayout();\n this.hooks.beforeRender.tap('constructor', this.beforeRender);\n this.hooks.afterRender.tap('constructor', this.afterRender);\n this._beforeRender = params.beforeRender;\n this._afterRender = params.afterRender;\n this.ticker = params.ticker || defaultTicker;\n this.supportInteractiveLayer = params.interactiveLayer !== false;\n this.timeline = new DefaultTimeline();\n this.ticker.addTimeline(this.timeline);\n this.timeline.pause();\n if (!params.optimize) {\n params.optimize = {};\n }\n this.optmize(params.optimize);\n // 如果背景是图片,触发加载图片操作\n if (params.background && isString(this._background) && this._background.includes('/')) {\n this.setAttributes({ background: this._background });\n }\n }\n\n pauseRender(sr: number = -1) {\n this._skipRender = sr;\n }\n\n resumeRender() {\n this._skipRender = 0;\n }\n\n protected tryInitEventSystem() {\n if (this.global.supportEvent && !this._eventSystem) {\n this._eventSystem = new EventSystem({\n targetElement: this.window,\n resolution: this.window.dpr || this.global.devicePixelRatio,\n rootNode: this as any,\n global: this.global,\n supportsPointerEvents: this.params.supportsPointerEvents,\n supportsTouchEvents: this.params.supportsTouchEvents,\n ...this.params.event\n });\n }\n }\n\n preventRender(prevent: boolean) {\n if (prevent) {\n this._skipRender = -Infinity;\n } else {\n // 判断是否需要outRange优化\n if (this.params.optimize.skipRenderWithOutRange !== false) {\n this._skipRender = this.window.isVisible() ? 0 : 1;\n } else {\n this._skipRender = 0;\n }\n }\n }\n\n // 优化策略\n optmize(params: IOptimizeType) {\n this.optmizeRender(params.skipRenderWithOutRange);\n this.params.optimize = params;\n }\n\n // 优化渲染\n protected optmizeRender(skipRenderWithOutRange: boolean = false) {\n if (!skipRenderWithOutRange) {\n return;\n }\n // 不在视口内的时候,跳过渲染\n this._skipRender = this._skipRender < 0 ? this._skipRender : this.window.isVisible() ? 0 : 1;\n this.window.onVisibleChange(this._onVisibleChange);\n }\n\n protected _onVisibleChange = (visible: boolean) => {\n if (this._skipRender < 0) {\n return;\n }\n if (visible) {\n if (this.dirtyBounds) {\n const b = this.window.getViewBox();\n this.dirtyBounds.setValue(b.x1, b.y1, b.width(), b.height());\n }\n if (this._skipRender > 1) {\n this.renderNextFrame();\n }\n this._skipRender = 0;\n } else {\n this._skipRender = 1;\n }\n };\n\n getTimeline() {\n return this.timeline;\n }\n\n get3dOptions(options: IOption3D) {\n const {\n center = { x: this.width / 2, y: this.height / 2, z: 0, dx: 0, dy: 0, dz: 0 },\n light = {},\n alpha = 0,\n beta = 0,\n camera,\n fieldRatio = 1,\n fieldDepth\n } = options;\n\n return {\n ...options,\n center,\n light,\n alpha,\n beta,\n camera,\n fieldRatio,\n fieldDepth\n };\n }\n\n set3dOptions(options: IOption3D) {\n this.option3d = options;\n const options3d = this.get3dOptions(options);\n const { light, center, camera, alpha, beta, fieldRatio, fieldDepth } = options3d;\n const { dir = [1, 1, -1], color = 'white', ambient } = light;\n\n const centerX = (center.x ?? this.width / 2) + (center.dx ?? 0);\n const centerY = (center.y ?? this.height / 2) + (center.dy ?? 0);\n const centerZ = (center.z ?? 0) + (center.dz ?? 0);\n const centerVec3: vec3 = [centerX, centerY, centerZ];\n const z = 1;\n let cameraX = 0;\n let cameraY = 0;\n let cameraZ = 0;\n if (!camera) {\n cameraX = Math.sin(alpha) + centerX;\n cameraY = Math.sin(beta) + centerY;\n cameraZ = Math.cos(alpha) * Math.cos(beta) * z;\n }\n\n const DirectionalLight = Factory.getPlugin('DirectionalLight');\n\n if (DirectionalLight) {\n this.light = new DirectionalLight(dir, color, ambient);\n }\n const cameraParams = {\n left: 0,\n right: this.width,\n top: 0,\n bottom: this.height,\n fieldRatio: fieldRatio,\n fieldDepth,\n viewParams: {\n pos: [cameraX, cameraY, cameraZ] as vec3,\n center: centerVec3,\n up: [0, 1, 0] as vec3\n }\n };\n if (this.camera) {\n this.camera.params = cameraParams;\n } else {\n const OrthoCamera = Factory.getPlugin('OrthoCamera');\n if (OrthoCamera) {\n this.camera = new OrthoCamera(cameraParams);\n }\n }\n\n if (options.enableView3dTransform) {\n this.enableView3dTransform();\n }\n }\n\n protected beforeRender = (stage: IStage) => {\n this._beforeRender && this._beforeRender(stage);\n };\n\n protected afterRender = (stage: IStage) => {\n this.renderCount++;\n this._afterRender && this._afterRender(stage);\n this._afterNextRenderCbs && this._afterNextRenderCbs.forEach(cb => cb(stage));\n this._afterNextRenderCbs = null;\n };\n\n setBeforeRender(cb: (stage: IStage) => void) {\n this._beforeRender = cb;\n }\n\n setAfterRender(cb: (stage: IStage) => void) {\n this._afterRender = cb;\n }\n\n afterNextRender(cb: (stage: IStage) => void) {\n if (!this._afterNextRenderCbs) {\n this._afterNextRenderCbs = [];\n }\n this._afterNextRenderCbs.push(cb);\n }\n\n enableView3dTransform() {\n if (this.view3dTranform) {\n return;\n }\n this.view3dTranform = true;\n const ViewTransform3dPlugin = Factory.getPlugin('ViewTransform3dPlugin');\n\n if (ViewTransform3dPlugin) {\n this.pluginService.register(new ViewTransform3dPlugin());\n }\n }\n\n disableView3dTranform() {\n if (!this.view3dTranform) {\n return;\n }\n this.view3dTranform = false;\n this.pluginService.findPluginsByName('ViewTransform3dPlugin').forEach(plugin => {\n this.pluginService.unRegister(plugin);\n });\n }\n\n enableAutoRender() {\n if (this.autoRender) {\n return;\n }\n this.autoRender = true;\n this.pluginService.register(new AutoRenderPlugin());\n }\n disableAutoRender() {\n if (!this.autoRender) {\n return;\n }\n this.autoRender = false;\n this.pluginService.findPluginsByName('AutoRenderPlugin').forEach(plugin => {\n this.pluginService.unRegister(plugin);\n });\n }\n enableAutoRefresh() {\n if (this.autoRefresh) {\n return;\n }\n this.autoRefresh = true;\n this.pluginService.register(new AutoRefreshPlugin());\n }\n disableAutoRefresh() {\n if (!this.autoRefresh) {\n return;\n }\n this.autoRefresh = false;\n this.pluginService.findPluginsByName('AutoRefreshPlugin').forEach(plugin => {\n this.pluginService.unRegister(plugin);\n });\n }\n enableIncrementalAutoRender() {\n if (this.increaseAutoRender) {\n return;\n }\n this.increaseAutoRender = true;\n this.pluginService.register(new IncrementalAutoRenderPlugin());\n }\n disableIncrementalAutoRender() {\n if (!this.increaseAutoRender) {\n return;\n }\n this.increaseAutoRender = false;\n this.pluginService.findPluginsByName('IncrementalAutoRenderPlugin').forEach(plugin => {\n this.pluginService.unRegister(plugin);\n });\n }\n enableDirtyBounds() {\n if (this.dirtyBounds) {\n return;\n }\n this.dirtyBounds = new Bounds();\n let plugin = this.pluginService.findPluginsByName('DirtyBoundsPlugin')[0];\n if (!plugin) {\n plugin = new DirtyBoundsPlugin();\n this.pluginService.register(plugin);\n } else {\n plugin.activate(this.pluginService);\n }\n }\n disableDirtyBounds() {\n if (!this.dirtyBounds) {\n return;\n }\n this.dirtyBounds = null;\n this.pluginService.findPluginsByName('DirtyBoundsPlugin').forEach(plugin => {\n this.pluginService.unRegister(plugin);\n });\n }\n enableLayout() {\n if (this._enableLayout) {\n return;\n }\n this._enableLayout = true;\n\n const FlexLayoutPlugin = Factory.getPlugin('FlexLayoutPlugin');\n\n if (FlexLayoutPlugin) {\n this.pluginService.register(new FlexLayoutPlugin());\n }\n }\n disableLayout() {\n if (!this._enableLayout) {\n return;\n }\n this._enableLayout = false;\n this.pluginService.findPluginsByName('FlexLayoutPlugin').forEach(plugin => {\n this.pluginService.unRegister(plugin);\n });\n }\n enableHtmlAttribute(container?: any) {\n if (this.htmlAttribute) {\n return;\n }\n const HtmlAttributePlugin = Factory.getPlugin('HtmlAttributePlugin');\n\n if (HtmlAttributePlugin) {\n this.htmlAttribute = container;\n this.pluginService.register(new HtmlAttributePlugin());\n }\n }\n disableHtmlAttribute() {\n if (!this.htmlAttribute) {\n return;\n }\n this.htmlAttribute = false;\n this.pluginService.findPluginsByName('HtmlAttributePlugin').forEach(plugin => {\n this.pluginService.unRegister(plugin);\n });\n }\n enableReactAttribute(container?: any) {\n if (this.reactAttribute) {\n return;\n }\n const ReactAttributePlugin = Factory.getPlugin('ReactAttributePlugin');\n\n if (ReactAttributePlugin) {\n this.reactAttribute = container;\n this.pluginService.register(new ReactAttributePlugin());\n }\n }\n disableReactAttribute() {\n if (!this.reactAttribute) {\n return;\n }\n this.reactAttribute = false;\n this.pluginService.findPluginsByName('ReactAttributePlugin').forEach(plugin => {\n this.pluginService.unRegister(plugin);\n });\n }\n\n getPluginsByName(name: string): IPlugin[] {\n return this.pluginService.findPluginsByName(name);\n }\n\n // /**\n // * stage的appendChild,add\n // * @param node\n // * @returns\n // */\n // appendChild<T extends Node>(node: T): T | null {\n // const layer = this.at(0);\n // if (!layer) {\n // return null;\n // }\n // return layer.appendChild<T>(node);\n // }\n\n protected tryUpdateAABBBounds(): IAABBBounds {\n const viewBox = this.window.getViewBox();\n this._AABBBounds.setValue(viewBox.x1, viewBox.y1, viewBox.x2, viewBox.y2);\n return this._AABBBounds;\n }\n\n combineLayer(ILayer1: ILayer, ILayer2: ILayer): ILayer {\n throw new Error('暂不支持');\n }\n // 如果传入CanvasId,如果存在相同Id,说明这两个图层使用相同的Canvas绘制\n // 但需要注意的是依然是两个图层(用于解决Table嵌入ChartSpace不影响Table的绘制)\n createLayer(canvasId?: string, layerMode?: LayerMode): ILayer {\n if (this.releaseStatus === 'released') {\n return;\n }\n // 创建一个默认layer图层\n const layer = this.layerService.createLayer(this, {\n main: false,\n layerMode,\n canvasId\n });\n this.appendChild(layer);\n return layer;\n // const layer = new Layer(this, this.global, this.window, {\n // main: false,\n // canvasId\n // });\n // this.appendChild(layer);\n // return layer;\n }\n sortLayer(cb: (ILayer1: ILayer, layer2: ILayer) => number): void {\n const children = this.children;\n children.sort(cb);\n this.removeAllChild();\n children.forEach(c => {\n this.appendChild(c);\n });\n }\n removeLayer(ILayerId: number): ILayer | false {\n return this.removeChild(this.findChildByUid(ILayerId) as IGraphic) as ILayer;\n }\n tryInitInteractiveLayer() {\n if (this.releaseStatus === 'released') {\n return;\n }\n // TODO:顺序可能会存在问题\n // 支持交互层,且没有创建过,那就创建\n if (this.supportInteractiveLayer && !this.interactiveLayer) {\n this.interactiveLayer = this.createLayer();\n this.interactiveLayer.name = '_builtin_interactive';\n this.interactiveLayer.attribute.pickable = false;\n this.nextFrameRenderLayerSet.add(this.interactiveLayer as any); // to be fixed\n }\n // this.interactiveLayer.afterDraw(l => {\n // l.removeAllChild();\n // });\n }\n\n clearViewBox(color?: string) {\n this.window.clearViewBox(color);\n }\n\n render(layers?: ILayer[], params?: Partial<IDrawContext>): void {\n if (this.releaseStatus === 'released') {\n return;\n }\n this.ticker.start();\n this.timeline.resume();\n const state = this.state;\n this.state = 'rendering';\n this.layerService.prepareStageLayer(this);\n if (!this._skipRender) {\n this.lastRenderparams = params;\n this.hooks.beforeRender.call(this);\n if (!this._skipRender) {\n this.renderLayerList(this.children as ILayer[]);\n this.combineLayersToWindow();\n this.nextFrameRenderLayerSet.clear();\n }\n this.hooks.afterRender.call(this);\n }\n this.state = state;\n this._skipRender && this._skipRender++;\n }\n\n protected combineLayersToWindow() {\n // TODO 后续支持通用的渲染模型\n if (this.global.env === 'harmony') {\n const ctx = this.window.getContext().nativeContext;\n this.forEachChildren<ILayer>((layer, i) => {\n if (i > 0) {\n const image = layer\n .getNativeHandler()\n .getContext()\n .canvas.nativeCanvas.nativeCanvas._c.transferToImageBitmap();\n ctx.transferFromImageBitmap(image);\n }\n });\n }\n return;\n // this.forEach<ILayer>((layer, i) => {\n // layer.combineTo(this.window, {\n // clear: i === 0,\n // x: this.x,\n // y: this.y,\n // width: this.viewWidth,\n // height: this.viewHeight,\n // renderService: this.renderService,\n // background: layer === this.defaultLayer ? this.background : undefined,\n // updateBounds: !!this.dirtyBounds\n // });\n // });\n }\n\n renderNextFrame(layers?: ILayer[], force?: boolean): void {\n // render状态中调用的不会触发nextFrame,避免loop\n // if (this.state === 'rendering' && !force) {\n // console.log('abc');\n // return;\n // }\n // 性能优化,避免重复add\n if (this.nextFrameRenderLayerSet.size !== this.childrenCount) {\n (layers || this).forEach<ILayer>((layer: any) => {\n this.nextFrameRenderLayerSet.add(layer);\n });\n }\n if (!this.willNextFrameRender) {\n this.willNextFrameRender = true;\n this.global.getRequestAnimationFrame()(() => {\n this._doRenderInThisFrame(), (this.willNextFrameRender = false);\n });\n }\n }\n\n _doRenderInThisFrame() {\n if (this.releaseStatus === 'released') {\n return;\n }\n this.timeline.resume();\n this.ticker.start();\n const state = this.state;\n this.state = 'rendering';\n this.layerService.prepareStageLayer(this);\n if (this.nextFrameRenderLayerSet.size && !this._skipRender) {\n this.hooks.beforeRender.call(this);\n if (!this._skipRender) {\n this.renderLayerList(Array.from(this.nextFrameRenderLayerSet.values()), this.lastRenderparams || {});\n this.combineLayersToWindow();\n this.nextFrameRenderLayerSet.clear();\n }\n this.hooks.afterRender.call(this);\n }\n this.state = state;\n this._skipRender && this._skipRender++;\n }\n\n protected renderLayerList(layerList: ILayer[], params?: Partial<IDrawContext>) {\n const list: ILayer[] = [];\n // 只需要render main layer即可\n for (let i = 0; i < layerList.length; i++) {\n let l = layerList[i];\n if (l.layerMode === 'virtual') {\n l = l.getNativeHandler().mainHandler.layer;\n }\n if (!list.includes(l)) {\n list.push(l);\n }\n }\n list.forEach(layer => {\n // 记录当前的stamp,避免重复绘制layer(如果存在virtual layer)\n if (layer.renderCount > this.renderCount) {\n return;\n }\n layer.renderCount = this.renderCount + 1;\n\n if (layer === this.interactiveLayer) {\n // 交互层由于其特殊性,不使用dirtyBounds\n this.dirtyBounds && this.dirtyBounds.clear();\n }\n layer.render(\n {\n renderService: this.renderService,\n background: layer === this.defaultLayer ? this.background : undefined,\n updateBounds: !!(this.dirtyBounds && !this.dirtyBounds.empty()),\n viewBox: this.window.getViewBox(),\n transMatrix: this.window.getViewBoxTransform()\n },\n { renderStyle: this.renderStyle, ...params }\n );\n });\n\n // 添加交互层渲染\n if (this.interactiveLayer && !layerList.includes(this.interactiveLayer)) {\n // 交互层由于其特殊性,不使用dirtyBounds\n this.dirtyBounds && this.dirtyBounds.clear();\n this.interactiveLayer.render(\n {\n renderService: this.renderService,\n updateBounds: !!(this.dirtyBounds && !this.dirtyBounds.empty()),\n viewBox: this.window.getViewBox(),\n transMatrix: this.window.getViewBoxTransform()\n },\n { renderStyle: this.renderStyle, ...params }\n );\n }\n }\n\n resizeWindow(w: number, h: number, rerender: boolean = true) {\n this.window.resize(w, h);\n rerender && this.render();\n }\n\n /**\n * 语法糖,如果viewBox和window宽高一样的话,那么会同时缩放window和viewBox\n * @param w\n * @param h\n * @param rerender\n */\n resize(w: number, h: number, rerender: boolean = true): void {\n if (this.releaseStatus === 'released') {\n return;\n }\n // 如果不是子图的stage,那么认为用户也想要resize view\n if (!this.window.hasSubView()) {\n this.viewBox.setValue(this.viewBox.x1, this.viewBox.y1, this.viewBox.x1 + w, this.viewBox.y1 + h);\n }\n this.window.resize(w, h);\n this.forEachChildren<ILayer>(c => {\n c.resize(w, h);\n });\n // 设置camera\n // this.camera && (this.camera.params = { ...this.camera.params, right: this.width, bottom: this.height });\n this.camera && this.option3d && this.set3dOptions(this.option3d);\n rerender && this.render();\n }\n resizeView(w: number, h: number, rerender: boolean = true) {\n if (this.releaseStatus === 'released') {\n return;\n }\n this.viewBox.setValue(this.viewBox.x1, this.viewBox.y1, this.viewBox.x1 + w, this.viewBox.y1 + h);\n this.forEachChildren<ILayer>(c => {\n c.resizeView(w, h);\n });\n // 设置camera\n this.camera && (this.camera.params = { ...this.camera.params, right: this.width, bottom: this.height });\n rerender && this.render();\n }\n setViewBox(viewBox: IBoundsLike, rerender: boolean): void;\n setViewBox(x: number, y: number, w: number, h: number, rerender: boolean): void;\n setViewBox(x: number | IBoundsLike, y: number | boolean, w?: number, h?: number, rerender?: boolean): void {\n let isRerender: boolean = true;\n\n if (typeof x === 'object') {\n this.viewBox.setValue(x.x1, x.y1, x.x2, x.y2);\n if (y === false) {\n isRerender = false;\n }\n } else {\n this.viewBox.setValue(x, y as number, x + w, (y as number) + h);\n\n if (rerender === false) {\n isRerender = false;\n }\n }\n\n this.forEachChildren<ILayer>(c => {\n c.resizeView(this.viewBox.width(), this.viewBox.height());\n });\n isRerender && this.render();\n }\n setDpr(dpr: number, rerender: boolean = true): void {\n // this.window.setDpr(dpr);\n this.forEachChildren<ILayer>(c => {\n c.setDpr(dpr);\n });\n\n rerender && this.render();\n }\n setOrigin(x: number, y: number): void {\n throw new Error('暂不支持');\n }\n export(type: IExportType): HTMLCanvasElement | ImageData {\n throw new Error('暂不支持');\n }\n pick(x: number, y: number): PickResult | false {\n if (this.releaseStatus === 'released') {\n return;\n }\n // 暂时不提供layer的pick\n const result = this.getPickerService().pick(this.children as unknown as IGraphic[], new Point(x, y), {\n bounds: this.AABBBounds\n });\n if (result?.graphic || result?.group) {\n return result;\n }\n return false;\n }\n\n // 动画相关\n startAnimate(t: number): void {\n throw new Error('暂不支持');\n }\n setToFrame(t: number): void {\n throw new Error('暂不支持');\n }\n\n release() {\n super.release();\n\n this.hooks.beforeRender.unTap('constructor', this.beforeRender);\n this.hooks.afterRender.unTap('constructor', this.afterRender);\n\n this.eventSystem && this.eventSystem.release();\n this.layerService.releaseStage(this);\n this.pluginService.release();\n this.forEach(layer => {\n layer.release();\n });\n // 额外删除掉interactiveLayer的节点\n if (this.interactiveLayer) {\n this.interactiveLayer.forEachChildren((item: IGraphic) => {\n item.setStage && item.setStage(null, null);\n this.interactiveLayer.removeChild(item);\n });\n this.interactiveLayer.release();\n }\n this.window.release();\n this.ticker.remTimeline(this.timeline);\n this.renderService.renderTreeRoots = [];\n }\n\n setStage(stage?: IStage) {\n return;\n // this.stage = this;\n // this.forEachChildren(item => {\n // (item as Layer).setStage(this);\n // });\n }\n\n /**\n * 添加dirty区域,会修改参数b\n * @param b\n * @param matrix\n */\n dirty(b: IBounds, matrix?: IMatrix) {\n if (this.releaseStatus === 'released') {\n return;\n }\n if (matrix) {\n b.transformWithMatrix(matrix);\n }\n if (this.dirtyBounds.empty()) {\n this.dirtyBounds.setValue(b.x1, b.y1, b.x2, b.y2);\n }\n this.dirtyBounds.union(b);\n }\n\n getLayer(name: string): undefined | ILayer {\n const layer = this.children.filter(layer => layer.name === name);\n return layer[0] as ILayer;\n }\n\n renderTo(window: IWindow) {\n if (this.releaseStatus === 'released') {\n return;\n }\n this.forEachChildren<ILayer>((layer, i) => {\n layer.drawTo(window, {\n // ...params,\n renderService: this.renderService,\n viewBox: window.getViewBox(),\n transMatrix: window.getViewBoxTransform(),\n background: layer === this.defaultLayer ? this.background : undefined,\n clear: i === 0, // 第一个layer需要clear\n updateBounds: !!(this.dirtyBounds && !this.dirtyBounds.empty())\n });\n });\n }\n\n /**\n * 渲染到新的window上去\n * @param fullImage 是否是全量的image,因为可能之前的window有一部分场景树超过window的帧缓冲了\n * @returns\n */\n renderToNewWindow(fullImage: boolean = true, viewBox?: IAABBBounds): IWindow {\n if (this.releaseStatus === 'released') {\n return;\n }\n const window = container.get<IWindow>(VWindow);\n const x1 = viewBox ? -viewBox.x1 : 0;\n const y1 = viewBox ? -viewBox.y1 : 0;\n const x2 = viewBox ? viewBox.x2 : this.viewWidth;\n const y2 = viewBox ? viewBox.y2 : this.viewHeight;\n const width = viewBox ? viewBox.width() : this.viewWidth;\n const height = viewBox ? viewBox.height() : this.viewHeight;\n if (fullImage) {\n window.create({\n viewBox: { x1, y1, x2, y2 },\n width,\n height,\n dpr: this.window.dpr,\n canvasControled: true,\n offscreen: true,\n title: ''\n });\n } else {\n window.create({\n viewBox: { x1, y1, x2, y2 },\n width,\n height,\n dpr: this.window.dpr,\n canvasControled: true,\n offscreen: true,\n title: ''\n });\n }\n\n this.renderTo(window);\n return window;\n }\n\n toCanvas(fullImage: boolean = true, viewBox?: IAABBBounds): HTMLCanvasElement | null {\n if (this.releaseStatus === 'released') {\n return;\n }\n const window = this.renderToNewWindow(fullImage, viewBox);\n const c = window.getNativeHandler();\n if (c.nativeCanvas) {\n return c.nativeCanvas;\n }\n return null;\n }\n\n setCursor(mode?: string): void {\n this._cursor = mode;\n this.eventSystem.setCursor(mode, 'ignore');\n }\n\n getCursor() {\n return this._cursor;\n }\n\n eventPointTransform(e: PointerEvent | WheelEvent | TouchEvent): { x: number; y: number } {\n const point = this.global.mapToCanvasPoint(e, this.window.getContext().canvas.nativeCanvas);\n\n return this.stage.window.pointTransform(point.x, point.y);\n }\n\n pauseTriggerEvent() {\n this._eventSystem && this._eventSystem.pauseTriggerEvent();\n }\n resumeTriggerEvent() {\n this._eventSystem && this._eventSystem.resumeTriggerEvent();\n }\n\n getPickerService() {\n if (!this.pickerService) {\n this.pickerService = container.get<IPickerService>(PickerService);\n }\n return this.pickerService;\n }\n}\n"]}
|