@visactor/vrender-core 1.1.11-alpha.1 → 1.1.11
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/common/area-cache.d.ts +11 -0
- package/cjs/common/area-cache.js +115 -0
- package/cjs/common/area-cache.js.map +1 -0
- package/cjs/common/bezier-utils.js +1 -2
- package/cjs/common/bounds-context.js +2 -1
- package/cjs/common/path-svg.js +1 -2
- package/cjs/common/performance-raf.js +2 -1
- package/cjs/common/render-curve.d.ts +3 -0
- package/cjs/common/render-curve.js +16 -17
- package/cjs/common/render-curve.js.map +1 -1
- package/cjs/common/seg-context.js +1 -1
- package/cjs/graphic/area.js +3 -3
- package/cjs/graphic/area.js.map +1 -1
- package/cjs/graphic/line.js +4 -4
- package/cjs/graphic/line.js.map +1 -1
- package/cjs/render/contributions/render/area-render.js +18 -92
- package/cjs/render/contributions/render/area-render.js.map +1 -1
- package/cjs/render/contributions/render/incremental-area-render.d.ts +5 -1
- package/cjs/render/contributions/render/incremental-area-render.js +29 -7
- package/cjs/render/contributions/render/incremental-area-render.js.map +1 -1
- package/dist/index.es.js +213 -149
- package/es/common/area-cache.d.ts +11 -0
- package/es/common/area-cache.js +113 -0
- package/es/common/area-cache.js.map +1 -0
- package/es/common/bezier-utils.js +1 -2
- package/es/common/bounds-context.js +2 -1
- package/es/common/path-svg.js +1 -2
- package/es/common/performance-raf.js +2 -1
- package/es/common/render-curve.d.ts +3 -0
- package/es/common/render-curve.js +15 -16
- package/es/common/render-curve.js.map +1 -1
- package/es/common/seg-context.js +1 -1
- package/es/graphic/area.js +3 -3
- package/es/graphic/area.js.map +1 -1
- package/es/graphic/line.js +4 -4
- package/es/graphic/line.js.map +1 -1
- package/es/render/contributions/render/area-render.js +18 -92
- package/es/render/contributions/render/area-render.js.map +1 -1
- package/es/render/contributions/render/incremental-area-render.d.ts +5 -1
- package/es/render/contributions/render/incremental-area-render.js +28 -6
- package/es/render/contributions/render/incremental-area-render.js.map +1 -1
- package/package.json +4 -3
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import type { IPointLike } from '@visactor/vutils';
|
|
1
2
|
import type { IArea, IAreaGraphicAttribute, IAreaSegment, IGraphicAttribute, IContext2d, IMarkAttribute, IThemeAttribute, IGraphicRender, IGraphicRenderDrawParams, IDrawContext } from '../../../interface';
|
|
2
3
|
import { DefaultCanvasAreaRender } from './area-render';
|
|
3
4
|
export declare class DefaultIncrementalCanvasAreaRender extends DefaultCanvasAreaRender implements IGraphicRender {
|
|
4
5
|
type: 'area';
|
|
5
6
|
numberType: number;
|
|
6
7
|
drawShape(area: IArea, context: IContext2d, x: number, y: number, drawContext: IDrawContext, params?: IGraphicRenderDrawParams, fillCb?: (ctx: IContext2d, lineAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean): void;
|
|
7
|
-
drawIncreaseSegment(area: IArea, context: IContext2d, lastSeg: IAreaSegment, seg: IAreaSegment, attribute: Partial<IAreaGraphicAttribute>, defaultAttribute: Required<IAreaGraphicAttribute> | Partial<IAreaGraphicAttribute>[], offsetX: number, offsetY: number
|
|
8
|
+
drawIncreaseSegment(area: IArea, context: IContext2d, lastSeg: IAreaSegment, seg: IAreaSegment, attribute: Partial<IAreaGraphicAttribute>, defaultAttribute: Required<IAreaGraphicAttribute> | Partial<IAreaGraphicAttribute>[], offsetX: number, offsetY: number, continuity?: {
|
|
9
|
+
connectedType: 'none' | 'connect';
|
|
10
|
+
startPoint?: IPointLike;
|
|
11
|
+
}): void;
|
|
8
12
|
}
|
|
@@ -8,6 +8,19 @@ import { DefaultCanvasAreaRender } from "./area-render";
|
|
|
8
8
|
|
|
9
9
|
import { drawIncrementalAreaSegments } from "../../../common/render-curve";
|
|
10
10
|
|
|
11
|
+
import { getAreaPointRuns } from "../../../common/area-cache";
|
|
12
|
+
|
|
13
|
+
function previousPoint(segments, index, connectedType) {
|
|
14
|
+
for (let i = index - 1; i >= 0; i--) {
|
|
15
|
+
const points = segments[i].points;
|
|
16
|
+
for (let j = points.length - 1; j >= 0; j--) {
|
|
17
|
+
const point = points[j];
|
|
18
|
+
if (!1 !== point.defined) return point;
|
|
19
|
+
if ("connect" !== connectedType) return;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
11
24
|
export class DefaultIncrementalCanvasAreaRender extends DefaultCanvasAreaRender {
|
|
12
25
|
constructor() {
|
|
13
26
|
super(...arguments), this.numberType = AREA_NUMBER_TYPE;
|
|
@@ -16,19 +29,28 @@ export class DefaultIncrementalCanvasAreaRender extends DefaultCanvasAreaRender
|
|
|
16
29
|
if (area.incremental && drawContext.multiGraphicOptions) {
|
|
17
30
|
const {startAtIdx: startAtIdx, length: length} = drawContext.multiGraphicOptions, {segments: segments = []} = area.attribute;
|
|
18
31
|
if (startAtIdx > segments.length) return;
|
|
19
|
-
const areaAttribute = getTheme(area).area, {fill: fill = areaAttribute.fill, fillOpacity: fillOpacity = areaAttribute.fillOpacity, opacity: opacity = areaAttribute.opacity, visible: visible = areaAttribute.visible} = area.attribute, fVisible = fillVisible(opacity, fillOpacity, fill), doFill = runFill(fill);
|
|
32
|
+
const areaAttribute = getTheme(area).area, {fill: fill = areaAttribute.fill, fillOpacity: fillOpacity = areaAttribute.fillOpacity, opacity: opacity = areaAttribute.opacity, visible: visible = areaAttribute.visible, connectedType: connectedType = areaAttribute.connectedType} = area.attribute, fVisible = fillVisible(opacity, fillOpacity, fill), doFill = runFill(fill);
|
|
20
33
|
if (!area.valid || !visible) return;
|
|
21
34
|
if (!doFill) return;
|
|
22
35
|
if (!fVisible && !fillCb) return;
|
|
23
|
-
|
|
36
|
+
const endIndex = Math.min(startAtIdx + length, segments.length);
|
|
37
|
+
for (let i = startAtIdx; i < endIndex; i++) segments[i].points.some((p => !1 !== p.defined)) && this.drawIncreaseSegment(area, context, segments[i - 1], segments[i], area.attribute.segments[i], [ areaAttribute, area.attribute ], x, y, {
|
|
38
|
+
connectedType: connectedType,
|
|
39
|
+
startPoint: previousPoint(segments, i, connectedType)
|
|
40
|
+
});
|
|
24
41
|
} else super.drawShape(area, context, x, y, drawContext, params, fillCb);
|
|
25
42
|
}
|
|
26
|
-
drawIncreaseSegment(area, context, lastSeg, seg, attribute, defaultAttribute, offsetX, offsetY) {
|
|
27
|
-
|
|
43
|
+
drawIncreaseSegment(area, context, lastSeg, seg, attribute, defaultAttribute, offsetX, offsetY, continuity) {
|
|
44
|
+
var _a, _b;
|
|
45
|
+
if (!seg) return;
|
|
46
|
+
const connectedType = null !== (_b = null !== (_a = null == continuity ? void 0 : continuity.connectedType) && void 0 !== _a ? _a : area.attribute.connectedType) && void 0 !== _b ? _b : getTheme(area).area.connectedType, startPoint = continuity ? continuity.startPoint : lastSeg && getAreaPointRuns(lastSeg.points, connectedType).tail;
|
|
47
|
+
context.beginPath(), drawIncrementalAreaSegments(context.camera ? context : context.nativeContext, lastSeg, seg, {
|
|
28
48
|
offsetX: offsetX,
|
|
29
|
-
offsetY: offsetY
|
|
49
|
+
offsetY: offsetY,
|
|
50
|
+
connectedType: connectedType,
|
|
51
|
+
startPoint: startPoint
|
|
30
52
|
}), context.setShadowBlendStyle && context.setShadowBlendStyle(area, attribute, defaultAttribute),
|
|
31
|
-
context.setCommonStyle(area, attribute, offsetX, offsetY, defaultAttribute), context.fill()
|
|
53
|
+
context.setCommonStyle(area, attribute, offsetX, offsetY, defaultAttribute), context.fill();
|
|
32
54
|
}
|
|
33
55
|
}
|
|
34
56
|
//# sourceMappingURL=incremental-area-render.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/render/incremental-area-render.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/render/contributions/render/incremental-area-render.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,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CAAC;QAC5E,OAAO,CAAC,IAAI,EAAE,CAAC;IACjB,CAAC;CACF","file":"incremental-area-render.js","sourcesContent":["import type { IPointLike } from '@visactor/vutils';\nimport type {\n IArea,\n IAreaGraphicAttribute,\n IAreaSegment,\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n IThemeAttribute,\n IGraphicRender,\n IGraphicRenderDrawParams,\n IDrawContext\n} from '../../../interface';\nimport { AREA_NUMBER_TYPE } from '../../../graphic/constants';\nimport { getTheme } from '../../../graphic/theme';\nimport { fillVisible, runFill } from './utils';\nimport { DefaultCanvasAreaRender } from './area-render';\nimport { drawIncrementalAreaSegments } from '../../../common/render-curve';\nimport { getAreaPointRuns } from '../../../common/area-cache';\n\nfunction previousPoint(segments: IAreaSegment[], index: number, connectedType: 'none' | 'connect') {\n for (let i = index - 1; i >= 0; i--) {\n const points = segments[i].points;\n for (let j = points.length - 1; j >= 0; j--) {\n const point = points[j];\n if (point.defined !== false) {\n return point;\n }\n if (connectedType !== 'connect') {\n return undefined;\n }\n }\n }\n return undefined;\n}\n\n/**\n * 默认的基于canvas的line渲染器\n * 单例\n */\nexport class DefaultIncrementalCanvasAreaRender extends DefaultCanvasAreaRender implements IGraphicRender {\n declare type: 'area';\n numberType: number = AREA_NUMBER_TYPE;\n\n drawShape(\n area: IArea,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n lineAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n if (area.incremental && drawContext.multiGraphicOptions) {\n const { startAtIdx, length } = drawContext.multiGraphicOptions;\n const { segments = [] } = area.attribute;\n if (startAtIdx > segments.length) {\n return;\n }\n const areaAttribute = getTheme(area).area;\n const {\n fill = areaAttribute.fill,\n fillOpacity = areaAttribute.fillOpacity,\n opacity = areaAttribute.opacity,\n visible = areaAttribute.visible,\n connectedType = areaAttribute.connectedType\n } = area.attribute;\n // 不绘制或者透明\n const fVisible = fillVisible(opacity, fillOpacity, fill);\n const doFill = runFill(fill);\n\n if (!(area.valid && visible)) {\n return;\n }\n\n if (!doFill) {\n return;\n }\n\n // 如果存在fillCb和strokeCb,那就不直接跳过\n if (!(fVisible || fillCb)) {\n return;\n }\n\n // 不支持clipRange,不支持pick,仅支持最基础的线段绘制\n const endIndex = Math.min(startAtIdx + length, segments.length);\n for (let i = startAtIdx; i < endIndex; i++) {\n // Empty batches draw nothing and must not repeatedly search the same prefix.\n if (!segments[i].points.some(p => p.defined !== false)) {\n continue;\n }\n this.drawIncreaseSegment(\n area,\n context,\n segments[i - 1],\n segments[i],\n area.attribute.segments[i],\n [areaAttribute, area.attribute],\n x,\n y,\n { connectedType, startPoint: previousPoint(segments, i, connectedType) }\n );\n }\n } else {\n super.drawShape(area, context, x, y, drawContext, params, fillCb);\n }\n }\n\n drawIncreaseSegment(\n area: IArea,\n context: IContext2d,\n lastSeg: IAreaSegment,\n seg: IAreaSegment,\n attribute: Partial<IAreaGraphicAttribute>,\n defaultAttribute: Required<IAreaGraphicAttribute> | Partial<IAreaGraphicAttribute>[],\n offsetX: number,\n offsetY: number,\n continuity?: { connectedType: 'none' | 'connect'; startPoint?: IPointLike }\n ) {\n if (!seg) {\n return;\n }\n\n const connectedType =\n continuity?.connectedType ?? area.attribute.connectedType ?? getTheme(area).area.connectedType;\n const startPoint = continuity\n ? continuity.startPoint\n : lastSeg && getAreaPointRuns(lastSeg.points, connectedType).tail;\n context.beginPath();\n drawIncrementalAreaSegments(context.camera ? context : context.nativeContext, lastSeg, seg, {\n offsetX,\n offsetY,\n connectedType,\n startPoint\n });\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(area, attribute, defaultAttribute);\n context.setCommonStyle(area, attribute, offsetX, offsetY, defaultAttribute);\n context.fill();\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visactor/vrender-core",
|
|
3
|
-
"version": "1.1.11
|
|
3
|
+
"version": "1.1.11",
|
|
4
4
|
"description": "",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"./src/modules.ts",
|
|
@@ -136,8 +136,8 @@
|
|
|
136
136
|
"typescript": "4.9.5",
|
|
137
137
|
"cross-env": "^7.0.3",
|
|
138
138
|
"@internal/bundler": "0.0.1",
|
|
139
|
-
"@internal/
|
|
140
|
-
"@internal/
|
|
139
|
+
"@internal/eslint-config": "0.0.1",
|
|
140
|
+
"@internal/ts-config": "0.0.1"
|
|
141
141
|
},
|
|
142
142
|
"keywords": [
|
|
143
143
|
"VisActor",
|
|
@@ -334,6 +334,7 @@
|
|
|
334
334
|
"dev": "cross-env DEBUG='Bundler*' bundle --clean -f es -w",
|
|
335
335
|
"start": "vite ./__tests__/browser",
|
|
336
336
|
"test": "jest -c jest.config.js",
|
|
337
|
+
"test:artifacts": "jest -c jest.artifacts.config.js",
|
|
337
338
|
"test:electron": "jest -c jest.electron.config.js --runInBand --passWithNoTests --testPathPattern='__tests__/(browser|electron)/'",
|
|
338
339
|
"test-live": "npm run test-watch __tests__/unit/theme/line.test.ts",
|
|
339
340
|
"test-watch": "cross-env DEBUG_MODE=1 jest --watch -c jest.config.js",
|