@visactor/vrender-core 0.20.16 → 0.21.0-alpha.10
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/Ticker/default-ticker.d.ts +4 -2
- package/cjs/animate/Ticker/default-ticker.js +8 -5
- package/cjs/animate/Ticker/default-ticker.js.map +1 -1
- package/cjs/animate/custom-animate.d.ts +2 -0
- package/cjs/animate/custom-animate.js +11 -2
- package/cjs/animate/custom-animate.js.map +1 -1
- package/cjs/common/color-utils.js +2 -2
- package/cjs/common/color-utils.js.map +1 -1
- package/cjs/core/contributions/textMeasure/AtextMeasure.d.ts +56 -4
- package/cjs/core/contributions/textMeasure/AtextMeasure.js +107 -14
- package/cjs/core/contributions/textMeasure/AtextMeasure.js.map +1 -1
- package/cjs/core/contributions/textMeasure/layout.d.ts +7 -3
- package/cjs/core/contributions/textMeasure/layout.js +40 -39
- package/cjs/core/contributions/textMeasure/layout.js.map +1 -1
- package/cjs/core/stage.d.ts +2 -0
- package/cjs/core/stage.js +9 -5
- package/cjs/core/stage.js.map +1 -1
- package/cjs/graphic/config.d.ts +1 -1
- package/cjs/graphic/config.js +4 -2
- package/cjs/graphic/config.js.map +1 -1
- package/cjs/graphic/graphic-service/graphic-service.d.ts +2 -0
- package/cjs/graphic/graphic-service/graphic-service.js +10 -5
- package/cjs/graphic/graphic-service/graphic-service.js.map +1 -1
- package/cjs/graphic/richtext/line.js +2 -9
- package/cjs/graphic/richtext/line.js.map +1 -1
- package/cjs/graphic/richtext/paragraph.js +3 -2
- package/cjs/graphic/richtext/paragraph.js.map +1 -1
- package/cjs/graphic/richtext/utils.d.ts +1 -2
- package/cjs/graphic/richtext/utils.js +3 -5
- package/cjs/graphic/richtext/utils.js.map +1 -1
- package/cjs/graphic/text.d.ts +11 -11
- package/cjs/graphic/text.js +99 -170
- package/cjs/graphic/text.js.map +1 -1
- package/cjs/graphic/wrap-text.js +12 -4
- package/cjs/graphic/wrap-text.js.map +1 -1
- package/cjs/interface/animate.d.ts +3 -1
- package/cjs/interface/animate.js.map +1 -1
- package/cjs/interface/graphic/text.d.ts +9 -3
- package/cjs/interface/graphic/text.js +6 -1
- package/cjs/interface/graphic/text.js.map +1 -1
- package/cjs/interface/graphic-service.d.ts +2 -0
- package/cjs/interface/graphic-service.js.map +1 -1
- package/cjs/interface/stage.d.ts +1 -0
- package/cjs/interface/stage.js.map +1 -1
- package/cjs/interface/text.d.ts +9 -1
- package/cjs/interface/text.js.map +1 -1
- package/cjs/plugins/builtin-plugin/dirty-bounds-plugin.js +3 -0
- package/cjs/plugins/builtin-plugin/dirty-bounds-plugin.js.map +1 -1
- package/cjs/render/contributions/render/draw-interceptor.js +2 -3
- package/cjs/render/contributions/render/draw-interceptor.js.map +1 -1
- package/cjs/render/contributions/render/text-render.d.ts +1 -1
- package/cjs/render/contributions/render/text-render.js +24 -46
- package/cjs/render/contributions/render/text-render.js.map +1 -1
- package/dist/index.es.js +2725 -2712
- package/es/animate/Ticker/default-ticker.d.ts +4 -2
- package/es/animate/Ticker/default-ticker.js +9 -6
- package/es/animate/Ticker/default-ticker.js.map +1 -1
- package/es/animate/custom-animate.d.ts +2 -0
- package/es/animate/custom-animate.js +11 -2
- package/es/animate/custom-animate.js.map +1 -1
- package/es/common/color-utils.js +2 -2
- package/es/common/color-utils.js.map +1 -1
- package/es/core/contributions/textMeasure/AtextMeasure.d.ts +56 -4
- package/es/core/contributions/textMeasure/AtextMeasure.js +108 -13
- package/es/core/contributions/textMeasure/AtextMeasure.js.map +1 -1
- package/es/core/contributions/textMeasure/layout.d.ts +7 -3
- package/es/core/contributions/textMeasure/layout.js +40 -39
- package/es/core/contributions/textMeasure/layout.js.map +1 -1
- package/es/core/stage.d.ts +2 -0
- package/es/core/stage.js +9 -5
- package/es/core/stage.js.map +1 -1
- package/es/graphic/config.d.ts +1 -1
- package/es/graphic/config.js +5 -1
- package/es/graphic/config.js.map +1 -1
- package/es/graphic/graphic-service/graphic-service.d.ts +2 -0
- package/es/graphic/graphic-service/graphic-service.js +11 -4
- package/es/graphic/graphic-service/graphic-service.js.map +1 -1
- package/es/graphic/richtext/line.js +3 -10
- package/es/graphic/richtext/line.js.map +1 -1
- package/es/graphic/richtext/paragraph.js +3 -2
- package/es/graphic/richtext/paragraph.js.map +1 -1
- package/es/graphic/richtext/utils.d.ts +1 -2
- package/es/graphic/richtext/utils.js +2 -6
- package/es/graphic/richtext/utils.js.map +1 -1
- package/es/graphic/text.d.ts +11 -11
- package/es/graphic/text.js +98 -165
- package/es/graphic/text.js.map +1 -1
- package/es/graphic/wrap-text.js +12 -4
- package/es/graphic/wrap-text.js.map +1 -1
- package/es/interface/animate.d.ts +3 -1
- package/es/interface/animate.js.map +1 -1
- package/es/interface/graphic/text.d.ts +9 -3
- package/es/interface/graphic/text.js +6 -1
- package/es/interface/graphic/text.js.map +1 -1
- package/es/interface/graphic-service.d.ts +2 -0
- package/es/interface/graphic-service.js.map +1 -1
- package/es/interface/stage.d.ts +1 -0
- package/es/interface/stage.js.map +1 -1
- package/es/interface/text.d.ts +9 -1
- package/es/interface/text.js.map +1 -1
- package/es/plugins/builtin-plugin/dirty-bounds-plugin.js +3 -0
- package/es/plugins/builtin-plugin/dirty-bounds-plugin.js.map +1 -1
- package/es/render/contributions/render/draw-interceptor.js +2 -3
- package/es/render/contributions/render/draw-interceptor.js.map +1 -1
- package/es/render/contributions/render/text-render.d.ts +1 -1
- package/es/render/contributions/render/text-render.js +23 -45
- package/es/render/contributions/render/text-render.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interface/stage.ts"],"names":[],"mappings":"","file":"stage.js","sourcesContent":["import type { INode } from './node-tree';\nimport type { ILayer, LayerMode } from './layer';\nimport type { IColor } from './color';\nimport type { IAABBBounds, IBounds, IBoundsLike, IMatrix } from '@visactor/vutils';\nimport type { ICamera } from './camera';\nimport type { vec3 } from './matrix';\nimport type { IDirectionLight } from './light';\nimport type { ISyncHook } from './sync-hook';\nimport type { IDrawContext, IRenderService } from './render';\nimport type { ITicker, ITimeline } from './animate';\nimport type { IPickerService, PickResult } from './picker';\nimport type { IPlugin, IPluginService } from './plugin';\nimport type { IWindow } from './window';\nimport type { ILayerService } from './core';\nimport type { IFullThemeSpec } from './graphic/theme';\n\nexport type IExportType = 'canvas' | 'imageData';\n\nexport type IStageCreateContext = {\n appName?: 'vchart' | 'vgrammar' | 'vtable' | string;\n};\nexport interface IStageParams {\n // x: number;\n // y: number;\n // // 视口的宽高\n // viewWidth: number;\n // viewHeight: number;\n\n // 视口的宽高\n viewBox: IBoundsLike;\n // 总的宽高\n width: number;\n height: number;\n dpr: number;\n // stage的背景\n background: string | IColor;\n // 外部的canvas\n canvas: string | HTMLCanvasElement;\n // canvas的container容器,如果不传入canvas,那就会在容器中创建canvas\n container: string | HTMLElement;\n // 是否是受控制的canvas,如果不是的话,不会进行resize等操作,也不会修改canvas的样式\n canvasControled: boolean;\n title: string;\n // 是否开启自动渲染\n autoRender: boolean;\n // 是否开启自动刷新\n autoRefresh: boolean;\n // 是否开启布局支持\n enableLayout: boolean;\n // 是否关闭脏矩形检测\n disableDirtyBounds: boolean;\n // 是否支持interactiveLayer,默认为true\n interactiveLayer: boolean;\n // 是否支持HTML属性\n enableHtmlAttribute: string | boolean | HTMLElement;\n // 是否支持react-dom(传入ReactDOM)\n ReactDOM: any;\n // 是否支持滚动条\n enableScroll: boolean;\n poptip: boolean;\n // 绘制之前的钩子函数\n beforeRender: (stage: IStage) => void;\n // 绘制之后的钩子函数\n afterRender: (stage: IStage) => void;\n renderStyle?: string;\n ticker?: ITicker;\n pluginList?: string[];\n // 优化配置\n optimize?: IOptimizeType;\n /**\n * 事件系统相关配置\n */\n event?: EventConfig;\n\n /**\n * @since 0.17.15\n * 是否支持touch事件,不支持就不监听touch事件\n */\n supportsTouchEvents?: boolean;\n\n /**\n * @since 0.17.15\n * 是否支持pointer事件,不支持就监听mouse事件\n */\n supportsPointerEvents?: boolean;\n\n context?: IStageCreateContext;\n}\n\nexport type EventConfig = {\n /** 是否自动阻止事件 */\n autoPreventDefault?: boolean;\n /**\n * 多次点击之间的最大时间,默认为 200 ms\n * @default 200\n */\n clickInterval?: number;\n [key: string]: any;\n};\n\nexport type IOptimizeType = {\n // 视口不在可视区,跳过渲染,默认为true\n skipRenderWithOutRange?: boolean;\n // 跳过图元在区间外的判断\n // 不存在dirtyBounds的时候,根据该配置判断是否关闭图元的超出边界判定\n // 如果有dirtyBounds那么该配置不生效\n disableCheckGraphicWidthOutRange?: boolean;\n};\n\nexport interface IOption3D {\n enableView3dTransform?: boolean; // 是否开启view3d自动旋转\n alpha?: number; // x轴的转角\n beta?: number; // y轴的转角\n gama?: number; // z轴的转角\n center?: { x?: number; y?: number; z?: number; dx?: number; dy?: number; dz?: number }; // 中心位置\n fieldRatio?: number; // 透视的视域缩放比例\n fieldDepth?: number;\n light?: {\n dir?: vec3;\n color?: string;\n ambient?: number;\n };\n // 配置相机后,alpha、beta、gamma配置会失效\n camera?: any; // 相机配置\n}\n\n// TODO 命名方式\nexport interface IStage extends INode {\n stage?: IStage;\n parent: IStage | null;\n // rootNode: IStage;\n x: number;\n y: number;\n\n params: Partial<IStageParams>;\n\n window: IWindow;\n\n width: number;\n height: number;\n viewWidth: number;\n viewHeight: number;\n defaultLayer: ILayer;\n dirtyBounds: IBounds | null;\n\n autoRender: boolean;\n renderCount: number;\n\n hooks: {\n beforeRender: ISyncHook<[IStage]>;\n afterRender: ISyncHook<[IStage]>;\n };\n\n option3d?: IOption3D;\n\n set3dOptions: (options: IOption3D) => void;\n light?: IDirectionLight;\n camera?: ICamera;\n\n dpr: number;\n\n viewBox: IBoundsLike;\n background: string | IColor;\n ticker: ITicker;\n increaseAutoRender: boolean;\n readonly renderService: IRenderService;\n getPickerService: () => IPickerService;\n readonly pluginService: IPluginService;\n readonly layerService: ILayerService;\n // 如果传入CanvasId,如果存在相同Id,说明这两个图层使用相同的Canvas绘制\n // 但需要注意的是依然是两个图层(用于解决Table嵌入ChartSpace不影响Table的绘制)\n createLayer: (canvasId?: string, layerMode?: LayerMode) => ILayer;\n getLayer: (name: string) => ILayer;\n sortLayer: (cb: (layer1: ILayer, layer2: ILayer) => number) => void;\n removeLayer: (layerId: number) => ILayer | false;\n\n getTimeline: () => ITimeline;\n\n render: (layers?: ILayer[], params?: Partial<IDrawContext>) => void;\n /**\n * 下一帧渲染\n * @param layers 渲染的图层\n * @param force 是否强行下一帧渲染,不采取优化方案\n * @returns\n */\n renderNextFrame: (layers?: ILayer[], force?: boolean) => void;\n tryInitInteractiveLayer: () => void;\n\n // 画布操作\n resize: (w: number, h: number, rerender?: boolean) => void;\n resizeWindow: (w: number, h: number, rerender?: boolean) => void;\n resizeView: (w: number, h: number, rerender?: boolean) => void;\n setViewBox:\n | ((viewBox: IBoundsLike, rerender: boolean) => void)\n | ((x: number, y: number, w: number, h: number, rerender: boolean) => void)\n | ((x: number | IBoundsLike, y: number | boolean, w?: number, h?: number, rerender?: boolean) => void);\n setDpr: (dpr: number, rerender?: boolean) => void;\n setOrigin: (x: number, y: number) => void;\n export: (type: IExportType) => HTMLCanvasElement | ImageData;\n pick: (x: number, y: number) => PickResult | false;\n\n // 动画相关\n startAnimate: (t: number) => void;\n setToFrame: (t: number) => void;\n dirty: (b: IBounds, matrix?: IMatrix) => void;\n // 考虑操作回放\n\n renderTo: (window: IWindow, params: { x: number; y: number; width: number; height: number }) => void;\n\n renderToNewWindow: (fullImage?: boolean) => IWindow;\n\n toCanvas: (fullImage?: boolean, viewBox?: IAABBBounds) => HTMLCanvasElement | null;\n\n setBeforeRender: (cb: (stage: IStage) => void) => void;\n\n setAfterRender: (cb: (stage: IStage) => void) => void;\n\n afterNextRender: (cb: (stage: IStage) => void) => void;\n enableAutoRender: () => void;\n disableAutoRender: () => void;\n enableIncrementalAutoRender: () => void;\n disableIncrementalAutoRender: () => void;\n enableDirtyBounds: () => void;\n disableDirtyBounds: () => void;\n enableView3dTransform: () => void;\n disableView3dTranform: () => void;\n getPluginsByName: (name: string) => IPlugin[];\n clearViewBox: (color?: string) => void;\n release: () => void;\n setStage: (stage?: IStage) => void;\n\n pauseRender: (sk?: number) => void;\n resumeRender: () => void;\n\n setCursor: (mode?: string) => void;\n\n getTheme: () => IFullThemeSpec;\n eventPointTransform: (e: PointerEvent | WheelEvent | TouchEvent) => { x: number; y: number };\n pauseTriggerEvent: () => void;\n resumeTriggerEvent: () => void;\n}\n\nexport declare function combineStage(srages: IStage[], params: { canvas: string | HTMLCanvasElement }): IStage;\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/interface/stage.ts"],"names":[],"mappings":"","file":"stage.js","sourcesContent":["import type { INode } from './node-tree';\nimport type { ILayer, LayerMode } from './layer';\nimport type { IColor } from './color';\nimport type { IAABBBounds, IBounds, IBoundsLike, IMatrix } from '@visactor/vutils';\nimport type { ICamera } from './camera';\nimport type { vec3 } from './matrix';\nimport type { IDirectionLight } from './light';\nimport type { ISyncHook } from './sync-hook';\nimport type { IDrawContext, IRenderService } from './render';\nimport type { ITicker, ITimeline } from './animate';\nimport type { IPickerService, PickResult } from './picker';\nimport type { IPlugin, IPluginService } from './plugin';\nimport type { IWindow } from './window';\nimport type { ILayerService } from './core';\nimport type { IFullThemeSpec } from './graphic/theme';\n\nexport type IExportType = 'canvas' | 'imageData';\n\nexport type IStageCreateContext = {\n appName?: 'vchart' | 'vgrammar' | 'vtable' | string;\n};\nexport interface IStageParams {\n // x: number;\n // y: number;\n // // 视口的宽高\n // viewWidth: number;\n // viewHeight: number;\n\n // 视口的宽高\n viewBox: IBoundsLike;\n // 总的宽高\n width: number;\n height: number;\n dpr: number;\n // stage的背景\n background: string | IColor;\n // 外部的canvas\n canvas: string | HTMLCanvasElement;\n // canvas的container容器,如果不传入canvas,那就会在容器中创建canvas\n container: string | HTMLElement;\n // 是否是受控制的canvas,如果不是的话,不会进行resize等操作,也不会修改canvas的样式\n canvasControled: boolean;\n title: string;\n // 是否开启自动渲染\n autoRender: boolean;\n // 是否开启自动刷新\n autoRefresh: boolean;\n // 是否开启布局支持\n enableLayout: boolean;\n // 是否关闭脏矩形检测\n disableDirtyBounds: boolean;\n // 是否支持interactiveLayer,默认为true\n interactiveLayer: boolean;\n // 是否支持HTML属性\n enableHtmlAttribute: string | boolean | HTMLElement;\n // 是否支持react-dom(传入ReactDOM)\n ReactDOM: any;\n // 是否支持滚动条\n enableScroll: boolean;\n poptip: boolean;\n // 绘制之前的钩子函数\n beforeRender: (stage: IStage) => void;\n // 绘制之后的钩子函数\n afterRender: (stage: IStage) => void;\n renderStyle?: string;\n ticker?: ITicker;\n pluginList?: string[];\n // 优化配置\n optimize?: IOptimizeType;\n /**\n * 事件系统相关配置\n */\n event?: EventConfig;\n\n /**\n * @since 0.17.15\n * 是否支持touch事件,不支持就不监听touch事件\n */\n supportsTouchEvents?: boolean;\n\n /**\n * @since 0.17.15\n * 是否支持pointer事件,不支持就监听mouse事件\n */\n supportsPointerEvents?: boolean;\n\n context?: IStageCreateContext;\n}\n\nexport type EventConfig = {\n /** 是否自动阻止事件 */\n autoPreventDefault?: boolean;\n /**\n * 多次点击之间的最大时间,默认为 200 ms\n * @default 200\n */\n clickInterval?: number;\n [key: string]: any;\n};\n\nexport type IOptimizeType = {\n // 视口不在可视区,跳过渲染,默认为true\n skipRenderWithOutRange?: boolean;\n // 跳过图元在区间外的判断\n // 不存在dirtyBounds的时候,根据该配置判断是否关闭图元的超出边界判定\n // 如果有dirtyBounds那么该配置不生效\n disableCheckGraphicWidthOutRange?: boolean;\n // tick渲染模式,effect会在tick之后立刻执行render,保证动画效果正常。performance模式中tick和render均是RAF,属性可能会被篡改\n tickRenderMode?: 'effect' | 'performance';\n};\n\nexport interface IOption3D {\n enableView3dTransform?: boolean; // 是否开启view3d自动旋转\n alpha?: number; // x轴的转角\n beta?: number; // y轴的转角\n gama?: number; // z轴的转角\n center?: { x?: number; y?: number; z?: number; dx?: number; dy?: number; dz?: number }; // 中心位置\n fieldRatio?: number; // 透视的视域缩放比例\n fieldDepth?: number;\n light?: {\n dir?: vec3;\n color?: string;\n ambient?: number;\n };\n // 配置相机后,alpha、beta、gamma配置会失效\n camera?: any; // 相机配置\n}\n\n// TODO 命名方式\nexport interface IStage extends INode {\n stage?: IStage;\n parent: IStage | null;\n // rootNode: IStage;\n x: number;\n y: number;\n\n params: Partial<IStageParams>;\n\n window: IWindow;\n\n width: number;\n height: number;\n viewWidth: number;\n viewHeight: number;\n defaultLayer: ILayer;\n dirtyBounds: IBounds | null;\n\n autoRender: boolean;\n renderCount: number;\n\n hooks: {\n beforeRender: ISyncHook<[IStage]>;\n afterRender: ISyncHook<[IStage]>;\n };\n\n option3d?: IOption3D;\n\n set3dOptions: (options: IOption3D) => void;\n light?: IDirectionLight;\n camera?: ICamera;\n\n dpr: number;\n\n viewBox: IBoundsLike;\n background: string | IColor;\n ticker: ITicker;\n increaseAutoRender: boolean;\n readonly renderService: IRenderService;\n getPickerService: () => IPickerService;\n readonly pluginService: IPluginService;\n readonly layerService: ILayerService;\n // 如果传入CanvasId,如果存在相同Id,说明这两个图层使用相同的Canvas绘制\n // 但需要注意的是依然是两个图层(用于解决Table嵌入ChartSpace不影响Table的绘制)\n createLayer: (canvasId?: string, layerMode?: LayerMode) => ILayer;\n getLayer: (name: string) => ILayer;\n sortLayer: (cb: (layer1: ILayer, layer2: ILayer) => number) => void;\n removeLayer: (layerId: number) => ILayer | false;\n\n getTimeline: () => ITimeline;\n\n render: (layers?: ILayer[], params?: Partial<IDrawContext>) => void;\n /**\n * 下一帧渲染\n * @param layers 渲染的图层\n * @param force 是否强行下一帧渲染,不采取优化方案\n * @returns\n */\n renderNextFrame: (layers?: ILayer[], force?: boolean) => void;\n tryInitInteractiveLayer: () => void;\n\n // 画布操作\n resize: (w: number, h: number, rerender?: boolean) => void;\n resizeWindow: (w: number, h: number, rerender?: boolean) => void;\n resizeView: (w: number, h: number, rerender?: boolean) => void;\n setViewBox:\n | ((viewBox: IBoundsLike, rerender: boolean) => void)\n | ((x: number, y: number, w: number, h: number, rerender: boolean) => void)\n | ((x: number | IBoundsLike, y: number | boolean, w?: number, h?: number, rerender?: boolean) => void);\n setDpr: (dpr: number, rerender?: boolean) => void;\n setOrigin: (x: number, y: number) => void;\n export: (type: IExportType) => HTMLCanvasElement | ImageData;\n pick: (x: number, y: number) => PickResult | false;\n\n // 动画相关\n startAnimate: (t: number) => void;\n setToFrame: (t: number) => void;\n dirty: (b: IBounds, matrix?: IMatrix) => void;\n // 考虑操作回放\n\n renderTo: (window: IWindow, params: { x: number; y: number; width: number; height: number }) => void;\n\n renderToNewWindow: (fullImage?: boolean) => IWindow;\n\n toCanvas: (fullImage?: boolean, viewBox?: IAABBBounds) => HTMLCanvasElement | null;\n\n setBeforeRender: (cb: (stage: IStage) => void) => void;\n\n setAfterRender: (cb: (stage: IStage) => void) => void;\n\n afterNextRender: (cb: (stage: IStage) => void) => void;\n enableAutoRender: () => void;\n disableAutoRender: () => void;\n enableIncrementalAutoRender: () => void;\n disableIncrementalAutoRender: () => void;\n enableDirtyBounds: () => void;\n disableDirtyBounds: () => void;\n enableView3dTransform: () => void;\n disableView3dTranform: () => void;\n getPluginsByName: (name: string) => IPlugin[];\n clearViewBox: (color?: string) => void;\n release: () => void;\n setStage: (stage?: IStage) => void;\n\n pauseRender: (sk?: number) => void;\n resumeRender: () => void;\n\n setCursor: (mode?: string) => void;\n\n getTheme: () => IFullThemeSpec;\n eventPointTransform: (e: PointerEvent | WheelEvent | TouchEvent) => { x: number; y: number };\n pauseTriggerEvent: () => void;\n resumeTriggerEvent: () => void;\n}\n\nexport declare function combineStage(srages: IStage[], params: { canvas: string | HTMLCanvasElement }): IStage;\n"]}
|
package/cjs/interface/text.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { IContribution } from './contribution';
|
|
2
2
|
import type { IGraphicUtil } from './core';
|
|
3
|
+
import type { MeasureModeEnum } from './graphic/text';
|
|
3
4
|
export interface TextOptionsType {
|
|
4
5
|
fontSize?: number;
|
|
5
6
|
fontWeight?: string | number;
|
|
6
7
|
fontFamily?: string;
|
|
7
8
|
fontStyle?: string;
|
|
8
9
|
fontVariant?: string;
|
|
10
|
+
lineHeight?: number;
|
|
9
11
|
textBaseline?: 'alphabetic' | 'top' | 'middle' | 'bottom';
|
|
10
12
|
textAlign?: 'left' | 'center' | 'right' | 'start' | 'end';
|
|
11
13
|
}
|
|
@@ -13,9 +15,15 @@ export interface ITextMeasure extends IContribution<IGraphicUtil> {
|
|
|
13
15
|
measureTextWidth: (text: string, options: TextOptionsType) => number;
|
|
14
16
|
measureTextPixelHeight: (text: string, options: TextOptionsType) => number;
|
|
15
17
|
measureTextBoundHieght: (text: string, options: TextOptionsType) => number;
|
|
18
|
+
measureTextPixelADscentAndWidth: (text: string, options: TextOptionsType, mode: MeasureModeEnum) => {
|
|
19
|
+
width: number;
|
|
20
|
+
ascent: number;
|
|
21
|
+
descent: number;
|
|
22
|
+
};
|
|
16
23
|
clipText: (text: string, options: TextOptionsType, width: number, wordBreak: boolean, keepAllBreak?: boolean) => {
|
|
17
24
|
str: string;
|
|
18
25
|
width: number;
|
|
26
|
+
wordBreaked?: number;
|
|
19
27
|
};
|
|
20
28
|
clipTextVertical: (verticalList: {
|
|
21
29
|
text: string;
|
|
@@ -29,7 +37,7 @@ export interface ITextMeasure extends IContribution<IGraphicUtil> {
|
|
|
29
37
|
}[];
|
|
30
38
|
width: number;
|
|
31
39
|
};
|
|
32
|
-
clipTextWithSuffix: (text: string, options: TextOptionsType, width: number, suffix: string, wordBreak: boolean, position: 'start' | 'end' | 'middle') => {
|
|
40
|
+
clipTextWithSuffix: (text: string, options: TextOptionsType, width: number, suffix: string | boolean, wordBreak: boolean, position: 'start' | 'end' | 'middle', forceSuffix?: boolean) => {
|
|
33
41
|
str: string;
|
|
34
42
|
width: number;
|
|
35
43
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interface/text.ts"],"names":[],"mappings":"","file":"text.js","sourcesContent":["import type { IContribution } from './contribution';\nimport type { IGraphicUtil } from './core';\n\nexport interface TextOptionsType {\n fontSize?: number;\n fontWeight?: string | number;\n fontFamily?: string;\n fontStyle?: string;\n fontVariant?: string;\n textBaseline?: 'alphabetic' | 'top' | 'middle' | 'bottom';\n textAlign?: 'left' | 'center' | 'right' | 'start' | 'end';\n}\n\nexport interface ITextMeasure extends IContribution<IGraphicUtil> {\n measureTextWidth: (text: string, options: TextOptionsType) => number;\n measureTextPixelHeight: (text: string, options: TextOptionsType) => number;\n measureTextBoundHieght: (text: string, options: TextOptionsType) => number;\n clipText: (\n text: string,\n options: TextOptionsType,\n width: number,\n wordBreak: boolean,\n keepAllBreak?: boolean\n ) => { str: string; width: number };\n clipTextVertical: (\n verticalList: { text: string; width?: number; direction: number }[],\n options: TextOptionsType,\n width: number,\n wordBreak: boolean\n ) => { verticalList: { text: string; width?: number; direction: number }[]; width: number };\n clipTextWithSuffix: (\n text: string,\n options: TextOptionsType,\n width: number,\n suffix: string,\n wordBreak: boolean,\n position: 'start' | 'end' | 'middle'\n ) => { str: string; width: number };\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 ) => { verticalList: { text: string; width?: number; direction: number }[]; width: number };\n measureText: (text: string, options: TextOptionsType) => { width: number };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/interface/text.ts"],"names":[],"mappings":"","file":"text.js","sourcesContent":["import type { IContribution } from './contribution';\nimport type { IGraphicUtil } from './core';\nimport type { MeasureModeEnum } from './graphic/text';\n\nexport interface TextOptionsType {\n fontSize?: number;\n fontWeight?: string | number;\n fontFamily?: string;\n fontStyle?: string;\n fontVariant?: string;\n lineHeight?: number;\n textBaseline?: 'alphabetic' | 'top' | 'middle' | 'bottom';\n textAlign?: 'left' | 'center' | 'right' | 'start' | 'end';\n}\n\nexport interface ITextMeasure extends IContribution<IGraphicUtil> {\n measureTextWidth: (text: string, options: TextOptionsType) => number;\n measureTextPixelHeight: (text: string, options: TextOptionsType) => number;\n measureTextBoundHieght: (text: string, options: TextOptionsType) => number;\n measureTextPixelADscentAndWidth: (\n text: string,\n options: TextOptionsType,\n mode: MeasureModeEnum\n ) => { width: number; ascent: number; descent: number };\n clipText: (\n text: string,\n options: TextOptionsType,\n width: number,\n wordBreak: boolean,\n keepAllBreak?: boolean\n ) => { str: string; width: number; wordBreaked?: number };\n clipTextVertical: (\n verticalList: { text: string; width?: number; direction: number }[],\n options: TextOptionsType,\n width: number,\n wordBreak: boolean\n ) => { verticalList: { text: string; width?: number; direction: number }[]; width: number };\n clipTextWithSuffix: (\n text: string,\n options: TextOptionsType,\n width: number,\n suffix: string | boolean,\n wordBreak: boolean,\n position: 'start' | 'end' | 'middle',\n forceSuffix?: boolean\n ) => { str: string; width: number };\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 ) => { verticalList: { text: string; width?: number; direction: number }[]; width: number };\n measureText: (text: string, options: TextOptionsType) => { width: number };\n}\n"]}
|
|
@@ -19,6 +19,8 @@ class DirtyBoundsPlugin {
|
|
|
19
19
|
stage.dirty(globalBounds, graphic.parent && graphic.parent.globalTransMatrix)));
|
|
20
20
|
})), application_1.application.graphicService.hooks.afterUpdateAABBBounds.tap(this.key, ((graphic, stage, bounds, params, selfChange) => {
|
|
21
21
|
stage && stage === this.pluginService.stage && stage.renderCount && (graphic.isContainer && !selfChange || stage.dirty(params.globalAABBBounds));
|
|
22
|
+
})), application_1.application.graphicService.hooks.clearAABBBounds.tap(this.key, ((graphic, stage, bounds) => {
|
|
23
|
+
stage && stage === this.pluginService.stage && stage.renderCount && stage && stage.dirty(bounds);
|
|
22
24
|
})), application_1.application.graphicService.hooks.onRemove.tap(this.key, (graphic => {
|
|
23
25
|
const stage = graphic.stage;
|
|
24
26
|
stage && stage === this.pluginService.stage && stage.renderCount && stage && stage.dirty(graphic.globalAABBBounds);
|
|
@@ -27,6 +29,7 @@ class DirtyBoundsPlugin {
|
|
|
27
29
|
deactivate(context) {
|
|
28
30
|
application_1.application.graphicService.hooks.beforeUpdateAABBBounds.taps = application_1.application.graphicService.hooks.beforeUpdateAABBBounds.taps.filter((item => item.name !== this.key)),
|
|
29
31
|
application_1.application.graphicService.hooks.afterUpdateAABBBounds.taps = application_1.application.graphicService.hooks.afterUpdateAABBBounds.taps.filter((item => item.name !== this.key)),
|
|
32
|
+
application_1.application.graphicService.hooks.clearAABBBounds.taps = application_1.application.graphicService.hooks.clearAABBBounds.taps.filter((item => item.name !== this.key)),
|
|
30
33
|
context.stage.hooks.afterRender.taps = context.stage.hooks.afterRender.taps.filter((item => item.name !== this.key)),
|
|
31
34
|
application_1.application.graphicService.hooks.onRemove.taps = application_1.application.graphicService.hooks.onRemove.taps.filter((item => item.name !== this.key));
|
|
32
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugins/builtin-plugin/dirty-bounds-plugin.ts"],"names":[],"mappings":";;;AACA,6CAA8C;AAC9C,sDAAmD;AAEnD,mDAAgD;AAEhD,MAAM,YAAY,GAAG,IAAI,mBAAU,EAAE,CAAC;AAEtC,MAAa,iBAAiB;IAA9B;QACE,SAAI,GAAwB,mBAAmB,CAAC;QAChD,gBAAW,GAAiB,YAAY,CAAC;QAEzC,SAAI,GAAW,qBAAS,CAAC,kBAAkB,EAAE,CAAC;QAC9C,QAAG,GAAW,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/plugins/builtin-plugin/dirty-bounds-plugin.ts"],"names":[],"mappings":";;;AACA,6CAA8C;AAC9C,sDAAmD;AAEnD,mDAAgD;AAEhD,MAAM,YAAY,GAAG,IAAI,mBAAU,EAAE,CAAC;AAEtC,MAAa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,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;YAC5G,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC;QAChC,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA9FD,8CA8FC","file":"dirty-bounds-plugin.js","sourcesContent":["import type { IAABBBounds } from '@visactor/vutils';\nimport { AABBBounds } from '@visactor/vutils';\nimport { Generator } from '../../common/generator';\nimport type { IGraphic, IStage, IPlugin, IPluginService } from '../../interface';\nimport { application } from '../../application';\n\nconst globalBounds = new AABBBounds();\n\nexport class DirtyBoundsPlugin implements IPlugin {\n name: 'DirtyBoundsPlugin' = 'DirtyBoundsPlugin';\n activeEvent: 'onRegister' = 'onRegister';\n pluginService: IPluginService;\n _uid: number = Generator.GenAutoIncrementId();\n key: string = this.name + this._uid;\n\n activate(context: IPluginService): void {\n this.pluginService = context;\n context.stage.hooks.afterRender.tap(this.key, stage => {\n if (!(stage && stage === this.pluginService.stage)) {\n return;\n }\n stage.dirtyBounds.clear();\n });\n application.graphicService.hooks.beforeUpdateAABBBounds.tap(\n this.key,\n (graphic: IGraphic, stage: IStage, willUpdate: boolean, bounds: IAABBBounds) => {\n if (graphic.glyphHost) {\n graphic = graphic.glyphHost;\n }\n if (!(stage && stage === this.pluginService.stage && stage.renderCount)) {\n return;\n }\n // group的子元素导致的bounds更新不用做dirtyBounds\n if (graphic.isContainer && !graphic.shouldSelfChangeUpdateAABBBounds()) {\n return;\n }\n if (willUpdate) {\n globalBounds.setValue(bounds.x1, bounds.y1, bounds.x2, bounds.y2);\n stage.dirty(globalBounds, graphic.parent && graphic.parent.globalTransMatrix);\n }\n }\n );\n application.graphicService.hooks.afterUpdateAABBBounds.tap(\n this.key,\n (\n graphic: IGraphic,\n stage: IStage,\n bounds: IAABBBounds,\n params: { globalAABBBounds: IAABBBounds },\n selfChange: boolean\n ) => {\n if (!(stage && stage === this.pluginService.stage && stage.renderCount)) {\n return;\n }\n // group的子元素导致的bounds更新不用做dirtyBounds\n if (graphic.isContainer && !selfChange) {\n return;\n }\n stage.dirty(params.globalAABBBounds);\n }\n );\n application.graphicService.hooks.clearAABBBounds.tap(\n this.key,\n (graphic: IGraphic, stage: IStage, bounds: IAABBBounds) => {\n if (!(stage && stage === this.pluginService.stage && stage.renderCount)) {\n return;\n }\n if (stage) {\n stage.dirty(bounds);\n }\n }\n );\n application.graphicService.hooks.onRemove.tap(this.key, (graphic: IGraphic) => {\n const stage = graphic.stage;\n if (!(stage && stage === this.pluginService.stage && stage.renderCount)) {\n return;\n }\n if (stage) {\n stage.dirty(graphic.globalAABBBounds);\n }\n });\n }\n deactivate(context: IPluginService): void {\n application.graphicService.hooks.beforeUpdateAABBBounds.taps =\n application.graphicService.hooks.beforeUpdateAABBBounds.taps.filter(item => {\n return item.name !== this.key;\n });\n application.graphicService.hooks.afterUpdateAABBBounds.taps =\n application.graphicService.hooks.afterUpdateAABBBounds.taps.filter(item => {\n return item.name !== this.key;\n });\n application.graphicService.hooks.clearAABBBounds.taps =\n application.graphicService.hooks.clearAABBBounds.taps.filter(item => {\n return item.name !== this.key;\n });\n context.stage.hooks.afterRender.taps = context.stage.hooks.afterRender.taps.filter(item => {\n return item.name !== this.key;\n });\n application.graphicService.hooks.onRemove.taps = application.graphicService.hooks.onRemove.taps.filter(item => {\n return item.name !== this.key;\n });\n }\n}\n"]}
|
|
@@ -33,9 +33,8 @@ class ShadowRootDrawItemInterceptorContribution {
|
|
|
33
33
|
drawItem(graphic, renderService, drawContext, drawContribution, params) {
|
|
34
34
|
if (!graphic.shadowRoot) return !1;
|
|
35
35
|
const {context: context} = drawContext;
|
|
36
|
-
context.highPerformanceSave()
|
|
37
|
-
|
|
38
|
-
if (graphic.parent && context.setTransformFromMatrix(t2, !0), drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {
|
|
36
|
+
if (context.highPerformanceSave(), context.transformFromMatrix(graphic.transMatrix, !0),
|
|
37
|
+
drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {
|
|
39
38
|
tempDirtyBounds.copy(drawContribution.dirtyBounds), tempBackupDirtyBounds.copy(drawContribution.backupDirtyBounds);
|
|
40
39
|
const m = graphic.globalTransMatrix.getInverse();
|
|
41
40
|
drawContribution.dirtyBounds.copy(drawContribution.backupDirtyBounds).transformWithMatrix(m),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/render/draw-interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mEAA4D;AAC5D,6CAA8C;AAC9C,mDAAsE;AACtE,sEAAkE;AAYlE,wEAAkF;AAClF,oEAA4D;AAG/C,QAAA,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;AASrE,MAAM,eAAe,GAAG,IAAI,mBAAU,EAAE,CAAC;AACzC,MAAM,qBAAqB,GAAG,IAAI,mBAAU,EAAE,CAAC;AAK/C,MAAa,yCAAyC;IAAtD;QACE,UAAK,GAAW,CAAC,CAAC;IAsFpB,CAAC;IArFC,aAAa,CACX,OAAiB,EACjB,aAA6B,EAC7B,WAAyB,EACzB,gBAAmC,EACnC,MAAiC;QAGjC,IACE,OAAO,CAAC,SAAS,CAAC,aAAa,IAAI,IAAI;YACvC,OAAO,CAAC,UAAU;YAClB,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,aAAa,GAAG,CAAC,EAC9C;YACA,OAAO,KAAK,CAAC;SACd;QACD,IACE,OAAO,CAAC,SAAS,CAAC,aAAa,GAAG,CAAC;YACnC,CAAC,OAAO,CAAC,SAAS,CAAC,aAAa;YAChC,CAAC,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,aAAa,GAAG,CAAC,CAAC,EACtE;YACA,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,CAAC,CAAC;SAC9E;QACD,OAAO,KAAK,CAAC;IACf,CAAC;I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,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;QAG7C,IAAI,OAAO,CAAC,WAAW,EAAE;YACvB,IAAA,4BAAU,EACR,OAAO,EACP,OAAO,EACP,CAAC,KAAc,EAAE,IAAa,EAAE,EAAE;gBAChC,OAAO,gBAAgB,CAAC,WAAW,CACjC,OAAiB,EACjB,WAAW,EACX,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAChC,CAAC,KAAK,IAAI,IAAI,CACf,CAAC;YACJ,CAAC,EACD,WAAW,CACZ,CAAC;SACH;aAAM;YACL,gBAAgB,CAAC,UAAU,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;SACnD;QACD,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;QACtB,OAAO,CAAC,OAAO,EAAE,CAAC;QAElB,IAAI,OAAO,CAAC,WAAW,KAAK,eAAe,EAAE;YAC3C,8BAAY,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;SACxC;QACD,OAAO,CAAC,WAAW,GAAG,eAAe,CAAC;QAEtC,WAAW,CAAC,eAAe,GAAG,KAAK,CAAC;QACpC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,aAAa,CAAC,OAAmB;QAC/B,OAAO,CAAC,sBAAsB,EAAE,CAAC;IACnC,CAAC;CACF;AA9ED,kEA8EC","file":"draw-interceptor.js","sourcesContent":["import { injectable } from '../../../common/inversify-lite';\nimport { AABBBounds } from '@visactor/vutils';\nimport { mat3Tomat4, multiplyMat4Mat4 } from '../../../common/matrix';\nimport { graphicCreator } from '../../../graphic/graphic-creator';\nimport type {\n IContext2d,\n IDrawContext,\n IDrawContribution,\n IDrawItemInterceptorContribution,\n IGraphic,\n IGraphicRenderDrawParams,\n IGroup,\n ILayer,\n IRenderService\n} from '../../../interface';\nimport { mat4Allocate, matrixAllocate } from '../../../allocator/matrix-allocate';\nimport { draw3dItem } from '../../../common/3d-interceptor';\n\n// 拦截器\nexport const DrawItemInterceptor = Symbol.for('DrawItemInterceptor');\n\n// @injectable()\n// export class DefaultDrawItemInterceptor implements IDrawItemInterceptor {\n// drawItem(graphic: IGraphic, renderService: IRenderService, params?: IGraphicRenderDrawParams): boolean {\n// return false;\n// }\n// }\n\nconst tempDirtyBounds = new AABBBounds();\nconst tempBackupDirtyBounds = new AABBBounds();\n/**\n * 影子节点拦截器,用于渲染影子节点\n */\n// @injectable()\nexport class ShadowRootDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 如果graphic没设置shadowRootIdx,shadowRoot设置了,那就使用shadowRoot的shadowRootIdx\n if (\n graphic.attribute.shadowRootIdx == null &&\n graphic.shadowRoot &&\n graphic.shadowRoot.attribute.shadowRootIdx < 0\n ) {\n return false;\n }\n if (\n graphic.attribute.shadowRootIdx > 0 ||\n !graphic.attribute.shadowRootIdx ||\n (graphic.shadowRoot && graphic.shadowRoot.attribute.shadowRootIdx > 0)\n ) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 如果graphic没设置shadowRootIdx,shadowRoot设置了,那就使用shadowRoot的shadowRootIdx\n if (\n graphic.attribute.shadowRootIdx == null &&\n graphic.shadowRoot &&\n graphic.shadowRoot.attribute.shadowRootIdx > 0\n ) {\n return false;\n }\n if (graphic.attribute.shadowRootIdx < 0 || (graphic.shadowRoot && graphic.shadowRoot.attribute.shadowRootIdx < 0)) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n protected drawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (!graphic.shadowRoot) {\n return false;\n }\n\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n const t1 = graphic.parent.globalTransMatrix;\n const t2 = graphic.stage.window.getViewBoxTransform().clone().multiply(t1.a, t1.b, t1.c, t1.d, t1.e, t1.f);\n graphic.parent && context.setTransformFromMatrix(t2, true);\n\n // 变换dirtyBounds\n if (drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {\n tempDirtyBounds.copy(drawContribution.dirtyBounds);\n tempBackupDirtyBounds.copy(drawContribution.backupDirtyBounds);\n const m = graphic.globalTransMatrix.getInverse();\n drawContribution.dirtyBounds.copy(drawContribution.backupDirtyBounds).transformWithMatrix(m);\n drawContribution.backupDirtyBounds.copy(drawContribution.dirtyBounds);\n }\n\n // 设置context的transform到上一个节点\n drawContribution.renderGroup(graphic.shadowRoot, drawContext, matrixAllocate.allocate(1, 0, 0, 1, 0, 0));\n\n context.highPerformanceRestore();\n\n if (drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {\n drawContribution.dirtyBounds.copy(tempDirtyBounds);\n drawContribution.backupDirtyBounds.copy(tempBackupDirtyBounds);\n }\n\n return true;\n }\n}\n\n// @injectable()\nexport class DebugDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (graphic.attribute._debug_bounds) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n protected drawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (!graphic.attribute._debug_bounds) {\n return false;\n }\n\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n graphic.parent && context.setTransformFromMatrix(graphic.parent.globalTransMatrix, true);\n graphic.glyphHost &&\n graphic.glyphHost.parent &&\n context.setTransformFromMatrix(graphic.glyphHost.parent.globalTransMatrix, true);\n\n const b = graphic.AABBBounds;\n\n if (graphic.attribute._debug_bounds !== true) {\n graphic.attribute._debug_bounds(context, graphic);\n }\n context.strokeRect(b.x1, b.y1, b.width(), b.height());\n\n context.highPerformanceRestore();\n\n return true;\n }\n}\n\n@injectable()\nexport class CommonDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n interceptors: IDrawItemInterceptorContribution[];\n constructor() {\n this.interceptors = [\n new ShadowRootDrawItemInterceptorContribution(),\n new Canvas3DDrawItemInterceptor(),\n new InteractiveDrawItemInterceptorContribution(),\n new DebugDrawItemInterceptorContribution()\n ];\n }\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n for (let i = 0; i < this.interceptors.length; i++) {\n if (\n this.interceptors[i].afterDrawItem &&\n this.interceptors[i].afterDrawItem(graphic, renderService, drawContext, drawContribution, params)\n ) {\n return true;\n }\n }\n return false;\n }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 【性能方案】判定写在外层,减少遍历判断耗时,10000条数据减少1ms\n if (\n (!graphic.in3dMode || drawContext.in3dInterceptor) &&\n !graphic.shadowRoot &&\n !(graphic.baseGraphic || graphic.attribute.globalZIndex || graphic.interactiveGraphic)\n ) {\n return false;\n }\n\n for (let i = 0; i < this.interceptors.length; i++) {\n if (\n this.interceptors[i].beforeDrawItem &&\n this.interceptors[i].beforeDrawItem(graphic, renderService, drawContext, drawContribution, params)\n ) {\n return true;\n }\n }\n return false;\n }\n}\n\n/**\n * 交互层节点拦截器,用于支持交互层图元\n */\n// @injectable()\nexport class InteractiveDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n processing: boolean;\n // afterDrawItem(\n // graphic: IGraphic,\n // renderService: IRenderService,\n // drawContext: IDrawContext,\n // drawContribution: IDrawContribution,\n // params?: IGraphicRenderDrawParams\n // ): boolean {\n\n // if (graphic.attribute.shadowRootIdx > 0 || !graphic.attribute.shadowRootIdx) {\n // this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n // }\n // return false;\n // }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (this.processing) {\n return false;\n }\n // 判断是否在交互层\n if (graphic.baseGraphic) {\n return this.beforeDrawInteractive(graphic, renderService, drawContext, drawContribution, params);\n }\n return this.beforeSetInteractive(graphic, renderService, drawContext, drawContribution, params);\n }\n\n /**\n * 用于提升interactive\n * @param graphic\n * @param renderService\n * @param drawContext\n * @param drawContribution\n * @param params\n */\n beforeSetInteractive(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n let interactiveGraphic: IGraphic = graphic.interactiveGraphic;\n if (graphic.attribute.globalZIndex) {\n if (!interactiveGraphic) {\n interactiveGraphic = graphic.clone();\n graphic.interactiveGraphic = interactiveGraphic;\n interactiveGraphic.baseGraphic = graphic;\n }\n // 设置位置\n // const m = graphic.globalTransMatrix;\n interactiveGraphic.setAttributes(\n {\n globalZIndex: 0,\n zIndex: graphic.attribute.globalZIndex\n },\n false,\n { skipUpdateCallback: true }\n );\n // 添加到交互层中\n drawContext.stage.tryInitInteractiveLayer();\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.add(interactiveGraphic);\n }\n return true;\n } else if (interactiveGraphic) {\n // 从交互层中删除\n drawContext.stage.tryInitInteractiveLayer();\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.removeChild(interactiveGraphic);\n }\n graphic.interactiveGraphic = null;\n interactiveGraphic.baseGraphic = null;\n }\n return false;\n }\n\n /**\n * 用于绘制interactive\n * @param graphic\n * @param renderService\n * @param drawContext\n * @param drawContribution\n * @param params\n */\n beforeDrawInteractive(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 默认使用原始的图元\n const baseGraphic = graphic.baseGraphic as IGraphic;\n // 如果主图元被删除了,那把交互图元这个也删除\n // 一直往上找\n let intree = !!baseGraphic.stage;\n let _g = baseGraphic.parent;\n while (intree && _g) {\n if ((_g as any).stage === _g) {\n break;\n }\n intree = !!_g.stage;\n _g = _g.parent;\n }\n if (!intree) {\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.removeChild(graphic);\n }\n return true;\n }\n if (baseGraphic) {\n this.processing = true;\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n context.setTransformFromMatrix(baseGraphic.parent.globalTransMatrix, true);\n // context.fillRect(0, 0, 100, 100);\n // 设置context的transform到上一个节点\n baseGraphic.isContainer\n ? drawContribution.renderGroup(baseGraphic as IGroup, drawContext, baseGraphic.parent.globalTransMatrix)\n : drawContribution.renderItem(baseGraphic, drawContext);\n\n context.highPerformanceRestore();\n this.processing = false;\n\n return true;\n }\n return false;\n }\n getShadowRoot(interactiveLayer: ILayer) {\n // 获取绑定影子节点的group\n let group = interactiveLayer.getElementById('_interactive_group') as IGroup;\n if (!group) {\n group = graphicCreator.CreateGraphic('group', {});\n group.id = '_interactive_group';\n interactiveLayer.add(group);\n }\n return group.shadowRoot ?? group.attachShadow();\n }\n}\n\n/**\n * 3d拦截器,用于渲染3d视角\n */\n// @injectable()\nexport class Canvas3DDrawItemInterceptor implements IDrawItemInterceptorContribution {\n // canvas?: ICanvas;\n order: number = 1;\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ) {\n if (!graphic.in3dMode || drawContext.in3dInterceptor) {\n return false;\n }\n\n drawContext.in3dInterceptor = true;\n const { context, stage } = renderService.drawParams;\n const canvas = context.canvas;\n\n // 使用3d模式渲染\n context.save();\n this.initCanvasCtx(context);\n context.camera = stage.camera;\n\n // 将三维矩阵换成四维矩阵\n const m = context.currentMatrix;\n m.a /= context.dpr;\n m.b /= context.dpr;\n m.c /= context.dpr;\n m.d /= context.dpr;\n m.e /= context.dpr;\n m.f /= context.dpr;\n const matrix = mat4Allocate.allocate();\n mat3Tomat4(matrix, m);\n const lastModelMatrix = context.modelMatrix;\n if (lastModelMatrix) {\n if (matrix) {\n const m = mat4Allocate.allocate();\n context.modelMatrix = multiplyMat4Mat4(m, lastModelMatrix, matrix);\n }\n } else {\n context.modelMatrix = matrix;\n }\n context.setTransform(1, 0, 0, 1, 0, 0, true);\n\n // 设置context的transform到上一个节点\n if (graphic.isContainer) {\n draw3dItem(\n context,\n graphic,\n (isPie: boolean, is3d: boolean) => {\n return drawContribution.renderGroup(\n graphic as IGroup,\n drawContext,\n graphic.parent.globalTransMatrix,\n !isPie && is3d\n );\n },\n drawContext\n );\n } else {\n drawContribution.renderItem(graphic, drawContext);\n }\n context.camera = null;\n context.restore();\n\n if (context.modelMatrix !== lastModelMatrix) {\n mat4Allocate.free(context.modelMatrix);\n }\n context.modelMatrix = lastModelMatrix;\n\n drawContext.in3dInterceptor = false;\n return true;\n }\n\n initCanvasCtx(context: IContext2d) {\n context.setTransformForCurrent();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/render/contributions/render/draw-interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mEAA4D;AAC5D,6CAA8C;AAC9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AC,eAAe,GAAG,KAAK,CAAC;QACpC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,aAAa,CAAC,OAAmB;QAC/B,OAAO,CAAC,sBAAsB,EAAE,CAAC;IACnC,CAAC;CACF;AA9ED,kEA8EC","file":"draw-interceptor.js","sourcesContent":["import { injectable } from '../../../common/inversify-lite';\nimport { AABBBounds } from '@visactor/vutils';\nimport { mat3Tomat4, multiplyMat4Mat4 } from '../../../common/matrix';\nimport { graphicCreator } from '../../../graphic/graphic-creator';\nimport type {\n IContext2d,\n IDrawContext,\n IDrawContribution,\n IDrawItemInterceptorContribution,\n IGraphic,\n IGraphicRenderDrawParams,\n IGroup,\n ILayer,\n IRenderService\n} from '../../../interface';\nimport { mat4Allocate, matrixAllocate } from '../../../allocator/matrix-allocate';\nimport { draw3dItem } from '../../../common/3d-interceptor';\n\n// 拦截器\nexport const DrawItemInterceptor = Symbol.for('DrawItemInterceptor');\n\n// @injectable()\n// export class DefaultDrawItemInterceptor implements IDrawItemInterceptor {\n// drawItem(graphic: IGraphic, renderService: IRenderService, params?: IGraphicRenderDrawParams): boolean {\n// return false;\n// }\n// }\n\nconst tempDirtyBounds = new AABBBounds();\nconst tempBackupDirtyBounds = new AABBBounds();\n/**\n * 影子节点拦截器,用于渲染影子节点\n */\n// @injectable()\nexport class ShadowRootDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 如果graphic没设置shadowRootIdx,shadowRoot设置了,那就使用shadowRoot的shadowRootIdx\n if (\n graphic.attribute.shadowRootIdx == null &&\n graphic.shadowRoot &&\n graphic.shadowRoot.attribute.shadowRootIdx < 0\n ) {\n return false;\n }\n if (\n graphic.attribute.shadowRootIdx > 0 ||\n !graphic.attribute.shadowRootIdx ||\n (graphic.shadowRoot && graphic.shadowRoot.attribute.shadowRootIdx > 0)\n ) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 如果graphic没设置shadowRootIdx,shadowRoot设置了,那就使用shadowRoot的shadowRootIdx\n if (\n graphic.attribute.shadowRootIdx == null &&\n graphic.shadowRoot &&\n graphic.shadowRoot.attribute.shadowRootIdx > 0\n ) {\n return false;\n }\n if (graphic.attribute.shadowRootIdx < 0 || (graphic.shadowRoot && graphic.shadowRoot.attribute.shadowRootIdx < 0)) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n protected drawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (!graphic.shadowRoot) {\n return false;\n }\n\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n context.transformFromMatrix(graphic.transMatrix, true);\n\n // 变换dirtyBounds\n if (drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {\n tempDirtyBounds.copy(drawContribution.dirtyBounds);\n tempBackupDirtyBounds.copy(drawContribution.backupDirtyBounds);\n const m = graphic.globalTransMatrix.getInverse();\n drawContribution.dirtyBounds.copy(drawContribution.backupDirtyBounds).transformWithMatrix(m);\n drawContribution.backupDirtyBounds.copy(drawContribution.dirtyBounds);\n }\n\n // 设置context的transform到上一个节点\n drawContribution.renderGroup(graphic.shadowRoot, drawContext, matrixAllocate.allocate(1, 0, 0, 1, 0, 0));\n\n context.highPerformanceRestore();\n\n if (drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {\n drawContribution.dirtyBounds.copy(tempDirtyBounds);\n drawContribution.backupDirtyBounds.copy(tempBackupDirtyBounds);\n }\n\n return true;\n }\n}\n\n// @injectable()\nexport class DebugDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (graphic.attribute._debug_bounds) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n protected drawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (!graphic.attribute._debug_bounds) {\n return false;\n }\n\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n graphic.parent && context.setTransformFromMatrix(graphic.parent.globalTransMatrix, true);\n graphic.glyphHost &&\n graphic.glyphHost.parent &&\n context.setTransformFromMatrix(graphic.glyphHost.parent.globalTransMatrix, true);\n\n const b = graphic.AABBBounds;\n\n if (graphic.attribute._debug_bounds !== true) {\n graphic.attribute._debug_bounds(context, graphic);\n }\n context.strokeRect(b.x1, b.y1, b.width(), b.height());\n\n context.highPerformanceRestore();\n\n return true;\n }\n}\n\n@injectable()\nexport class CommonDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n interceptors: IDrawItemInterceptorContribution[];\n constructor() {\n this.interceptors = [\n new ShadowRootDrawItemInterceptorContribution(),\n new Canvas3DDrawItemInterceptor(),\n new InteractiveDrawItemInterceptorContribution(),\n new DebugDrawItemInterceptorContribution()\n ];\n }\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n for (let i = 0; i < this.interceptors.length; i++) {\n if (\n this.interceptors[i].afterDrawItem &&\n this.interceptors[i].afterDrawItem(graphic, renderService, drawContext, drawContribution, params)\n ) {\n return true;\n }\n }\n return false;\n }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 【性能方案】判定写在外层,减少遍历判断耗时,10000条数据减少1ms\n if (\n (!graphic.in3dMode || drawContext.in3dInterceptor) &&\n !graphic.shadowRoot &&\n !(graphic.baseGraphic || graphic.attribute.globalZIndex || graphic.interactiveGraphic)\n ) {\n return false;\n }\n\n for (let i = 0; i < this.interceptors.length; i++) {\n if (\n this.interceptors[i].beforeDrawItem &&\n this.interceptors[i].beforeDrawItem(graphic, renderService, drawContext, drawContribution, params)\n ) {\n return true;\n }\n }\n return false;\n }\n}\n\n/**\n * 交互层节点拦截器,用于支持交互层图元\n */\n// @injectable()\nexport class InteractiveDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n processing: boolean;\n // afterDrawItem(\n // graphic: IGraphic,\n // renderService: IRenderService,\n // drawContext: IDrawContext,\n // drawContribution: IDrawContribution,\n // params?: IGraphicRenderDrawParams\n // ): boolean {\n\n // if (graphic.attribute.shadowRootIdx > 0 || !graphic.attribute.shadowRootIdx) {\n // this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n // }\n // return false;\n // }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (this.processing) {\n return false;\n }\n // 判断是否在交互层\n if (graphic.baseGraphic) {\n return this.beforeDrawInteractive(graphic, renderService, drawContext, drawContribution, params);\n }\n return this.beforeSetInteractive(graphic, renderService, drawContext, drawContribution, params);\n }\n\n /**\n * 用于提升interactive\n * @param graphic\n * @param renderService\n * @param drawContext\n * @param drawContribution\n * @param params\n */\n beforeSetInteractive(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n let interactiveGraphic: IGraphic = graphic.interactiveGraphic;\n if (graphic.attribute.globalZIndex) {\n if (!interactiveGraphic) {\n interactiveGraphic = graphic.clone();\n graphic.interactiveGraphic = interactiveGraphic;\n interactiveGraphic.baseGraphic = graphic;\n }\n // 设置位置\n // const m = graphic.globalTransMatrix;\n interactiveGraphic.setAttributes(\n {\n globalZIndex: 0,\n zIndex: graphic.attribute.globalZIndex\n },\n false,\n { skipUpdateCallback: true }\n );\n // 添加到交互层中\n drawContext.stage.tryInitInteractiveLayer();\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.add(interactiveGraphic);\n }\n return true;\n } else if (interactiveGraphic) {\n // 从交互层中删除\n drawContext.stage.tryInitInteractiveLayer();\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.removeChild(interactiveGraphic);\n }\n graphic.interactiveGraphic = null;\n interactiveGraphic.baseGraphic = null;\n }\n return false;\n }\n\n /**\n * 用于绘制interactive\n * @param graphic\n * @param renderService\n * @param drawContext\n * @param drawContribution\n * @param params\n */\n beforeDrawInteractive(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 默认使用原始的图元\n const baseGraphic = graphic.baseGraphic as IGraphic;\n // 如果主图元被删除了,那把交互图元这个也删除\n // 一直往上找\n let intree = !!baseGraphic.stage;\n let _g = baseGraphic.parent;\n while (intree && _g) {\n if ((_g as any).stage === _g) {\n break;\n }\n intree = !!_g.stage;\n _g = _g.parent;\n }\n if (!intree) {\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.removeChild(graphic);\n }\n return true;\n }\n if (baseGraphic) {\n this.processing = true;\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n context.setTransformFromMatrix(baseGraphic.parent.globalTransMatrix, true);\n // context.fillRect(0, 0, 100, 100);\n // 设置context的transform到上一个节点\n baseGraphic.isContainer\n ? drawContribution.renderGroup(baseGraphic as IGroup, drawContext, baseGraphic.parent.globalTransMatrix)\n : drawContribution.renderItem(baseGraphic, drawContext);\n\n context.highPerformanceRestore();\n this.processing = false;\n\n return true;\n }\n return false;\n }\n getShadowRoot(interactiveLayer: ILayer) {\n // 获取绑定影子节点的group\n let group = interactiveLayer.getElementById('_interactive_group') as IGroup;\n if (!group) {\n group = graphicCreator.CreateGraphic('group', {});\n group.id = '_interactive_group';\n interactiveLayer.add(group);\n }\n return group.shadowRoot ?? group.attachShadow();\n }\n}\n\n/**\n * 3d拦截器,用于渲染3d视角\n */\n// @injectable()\nexport class Canvas3DDrawItemInterceptor implements IDrawItemInterceptorContribution {\n // canvas?: ICanvas;\n order: number = 1;\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ) {\n if (!graphic.in3dMode || drawContext.in3dInterceptor) {\n return false;\n }\n\n drawContext.in3dInterceptor = true;\n const { context, stage } = renderService.drawParams;\n const canvas = context.canvas;\n\n // 使用3d模式渲染\n context.save();\n this.initCanvasCtx(context);\n context.camera = stage.camera;\n\n // 将三维矩阵换成四维矩阵\n const m = context.currentMatrix;\n m.a /= context.dpr;\n m.b /= context.dpr;\n m.c /= context.dpr;\n m.d /= context.dpr;\n m.e /= context.dpr;\n m.f /= context.dpr;\n const matrix = mat4Allocate.allocate();\n mat3Tomat4(matrix, m);\n const lastModelMatrix = context.modelMatrix;\n if (lastModelMatrix) {\n if (matrix) {\n const m = mat4Allocate.allocate();\n context.modelMatrix = multiplyMat4Mat4(m, lastModelMatrix, matrix);\n }\n } else {\n context.modelMatrix = matrix;\n }\n context.setTransform(1, 0, 0, 1, 0, 0, true);\n\n // 设置context的transform到上一个节点\n if (graphic.isContainer) {\n draw3dItem(\n context,\n graphic,\n (isPie: boolean, is3d: boolean) => {\n return drawContribution.renderGroup(\n graphic as IGroup,\n drawContext,\n graphic.parent.globalTransMatrix,\n !isPie && is3d\n );\n },\n drawContext\n );\n } else {\n drawContribution.renderItem(graphic, drawContext);\n }\n context.camera = null;\n context.restore();\n\n if (context.modelMatrix !== lastModelMatrix) {\n mat4Allocate.free(context.modelMatrix);\n }\n context.modelMatrix = lastModelMatrix;\n\n drawContext.in3dInterceptor = false;\n return true;\n }\n\n initCanvasCtx(context: IContext2d) {\n context.setTransformForCurrent();\n }\n}\n"]}
|
|
@@ -8,7 +8,7 @@ export declare class DefaultCanvasTextRender extends BaseRender<IText> implement
|
|
|
8
8
|
constructor(textRenderContribitions: IContributionProvider<ITextRenderContribution>);
|
|
9
9
|
drawShape(text: IText, context: IContext2d, x: number, y: number, drawContext: IDrawContext, params?: IGraphicRenderDrawParams, fillCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean): void;
|
|
10
10
|
draw(text: IText, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams): void;
|
|
11
|
-
drawUnderLine(underline: number, lineThrough: number, text: IText,
|
|
11
|
+
drawUnderLine(underline: number, lineThrough: number, text: IText, anchorX: number, anchorY: number, offsetUnderLineY: number, offsetThroughLineY: number, z: number, textAttribute: Required<ITextGraphicAttribute>, context: IContext2d, multiOption?: {
|
|
12
12
|
width: number;
|
|
13
13
|
}): void;
|
|
14
14
|
}
|
|
@@ -26,14 +26,8 @@ let DefaultCanvasTextRender = class extends base_render_1.BaseRender {
|
|
|
26
26
|
}
|
|
27
27
|
drawShape(text, context, x, y, drawContext, params, fillCb, strokeCb) {
|
|
28
28
|
var _a, _b, _c;
|
|
29
|
-
const textAttribute = (0, theme_1.getTheme)(text, null == params ? void 0 : params.theme).text, {text: str, underline: underline = textAttribute.underline, lineThrough: lineThrough = textAttribute.lineThrough, keepDirIn3d: keepDirIn3d = textAttribute.keepDirIn3d, direction: direction = textAttribute.direction, fontSize: fontSize = textAttribute.fontSize, verticalMode: verticalMode = textAttribute.verticalMode, x: originX = textAttribute.x, y: originY = textAttribute.y} = text.attribute
|
|
30
|
-
|
|
31
|
-
if (!verticalMode && "vertical" === direction) {
|
|
32
|
-
const t = textAlign;
|
|
33
|
-
textAlign = null !== (_a = text.getBaselineMapAlign()[textBaseline]) && void 0 !== _a ? _a : "left",
|
|
34
|
-
textBaseline = null !== (_b = text.getAlignMapBaseline()[t]) && void 0 !== _b ? _b : "top";
|
|
35
|
-
}
|
|
36
|
-
const lineHeight = null !== (_c = (0, utils_1.calculateLineHeight)(text.attribute.lineHeight, fontSize)) && void 0 !== _c ? _c : fontSize, data = this.valid(text, textAttribute, fillCb, strokeCb);
|
|
29
|
+
const textAttribute = (0, theme_1.getTheme)(text, null == params ? void 0 : params.theme).text, {text: str, underline: underline = textAttribute.underline, lineThrough: lineThrough = textAttribute.lineThrough, keepDirIn3d: keepDirIn3d = textAttribute.keepDirIn3d, direction: direction = textAttribute.direction, fontSize: fontSize = textAttribute.fontSize, verticalMode: verticalMode = textAttribute.verticalMode, x: originX = textAttribute.x, y: originY = textAttribute.y} = text.attribute, lineHeight = null !== (_a = (0,
|
|
30
|
+
utils_1.calculateLineHeight)(text.attribute.lineHeight, fontSize)) && void 0 !== _a ? _a : fontSize, data = this.valid(text, textAttribute, fillCb, strokeCb);
|
|
37
31
|
if (!data) return;
|
|
38
32
|
const {fVisible: fVisible, sVisible: sVisible, doFill: doFill, doStroke: doStroke} = data, transform3dMatrixToContextMatrix = !keepDirIn3d, z = this.z || 0;
|
|
39
33
|
context.beginPath(), context.setShadowBlendStyle && context.setShadowBlendStyle(text, text.attribute, textAttribute),
|
|
@@ -50,10 +44,10 @@ let DefaultCanvasTextRender = class extends base_render_1.BaseRender {
|
|
|
50
44
|
}
|
|
51
45
|
doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute),
|
|
52
46
|
context.strokeText(t, _x, _y, z))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute),
|
|
53
|
-
context.fillText(t, _x, _y, z),
|
|
54
|
-
|
|
47
|
+
context.fillText(t, _x, _y, z))), direction && (context.highPerformanceRestore(),
|
|
48
|
+
context.setTransformForCurrent());
|
|
55
49
|
};
|
|
56
|
-
if (
|
|
50
|
+
if (context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z),
|
|
57
51
|
"horizontal" === direction) {
|
|
58
52
|
const {multilineLayout: multilineLayout} = text;
|
|
59
53
|
if (!multilineLayout) return void context.highPerformanceRestore();
|
|
@@ -64,12 +58,17 @@ let DefaultCanvasTextRender = class extends base_render_1.BaseRender {
|
|
|
64
58
|
})))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute),
|
|
65
59
|
multilineLayout.lines.forEach((line => {
|
|
66
60
|
context.fillText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z),
|
|
67
|
-
this.drawUnderLine(underline, lineThrough, text, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y -
|
|
68
|
-
text_1.textDrawOffsetY)("bottom", fontSize) - .05 * fontSize, z, textAttribute, context, {
|
|
61
|
+
this.drawUnderLine(underline, lineThrough, text, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, line.descent, (line.descent - line.ascent) / 2, z, textAttribute, context, {
|
|
69
62
|
width: line.width
|
|
70
63
|
});
|
|
71
64
|
}))));
|
|
72
65
|
} else {
|
|
66
|
+
let {textAlign: textAlign = textAttribute.textAlign, textBaseline: textBaseline = textAttribute.textBaseline} = text.attribute;
|
|
67
|
+
if (!verticalMode) {
|
|
68
|
+
const t = textAlign;
|
|
69
|
+
textAlign = null !== (_b = text.getBaselineMapAlign()[textBaseline]) && void 0 !== _b ? _b : "left",
|
|
70
|
+
textBaseline = null !== (_c = text.getAlignMapBaseline()[t]) && void 0 !== _c ? _c : "top";
|
|
71
|
+
}
|
|
73
72
|
text.tryUpdateAABBBounds();
|
|
74
73
|
const cache = text.cache, {verticalList: verticalList} = cache;
|
|
75
74
|
context.textAlign = "left", context.textBaseline = "top";
|
|
@@ -92,28 +91,6 @@ let DefaultCanvasTextRender = class extends base_render_1.BaseRender {
|
|
|
92
91
|
currentOffsetY += width;
|
|
93
92
|
}));
|
|
94
93
|
}));
|
|
95
|
-
} else if ("horizontal" === direction) {
|
|
96
|
-
context.setTextStyle(text.attribute, textAttribute, z);
|
|
97
|
-
const t = text.clipedText;
|
|
98
|
-
let dy = 0;
|
|
99
|
-
lineHeight !== fontSize && ("top" === textBaseline ? dy = (lineHeight - fontSize) / 2 : "middle" === textBaseline || "bottom" === textBaseline && (dy = -(lineHeight - fontSize) / 2)),
|
|
100
|
-
drawText(t, 0, dy, 0);
|
|
101
|
-
} else {
|
|
102
|
-
text.tryUpdateAABBBounds();
|
|
103
|
-
const cache = text.cache;
|
|
104
|
-
if (cache) {
|
|
105
|
-
context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z);
|
|
106
|
-
const {verticalList: verticalList} = cache;
|
|
107
|
-
let offsetY = 0;
|
|
108
|
-
const totalW = verticalList[0].reduce(((a, b) => a + (b.width || 0)), 0);
|
|
109
|
-
let offsetX = 0;
|
|
110
|
-
"bottom" === textBaseline ? offsetX = -lineHeight : "middle" === textBaseline && (offsetX = -lineHeight / 2),
|
|
111
|
-
"center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW),
|
|
112
|
-
context.textAlign = "left", context.textBaseline = "top", verticalList[0].forEach((item => {
|
|
113
|
-
const {text: text, width: width, direction: direction} = item;
|
|
114
|
-
drawText(text, offsetX, offsetY, direction), offsetY += width;
|
|
115
|
-
}));
|
|
116
|
-
}
|
|
117
94
|
}
|
|
118
95
|
transform3dMatrixToContextMatrix && this.restoreTransformUseContext2d(text, textAttribute, z, context),
|
|
119
96
|
this.afterRenderStep(text, context, x, y, doFill, doStroke, fVisible, sVisible, textAttribute, drawContext, fillCb, strokeCb);
|
|
@@ -122,28 +99,29 @@ let DefaultCanvasTextRender = class extends base_render_1.BaseRender {
|
|
|
122
99
|
const textAttribute = (0, theme_1.getTheme)(text, null == params ? void 0 : params.theme).text, {keepDirIn3d: keepDirIn3d = textAttribute.keepDirIn3d} = text.attribute, computed3dMatrix = !keepDirIn3d;
|
|
123
100
|
this._draw(text, textAttribute, computed3dMatrix, drawContext, params);
|
|
124
101
|
}
|
|
125
|
-
drawUnderLine(underline, lineThrough, text,
|
|
102
|
+
drawUnderLine(underline, lineThrough, text, anchorX, anchorY, offsetUnderLineY, offsetThroughLineY, z, textAttribute, context, multiOption) {
|
|
126
103
|
if (lineThrough + underline <= 0) return;
|
|
127
|
-
const {textAlign: textAlign = textAttribute.textAlign,
|
|
104
|
+
const {textAlign: textAlign = textAttribute.textAlign, fill: fill = textAttribute.fill, opacity: opacity = textAttribute.opacity, underlineOffset: underlineOffset = textAttribute.underlineOffset, underlineDash: underlineDash = textAttribute.underlineDash, fillOpacity: fillOpacity = textAttribute.fillOpacity} = text.attribute, isMulti = !(0,
|
|
128
105
|
vutils_1.isNil)(multiOption), w = isMulti ? multiOption.width : text.clipedWidth, offsetX = isMulti ? 0 : (0,
|
|
129
|
-
text_1.textDrawOffsetX)(textAlign, w),
|
|
106
|
+
text_1.textDrawOffsetX)(textAlign, w), attribute = {
|
|
130
107
|
lineWidth: 0,
|
|
131
108
|
stroke: fill,
|
|
132
109
|
opacity: opacity,
|
|
133
110
|
strokeOpacity: fillOpacity
|
|
134
111
|
};
|
|
135
|
-
let deltaY = isMulti ? -3 : 0;
|
|
136
112
|
if (underline) {
|
|
137
|
-
attribute.lineWidth = underline, context.setStrokeStyle(text, attribute,
|
|
113
|
+
attribute.lineWidth = underline, context.setStrokeStyle(text, attribute, anchorX, anchorY, textAttribute),
|
|
138
114
|
underlineDash && context.setLineDash(underlineDash), context.beginPath();
|
|
139
|
-
const dy =
|
|
140
|
-
context.moveTo(
|
|
115
|
+
const dy = anchorY + offsetUnderLineY + underlineOffset;
|
|
116
|
+
context.moveTo(anchorX + offsetX, dy, z), context.lineTo(anchorX + offsetX + w, dy, z),
|
|
117
|
+
context.stroke();
|
|
141
118
|
}
|
|
142
|
-
if (
|
|
143
|
-
attribute.lineWidth = lineThrough, context.setStrokeStyle(text, attribute,
|
|
119
|
+
if (lineThrough) {
|
|
120
|
+
attribute.lineWidth = lineThrough, context.setStrokeStyle(text, attribute, anchorX, anchorY, textAttribute),
|
|
144
121
|
context.beginPath();
|
|
145
|
-
const dy =
|
|
146
|
-
context.moveTo(
|
|
122
|
+
const dy = anchorY + offsetThroughLineY;
|
|
123
|
+
context.moveTo(anchorX + offsetX, dy, z), context.lineTo(anchorX + offsetX + w, dy, z),
|
|
124
|
+
context.stroke();
|
|
147
125
|
}
|
|
148
126
|
}
|
|
149
127
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/render/text-render.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mEAA2E;AAC3E,kDAAkD;AAClD,0DAA8D;AAa9D,+CAA2F;AAE3F,+CAA2C;AAC3C,iFAA6E;AAC7E,yDAAmE;AACnE,wEAAoE;AACpE,6CAA8C;AAC9C,iDAA4D;AAC5D,uFAAmG;AAG5F,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,wBAAiB;IAI5D,YAGqB,uBAAuE;QAE1F,KAAK,EAAE,CAAC;QAFW,4BAAuB,GAAvB,uBAAuB,CAAgD;QAL5F,eAAU,GAAW,4BAAgB,CAAC;QAQpC,IAAI,CAAC,oBAAoB,GAAG,CAAC,kEAA8C,CAAC,CAAC;QAC7E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O,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;YACvC,OAAO,CAAC,MAAM,EAAE,CAAC;SAClB;IACH,CAAC;CACF,CAAA;AArVY,uBAAuB;IADnC,IAAA,2BAAU,GAAE;IAMR,WAAA,IAAA,uBAAM,EAAC,4CAAoB,CAAC,CAAA;IAC5B,WAAA,IAAA,sBAAK,EAAC,kCAAsB,CAAC,CAAA;;GANrB,uBAAuB,CAqVnC;AArVY,0DAAuB","file":"text-render.js","sourcesContent":["import { inject, injectable, named } from '../../../common/inversify-lite';\nimport { getTheme } from '../../../graphic/theme';\nimport { TEXT_NUMBER_TYPE } from '../../../graphic/constants';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n IThemeAttribute,\n IDrawContext,\n IRenderService,\n IGraphicRender,\n IGraphicRenderDrawParams,\n ITextRenderContribution,\n IContributionProvider\n} from '../../../interface';\nimport { textDrawOffsetX, textDrawOffsetY, textLayoutOffsetY } from '../../../common/text';\nimport type { IText, ITextGraphicAttribute } from '../../../interface/graphic/text';\nimport { BaseRender } from './base-render';\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { TextRenderContribution } from './contributions/constants';\nimport { matrixAllocate } from '../../../allocator/matrix-allocate';\nimport { isNil, max } from '@visactor/vutils';\nimport { calculateLineHeight } from '../../../common/utils';\nimport { defaultTextBackgroundRenderContribution } from './contributions/text-contribution-render';\n\n@injectable()\nexport class DefaultCanvasTextRender extends BaseRender<IText> implements IGraphicRender {\n type: 'text';\n numberType: number = TEXT_NUMBER_TYPE;\n\n constructor(\n @inject(ContributionProvider)\n @named(TextRenderContribution)\n protected readonly textRenderContribitions: IContributionProvider<ITextRenderContribution>\n ) {\n super();\n this.builtinContributions = [defaultTextBackgroundRenderContribution as any];\n this.init(textRenderContribitions);\n }\n\n drawShape(\n text: IText,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n const textAttribute = getTheme(text, params?.theme).text;\n const {\n text: str,\n underline = textAttribute.underline,\n lineThrough = textAttribute.lineThrough,\n keepDirIn3d = textAttribute.keepDirIn3d,\n direction = textAttribute.direction,\n // lineHeight = textAttribute.lineHeight,\n // whiteSpace = textAttribute.whiteSpace,\n fontSize = textAttribute.fontSize,\n verticalMode = textAttribute.verticalMode,\n x: originX = textAttribute.x,\n y: originY = textAttribute.y\n } = text.attribute;\n\n let { textAlign = textAttribute.textAlign, textBaseline = textAttribute.textBaseline } = text.attribute;\n if (!verticalMode && direction === 'vertical') {\n const t = textAlign;\n textAlign = text.getBaselineMapAlign()[textBaseline] ?? ('left' as any);\n textBaseline = text.getAlignMapBaseline()[t] ?? ('top' as any);\n }\n const lineHeight = calculateLineHeight(text.attribute.lineHeight, fontSize) ?? fontSize;\n\n const data = this.valid(text, textAttribute, fillCb, strokeCb);\n if (!data) {\n return;\n }\n const { fVisible, sVisible, doFill, doStroke } = data;\n\n // 文字如果需要变换,那就需要将3dmatrix转成context的2dmatrix\n const transform3dMatrixToContextMatrix = !keepDirIn3d;\n\n const z = this.z || 0;\n\n context.beginPath();\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(text, text.attribute, textAttribute);\n\n this.beforeRenderStep(\n text,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n textAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n\n transform3dMatrixToContextMatrix && this.transformUseContext2d(text, textAttribute, z, context);\n\n const drawText = (t: string, offsetX: number, offsetY: number, direction: number) => {\n let _x = x + offsetX;\n const _y = y + offsetY;\n if (direction) {\n context.highPerformanceSave();\n _x += fontSize;\n const matrix = matrixAllocate.allocate(1, 0, 0, 1, 0, 0);\n // matrix.translate(fontSize, 0);\n matrix.rotateByCenter(Math.PI / 2, _x, _y);\n context.transformFromMatrix(matrix, true);\n matrixAllocate.free(matrix);\n }\n\n if (doStroke) {\n if (strokeCb) {\n strokeCb(context, text.attribute, textAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute);\n context.strokeText(t, _x, _y, z);\n }\n }\n if (doFill) {\n if (fillCb) {\n fillCb(context, text.attribute, textAttribute);\n } else if (fVisible) {\n context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute);\n context.fillText(t, _x, _y, z);\n this.drawUnderLine(underline, lineThrough, text, _x, _y, z, textAttribute, context);\n }\n }\n\n if (direction) {\n context.highPerformanceRestore();\n context.setTransformForCurrent();\n }\n };\n if (text.isMultiLine) {\n context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z);\n if (direction === 'horizontal') {\n const { multilineLayout } = text;\n if (!multilineLayout) {\n context.highPerformanceRestore();\n return;\n } // 如果不存在的话,需要render层自行布局\n const { xOffset, yOffset } = multilineLayout.bbox;\n if (doStroke) {\n if (strokeCb) {\n strokeCb(context, text.attribute, textAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute);\n multilineLayout.lines.forEach(line => {\n context.strokeText(\n line.str,\n (line.leftOffset || 0) + xOffset + x,\n (line.topOffset || 0) + yOffset + y,\n z\n );\n });\n }\n }\n if (doFill) {\n if (fillCb) {\n fillCb(context, text.attribute, textAttribute);\n } else if (fVisible) {\n context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute);\n multilineLayout.lines.forEach(line => {\n context.fillText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);\n this.drawUnderLine(\n underline,\n lineThrough,\n text,\n (line.leftOffset || 0) + xOffset + x,\n // y是基于alphabetic对齐的,这里-0.05是为了和不换行的文字保持效果一致\n (line.topOffset || 0) + yOffset + y - textDrawOffsetY('bottom', fontSize) - 0.05 * fontSize,\n z,\n textAttribute,\n context,\n {\n width: line.width\n }\n );\n });\n }\n }\n } else {\n text.tryUpdateAABBBounds(); // 更新cache\n const cache = text.cache;\n const { verticalList } = cache;\n context.textAlign = 'left';\n context.textBaseline = 'top';\n const totalHeight = lineHeight * verticalList.length;\n let totalW = 0;\n verticalList.forEach(verticalData => {\n const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);\n totalW = max(_w, totalW);\n });\n let offsetY = 0;\n let offsetX = 0;\n if (textBaseline === 'bottom') {\n offsetX = -totalHeight;\n } else if (textBaseline === 'middle') {\n offsetX = -totalHeight / 2;\n }\n if (textAlign === 'center') {\n offsetY -= totalW / 2;\n } else if (textAlign === 'right') {\n offsetY -= totalW;\n }\n verticalList.forEach((verticalData, i) => {\n const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0);\n const dw = totalW - currentW;\n let currentOffsetY = offsetY;\n if (textAlign === 'center') {\n currentOffsetY += dw / 2;\n } else if (textAlign === 'right') {\n currentOffsetY += dw;\n }\n verticalData.forEach(item => {\n const { text, width, direction } = item;\n drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction);\n currentOffsetY += width;\n });\n });\n }\n } else {\n if (direction === 'horizontal') {\n context.setTextStyle(text.attribute, textAttribute, z);\n const t = text.clipedText as string;\n let dy = 0;\n if (lineHeight !== fontSize) {\n if (textBaseline === 'top') {\n dy = (lineHeight - fontSize) / 2;\n } else if (textBaseline === 'middle') {\n // middle do nothing\n } else if (textBaseline === 'bottom') {\n dy = -(lineHeight - fontSize) / 2;\n } else {\n // alphabetic do nothing\n // dy = (lineHeight - fontSize) / 2 - fontSize * 0.79;\n }\n }\n drawText(t, 0, dy, 0);\n } else {\n text.tryUpdateAABBBounds(); // 更新cache\n const cache = text.cache;\n if (cache) {\n context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z);\n const { verticalList } = cache;\n let offsetY = 0;\n const totalW = verticalList[0].reduce((a, b) => a + (b.width || 0), 0);\n let offsetX = 0;\n if (textBaseline === 'bottom') {\n offsetX = -lineHeight;\n } else if (textBaseline === 'middle') {\n offsetX = -lineHeight / 2;\n }\n if (textAlign === 'center') {\n offsetY -= totalW / 2;\n } else if (textAlign === 'right') {\n offsetY -= totalW;\n }\n context.textAlign = 'left';\n context.textBaseline = 'top';\n verticalList[0].forEach(item => {\n const { text, width, direction } = item;\n drawText(text, offsetX, offsetY, direction);\n offsetY += width;\n });\n }\n }\n }\n transform3dMatrixToContextMatrix && this.restoreTransformUseContext2d(text, textAttribute, z, context);\n\n this.afterRenderStep(\n text,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n textAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n\n draw(text: IText, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const textAttribute = getTheme(text, params?.theme).text;\n const { keepDirIn3d = textAttribute.keepDirIn3d } = text.attribute;\n // 文字如果需要变换,那就一定要计算3d矩阵\n const computed3dMatrix = !keepDirIn3d;\n this._draw(text, textAttribute, computed3dMatrix, drawContext, params);\n }\n\n drawUnderLine(\n underline: number,\n lineThrough: number,\n text: IText,\n x: number,\n y: number,\n z: number,\n textAttribute: Required<ITextGraphicAttribute>,\n context: IContext2d,\n multiOption?: {\n width: number;\n }\n ) {\n if (lineThrough + underline <= 0) {\n return;\n }\n\n const {\n textAlign = textAttribute.textAlign,\n textBaseline = textAttribute.textBaseline,\n fontSize = textAttribute.fontSize,\n fill = textAttribute.fill,\n opacity = textAttribute.opacity,\n underlineOffset = textAttribute.underlineOffset,\n underlineDash = textAttribute.underlineDash,\n fillOpacity = textAttribute.fillOpacity\n } = text.attribute;\n const isMulti = !isNil(multiOption);\n const w = isMulti ? multiOption!.width : text.clipedWidth;\n const offsetX = isMulti ? 0 : textDrawOffsetX(textAlign, w);\n const offsetY = textLayoutOffsetY(isMulti ? 'alphabetic' : textBaseline, fontSize, fontSize);\n const attribute = { lineWidth: 0, stroke: fill, opacity, strokeOpacity: fillOpacity };\n let deltaY = isMulti ? -3 : 0;\n if (underline) {\n attribute.lineWidth = underline;\n context.setStrokeStyle(text, attribute, x, y, textAttribute);\n underlineDash && context.setLineDash(underlineDash);\n context.beginPath();\n const dy = y + offsetY + fontSize + underlineOffset + deltaY;\n context.moveTo(x + offsetX, dy, z);\n context.lineTo(x + offsetX + w, dy, z);\n context.stroke();\n }\n if (isMulti) {\n deltaY = -1;\n }\n if (lineThrough) {\n attribute.lineWidth = lineThrough;\n context.setStrokeStyle(text, attribute, x, y, textAttribute);\n context.beginPath();\n const dy = y + offsetY + fontSize / 2 + deltaY;\n context.moveTo(x + offsetX, dy, z);\n context.lineTo(x + offsetX + w, dy, z);\n context.stroke();\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/render/contributions/render/text-render.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mEAA2E;AAC3E,kDAAkD;AAClD,0DAA8D;AAa9D,+CAA2F;AAE3F,+CAA2C;AAC3C,iFAA6E;AAC7E,yDAAmE;AACnE,wEAAoE;AACpE,6CAA8C;AAC9C,iDAA4D;AAC5D,uFAAmG;AAG5F,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,wBAAiB;IAI5D,YAGqB,uBAAuE;QAE1F,KAAK,EAAE,CAAC;QAFW,4BAAuB,GAAvB,uBAAuB,CAAgD;QAL5F,eAAU,GAAW,4BAAgB,CAAC;QAQpC,IAAI,CAAC,oBAAoB,GAAG,CAAC,kEAA8C,CAAC,CAAC;QAC7E,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;IACrC,CAAC;IAED,SAAS,CACP,IAAW,EACX,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,WAAyB,EACzB,MAAiC,EACjC,MAIY,EACZ,QAIY;;QAEZ,MAAM,aAAa,GAAG,IAAA,gBAAQ,EAAC,IAAI,EAAE,MAAM,aAAN,MAA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AA;;GANrB,uBAAuB,CAsSnC;AAtSY,0DAAuB","file":"text-render.js","sourcesContent":["import { inject, injectable, named } from '../../../common/inversify-lite';\nimport { getTheme } from '../../../graphic/theme';\nimport { TEXT_NUMBER_TYPE } from '../../../graphic/constants';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n IThemeAttribute,\n IDrawContext,\n IRenderService,\n IGraphicRender,\n IGraphicRenderDrawParams,\n ITextRenderContribution,\n IContributionProvider\n} from '../../../interface';\nimport { textDrawOffsetX, textDrawOffsetY, textLayoutOffsetY } from '../../../common/text';\nimport type { IText, ITextGraphicAttribute } from '../../../interface/graphic/text';\nimport { BaseRender } from './base-render';\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { TextRenderContribution } from './contributions/constants';\nimport { matrixAllocate } from '../../../allocator/matrix-allocate';\nimport { isNil, max } from '@visactor/vutils';\nimport { calculateLineHeight } from '../../../common/utils';\nimport { defaultTextBackgroundRenderContribution } from './contributions/text-contribution-render';\n\n@injectable()\nexport class DefaultCanvasTextRender extends BaseRender<IText> implements IGraphicRender {\n type: 'text';\n numberType: number = TEXT_NUMBER_TYPE;\n\n constructor(\n @inject(ContributionProvider)\n @named(TextRenderContribution)\n protected readonly textRenderContribitions: IContributionProvider<ITextRenderContribution>\n ) {\n super();\n this.builtinContributions = [defaultTextBackgroundRenderContribution as any];\n this.init(textRenderContribitions);\n }\n\n drawShape(\n text: IText,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n const textAttribute = getTheme(text, params?.theme).text;\n const {\n text: str,\n underline = textAttribute.underline,\n lineThrough = textAttribute.lineThrough,\n keepDirIn3d = textAttribute.keepDirIn3d,\n direction = textAttribute.direction,\n // lineHeight = textAttribute.lineHeight,\n // whiteSpace = textAttribute.whiteSpace,\n fontSize = textAttribute.fontSize,\n verticalMode = textAttribute.verticalMode,\n x: originX = textAttribute.x,\n y: originY = textAttribute.y\n } = text.attribute;\n\n const lineHeight = calculateLineHeight(text.attribute.lineHeight, fontSize) ?? fontSize;\n\n const data = this.valid(text, textAttribute, fillCb, strokeCb);\n if (!data) {\n return;\n }\n const { fVisible, sVisible, doFill, doStroke } = data;\n\n // 文字如果需要变换,那就需要将3dmatrix转成context的2dmatrix\n const transform3dMatrixToContextMatrix = !keepDirIn3d;\n\n const z = this.z || 0;\n\n context.beginPath();\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(text, text.attribute, textAttribute);\n\n this.beforeRenderStep(\n text,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n textAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n\n transform3dMatrixToContextMatrix && this.transformUseContext2d(text, textAttribute, z, context);\n\n const drawText = (t: string, offsetX: number, offsetY: number, direction: number) => {\n let _x = x + offsetX;\n const _y = y + offsetY;\n if (direction) {\n context.highPerformanceSave();\n _x += fontSize;\n const matrix = matrixAllocate.allocate(1, 0, 0, 1, 0, 0);\n // matrix.translate(fontSize, 0);\n matrix.rotateByCenter(Math.PI / 2, _x, _y);\n context.transformFromMatrix(matrix, true);\n matrixAllocate.free(matrix);\n }\n\n if (doStroke) {\n if (strokeCb) {\n strokeCb(context, text.attribute, textAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute);\n context.strokeText(t, _x, _y, z);\n }\n }\n if (doFill) {\n if (fillCb) {\n fillCb(context, text.attribute, textAttribute);\n } else if (fVisible) {\n context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute);\n context.fillText(t, _x, _y, z);\n // 垂直布局的情况下不支持下划线和中划线\n // this.drawUnderLine(underline, lineThrough, text, _x, _y, 0, 0, z, textAttribute, context);\n }\n }\n\n if (direction) {\n context.highPerformanceRestore();\n context.setTransformForCurrent();\n }\n };\n context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z);\n if (direction === 'horizontal') {\n const { multilineLayout } = text;\n if (!multilineLayout) {\n context.highPerformanceRestore();\n return;\n } // 如果不存在的话,需要render层自行布局\n const { xOffset, yOffset } = multilineLayout.bbox;\n if (doStroke) {\n if (strokeCb) {\n strokeCb(context, text.attribute, textAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute);\n multilineLayout.lines.forEach(line => {\n context.strokeText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);\n });\n }\n }\n if (doFill) {\n if (fillCb) {\n fillCb(context, text.attribute, textAttribute);\n } else if (fVisible) {\n context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute);\n multilineLayout.lines.forEach(line => {\n context.fillText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);\n this.drawUnderLine(\n underline,\n lineThrough,\n text,\n (line.leftOffset || 0) + xOffset + x,\n (line.topOffset || 0) + yOffset + y,\n line.descent,\n (line.descent - line.ascent) / 2,\n z,\n textAttribute,\n context,\n {\n width: line.width\n }\n );\n });\n }\n }\n } else {\n let { textAlign = textAttribute.textAlign, textBaseline = textAttribute.textBaseline } = text.attribute;\n if (!verticalMode) {\n const t = textAlign;\n textAlign = text.getBaselineMapAlign()[textBaseline] ?? ('left' as any);\n textBaseline = text.getAlignMapBaseline()[t] ?? ('top' as any);\n }\n text.tryUpdateAABBBounds(); // 更新cache\n const cache = text.cache;\n const { verticalList } = cache;\n context.textAlign = 'left';\n context.textBaseline = 'top';\n const totalHeight = lineHeight * verticalList.length;\n let totalW = 0;\n verticalList.forEach(verticalData => {\n const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);\n totalW = max(_w, totalW);\n });\n let offsetY = 0;\n let offsetX = 0;\n if (textBaseline === 'bottom') {\n offsetX = -totalHeight;\n } else if (textBaseline === 'middle') {\n offsetX = -totalHeight / 2;\n }\n if (textAlign === 'center') {\n offsetY -= totalW / 2;\n } else if (textAlign === 'right') {\n offsetY -= totalW;\n }\n verticalList.forEach((verticalData, i) => {\n const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0);\n const dw = totalW - currentW;\n let currentOffsetY = offsetY;\n if (textAlign === 'center') {\n currentOffsetY += dw / 2;\n } else if (textAlign === 'right') {\n currentOffsetY += dw;\n }\n verticalData.forEach(item => {\n const { text, width, direction } = item;\n drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction);\n currentOffsetY += width;\n });\n });\n }\n transform3dMatrixToContextMatrix && this.restoreTransformUseContext2d(text, textAttribute, z, context);\n\n this.afterRenderStep(\n text,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n textAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n\n draw(text: IText, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const textAttribute = getTheme(text, params?.theme).text;\n const { keepDirIn3d = textAttribute.keepDirIn3d } = text.attribute;\n // 文字如果需要变换,那就一定要计算3d矩阵\n const computed3dMatrix = !keepDirIn3d;\n this._draw(text, textAttribute, computed3dMatrix, drawContext, params);\n }\n\n drawUnderLine(\n underline: number,\n lineThrough: number,\n text: IText,\n anchorX: number,\n anchorY: number,\n offsetUnderLineY: number,\n offsetThroughLineY: number,\n z: number,\n textAttribute: Required<ITextGraphicAttribute>,\n context: IContext2d,\n multiOption?: {\n width: number;\n }\n ) {\n if (lineThrough + underline <= 0) {\n return;\n }\n\n const {\n textAlign = textAttribute.textAlign,\n // textBaseline = textAttribute.textBaseline,\n // fontSize = textAttribute.fontSize,\n fill = textAttribute.fill,\n opacity = textAttribute.opacity,\n underlineOffset = textAttribute.underlineOffset,\n underlineDash = textAttribute.underlineDash,\n fillOpacity = textAttribute.fillOpacity\n } = text.attribute;\n const isMulti = !isNil(multiOption);\n const w = isMulti ? multiOption!.width : text.clipedWidth;\n const offsetX = isMulti ? 0 : textDrawOffsetX(textAlign, w);\n // const offsetY = textLayoutOffsetY(isMulti ? 'alphabetic' : textBaseline, fontSize, fontSize);\n const attribute = { lineWidth: 0, stroke: fill, opacity, strokeOpacity: fillOpacity };\n // let deltaY = isMulti ? -3 : 0;\n if (underline) {\n attribute.lineWidth = underline;\n context.setStrokeStyle(text, attribute, anchorX, anchorY, textAttribute);\n underlineDash && context.setLineDash(underlineDash);\n context.beginPath();\n // const dy = y + offsetY + fontSize + underlineOffset + deltaY;\n const dy = anchorY + offsetUnderLineY + underlineOffset;\n context.moveTo(anchorX + offsetX, dy, z);\n context.lineTo(anchorX + offsetX + w, dy, z);\n context.stroke();\n }\n // if (isMulti) {\n // deltaY = -1;\n // }\n if (lineThrough) {\n attribute.lineWidth = lineThrough;\n context.setStrokeStyle(text, attribute, anchorX, anchorY, textAttribute);\n context.beginPath();\n // const dy = y + offsetY + fontSize / 2 + deltaY;\n const dy = anchorY + offsetThroughLineY;\n context.moveTo(anchorX + offsetX, dy, z);\n context.lineTo(anchorX + offsetX + w, dy, z);\n context.stroke();\n }\n }\n}\n"]}
|