@visactor/vrender-core 1.1.11-alpha.0 → 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/glyph.js +3 -0
- package/cjs/graphic/glyph.js.map +1 -1
- package/cjs/graphic/graphic.d.ts +1 -0
- package/cjs/graphic/graphic.js +3 -0
- package/cjs/graphic/graphic.js.map +1 -1
- package/cjs/graphic/line.js +4 -4
- package/cjs/graphic/line.js.map +1 -1
- package/cjs/graphic/state/attribute-update-classifier.js +2 -0
- package/cjs/graphic/state/attribute-update-classifier.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 +231 -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/glyph.js +4 -1
- package/es/graphic/glyph.js.map +1 -1
- package/es/graphic/graphic.d.ts +1 -0
- package/es/graphic/graphic.js +3 -0
- package/es/graphic/graphic.js.map +1 -1
- package/es/graphic/line.js +4 -4
- package/es/graphic/line.js.map +1 -1
- package/es/graphic/state/attribute-update-classifier.js +2 -0
- package/es/graphic/state/attribute-update-classifier.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
package/dist/index.es.js
CHANGED
|
@@ -9475,6 +9475,8 @@ const ATTRIBUTE_CATEGORY = {
|
|
|
9475
9475
|
shadowColor: UpdateCategory.PAINT,
|
|
9476
9476
|
x: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
9477
9477
|
y: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
9478
|
+
dx: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
9479
|
+
dy: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
9478
9480
|
scaleX: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
9479
9481
|
scaleY: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
9480
9482
|
angle: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
@@ -11036,6 +11038,9 @@ class Graphic extends Node {
|
|
|
11036
11038
|
this.setShadowGraphic(value);
|
|
11037
11039
|
}
|
|
11038
11040
|
}
|
|
11041
|
+
static needsShapeUpdate(graphic, key) {
|
|
11042
|
+
return graphic.needUpdateTag(key);
|
|
11043
|
+
}
|
|
11039
11044
|
needUpdateTags(keys, k = GRAPHIC_UPDATE_TAG_KEY) {
|
|
11040
11045
|
for (let i = 0; i < k.length; i++) {
|
|
11041
11046
|
const attrKey = k[i];
|
|
@@ -13533,21 +13538,21 @@ let Line$1 = class Line extends Graphic {
|
|
|
13533
13538
|
return aabbBounds;
|
|
13534
13539
|
}
|
|
13535
13540
|
updateLineAABBBoundsByPoints(attribute, lineTheme, aabbBounds, graphic) {
|
|
13536
|
-
const { points = lineTheme.points
|
|
13541
|
+
const { points = lineTheme.points } = attribute;
|
|
13537
13542
|
const b = aabbBounds;
|
|
13538
13543
|
points.forEach(p => {
|
|
13539
|
-
if (p.defined !== false
|
|
13544
|
+
if (p.defined !== false) {
|
|
13540
13545
|
b.add(p.x, p.y);
|
|
13541
13546
|
}
|
|
13542
13547
|
});
|
|
13543
13548
|
return b;
|
|
13544
13549
|
}
|
|
13545
13550
|
updateLineAABBBoundsBySegments(attribute, lineTheme, aabbBounds, graphic) {
|
|
13546
|
-
const { segments = lineTheme.segments
|
|
13551
|
+
const { segments = lineTheme.segments } = attribute;
|
|
13547
13552
|
const b = aabbBounds;
|
|
13548
13553
|
segments.forEach(s => {
|
|
13549
13554
|
s.points.forEach(p => {
|
|
13550
|
-
if (p.defined !== false
|
|
13555
|
+
if (p.defined !== false) {
|
|
13551
13556
|
b.add(p.x, p.y);
|
|
13552
13557
|
}
|
|
13553
13558
|
});
|
|
@@ -13913,9 +13918,22 @@ class Glyph extends Graphic {
|
|
|
13913
13918
|
return bounds;
|
|
13914
13919
|
}
|
|
13915
13920
|
needUpdateTags(keys) {
|
|
13921
|
+
for (const key of keys) {
|
|
13922
|
+
if (this.needUpdateTag(key)) {
|
|
13923
|
+
return true;
|
|
13924
|
+
}
|
|
13925
|
+
}
|
|
13916
13926
|
return false;
|
|
13917
13927
|
}
|
|
13918
13928
|
needUpdateTag(key) {
|
|
13929
|
+
if (ATTRIBUTE_CATEGORY[key] === UpdateCategory.PAINT) {
|
|
13930
|
+
return false;
|
|
13931
|
+
}
|
|
13932
|
+
for (const child of this.subGraphic) {
|
|
13933
|
+
if (Graphic.needsShapeUpdate(child, key)) {
|
|
13934
|
+
return true;
|
|
13935
|
+
}
|
|
13936
|
+
}
|
|
13919
13937
|
return false;
|
|
13920
13938
|
}
|
|
13921
13939
|
hasLegacyStateDefinitions() {
|
|
@@ -15887,7 +15905,14 @@ function createPath(attributes) {
|
|
|
15887
15905
|
return new Path(attributes);
|
|
15888
15906
|
}
|
|
15889
15907
|
|
|
15890
|
-
const AREA_UPDATE_TAG_KEY = [
|
|
15908
|
+
const AREA_UPDATE_TAG_KEY = [
|
|
15909
|
+
'segments',
|
|
15910
|
+
'points',
|
|
15911
|
+
'curveType',
|
|
15912
|
+
'curveTension',
|
|
15913
|
+
'connectedType',
|
|
15914
|
+
...GRAPHIC_UPDATE_TAG_KEY
|
|
15915
|
+
];
|
|
15891
15916
|
class Area extends Graphic {
|
|
15892
15917
|
constructor(params) {
|
|
15893
15918
|
super(params);
|
|
@@ -15936,6 +15961,9 @@ class Area extends Graphic {
|
|
|
15936
15961
|
const b = aabbBounds;
|
|
15937
15962
|
points.forEach(p => {
|
|
15938
15963
|
var _a, _b;
|
|
15964
|
+
if (p.defined === false) {
|
|
15965
|
+
return;
|
|
15966
|
+
}
|
|
15939
15967
|
b.add(p.x, p.y);
|
|
15940
15968
|
b.add((_a = p.x1) !== null && _a !== void 0 ? _a : p.x, (_b = p.y1) !== null && _b !== void 0 ? _b : p.y);
|
|
15941
15969
|
});
|
|
@@ -15947,6 +15975,9 @@ class Area extends Graphic {
|
|
|
15947
15975
|
segments.forEach(s => {
|
|
15948
15976
|
s.points.forEach(p => {
|
|
15949
15977
|
var _a, _b;
|
|
15978
|
+
if (p.defined === false) {
|
|
15979
|
+
return;
|
|
15980
|
+
}
|
|
15950
15981
|
b.add(p.x, p.y);
|
|
15951
15982
|
b.add((_a = p.x1) !== null && _a !== void 0 ? _a : p.x, (_b = p.y1) !== null && _b !== void 0 ? _b : p.y);
|
|
15952
15983
|
});
|
|
@@ -24859,6 +24890,142 @@ function drawSegItem(ctx, curve, endPercent, params) {
|
|
|
24859
24890
|
}
|
|
24860
24891
|
}
|
|
24861
24892
|
|
|
24893
|
+
function getAreaPointRuns(points, connectedType, startPoint) {
|
|
24894
|
+
const runs = [];
|
|
24895
|
+
if (!points.some(p => p.defined === false)) {
|
|
24896
|
+
const run = startPoint ? [startPoint, ...points] : points;
|
|
24897
|
+
if (run.length) {
|
|
24898
|
+
runs.push(run);
|
|
24899
|
+
}
|
|
24900
|
+
return { runs, tail: run[run.length - 1] };
|
|
24901
|
+
}
|
|
24902
|
+
let run = startPoint ? [startPoint] : [];
|
|
24903
|
+
for (let i = 0; i < points.length; i++) {
|
|
24904
|
+
const point = points[i];
|
|
24905
|
+
if (point.defined !== false) {
|
|
24906
|
+
run.push(point);
|
|
24907
|
+
}
|
|
24908
|
+
else if (connectedType !== 'connect') {
|
|
24909
|
+
if (run.length) {
|
|
24910
|
+
runs.push(run);
|
|
24911
|
+
}
|
|
24912
|
+
run = [];
|
|
24913
|
+
}
|
|
24914
|
+
}
|
|
24915
|
+
if (run.length) {
|
|
24916
|
+
runs.push(run);
|
|
24917
|
+
}
|
|
24918
|
+
return { runs, tail: run[run.length - 1] };
|
|
24919
|
+
}
|
|
24920
|
+
function joinAreaPaths(paths) {
|
|
24921
|
+
var _a;
|
|
24922
|
+
if (paths.length === 1) {
|
|
24923
|
+
return paths[0];
|
|
24924
|
+
}
|
|
24925
|
+
const curves = [];
|
|
24926
|
+
for (let i = 0; i < paths.length; i++) {
|
|
24927
|
+
const next = paths[i].curves;
|
|
24928
|
+
if (curves.length) {
|
|
24929
|
+
const previous = curves[curves.length - 1];
|
|
24930
|
+
const gap = new LineCurve((_a = previous.p3) !== null && _a !== void 0 ? _a : previous.p1, next[0].p0);
|
|
24931
|
+
gap.defined = false;
|
|
24932
|
+
gap.originP1 = previous.originP2;
|
|
24933
|
+
gap.originP2 = next[0].originP1;
|
|
24934
|
+
curves.push(gap);
|
|
24935
|
+
}
|
|
24936
|
+
for (let j = 0; j < next.length; j++) {
|
|
24937
|
+
curves.push(next[j]);
|
|
24938
|
+
}
|
|
24939
|
+
}
|
|
24940
|
+
const path = paths[paths.length - 1];
|
|
24941
|
+
path.curves = curves;
|
|
24942
|
+
path.length = NaN;
|
|
24943
|
+
return path;
|
|
24944
|
+
}
|
|
24945
|
+
function compileAreaRuns(runs, curveType, curveTension, sourceSegmentIndex, topStart, bottomStart) {
|
|
24946
|
+
var _a, _b, _c, _d;
|
|
24947
|
+
const tops = [];
|
|
24948
|
+
const bottoms = [];
|
|
24949
|
+
const bottomType = curveType === 'stepBefore' ? 'stepAfter' : curveType === 'stepAfter' ? 'stepBefore' : curveType;
|
|
24950
|
+
for (let i = 0; i < runs.length; i++) {
|
|
24951
|
+
const points = runs[i];
|
|
24952
|
+
const startPoint = i === 0 ? topStart : undefined;
|
|
24953
|
+
if (points.length < 2 - Number(!!startPoint)) {
|
|
24954
|
+
continue;
|
|
24955
|
+
}
|
|
24956
|
+
const bottomPoints = [];
|
|
24957
|
+
for (let j = points.length - 1; j >= 0; j--) {
|
|
24958
|
+
const p = points[j];
|
|
24959
|
+
bottomPoints.push({ x: (_a = p.x1) !== null && _a !== void 0 ? _a : p.x, y: (_b = p.y1) !== null && _b !== void 0 ? _b : p.y });
|
|
24960
|
+
}
|
|
24961
|
+
if (i === 0 && bottomStart) {
|
|
24962
|
+
bottomPoints.push({ x: (_c = bottomStart.x1) !== null && _c !== void 0 ? _c : bottomStart.x, y: (_d = bottomStart.y1) !== null && _d !== void 0 ? _d : bottomStart.y });
|
|
24963
|
+
}
|
|
24964
|
+
const top = calcLineCache(points, curveType, { startPoint, curveTension });
|
|
24965
|
+
const bottom = calcLineCache(bottomPoints, bottomType, { curveTension });
|
|
24966
|
+
if ((top === null || top === void 0 ? void 0 : top.curves.length) && (bottom === null || bottom === void 0 ? void 0 : bottom.curves.length)) {
|
|
24967
|
+
tops.push(top);
|
|
24968
|
+
bottoms.push(bottom);
|
|
24969
|
+
}
|
|
24970
|
+
}
|
|
24971
|
+
if (!tops.length) {
|
|
24972
|
+
return null;
|
|
24973
|
+
}
|
|
24974
|
+
return {
|
|
24975
|
+
top: joinAreaPaths(tops),
|
|
24976
|
+
bottom: joinAreaPaths(bottoms.reverse()),
|
|
24977
|
+
sourceSegmentIndex,
|
|
24978
|
+
direction: Direction.ROW
|
|
24979
|
+
};
|
|
24980
|
+
}
|
|
24981
|
+
function calcAreaCache(points, segments, curveType, connectedType, curveTension) {
|
|
24982
|
+
var _a;
|
|
24983
|
+
const caches = [];
|
|
24984
|
+
let tail;
|
|
24985
|
+
let topTail;
|
|
24986
|
+
let first;
|
|
24987
|
+
let last;
|
|
24988
|
+
const count = segments ? segments.length : 1;
|
|
24989
|
+
for (let i = 0; i < count; i++) {
|
|
24990
|
+
const segmentPoints = segments ? segments[i].points : points !== null && points !== void 0 ? points : [];
|
|
24991
|
+
const result = getAreaPointRuns(segmentPoints, connectedType);
|
|
24992
|
+
const canContinue = connectedType === 'connect' || ((_a = segmentPoints[0]) === null || _a === void 0 ? void 0 : _a.defined) !== false;
|
|
24993
|
+
if (result.runs.length) {
|
|
24994
|
+
first = first !== null && first !== void 0 ? first : result.runs[0][0];
|
|
24995
|
+
const lastRun = result.runs[result.runs.length - 1];
|
|
24996
|
+
last = lastRun[lastRun.length - 1];
|
|
24997
|
+
}
|
|
24998
|
+
const cache = compileAreaRuns(result.runs, curveType, curveTension, i, canContinue ? topTail : undefined, canContinue ? tail : undefined);
|
|
24999
|
+
if (cache) {
|
|
25000
|
+
caches.push(cache);
|
|
25001
|
+
}
|
|
25002
|
+
if (result.tail) {
|
|
25003
|
+
tail = result.tail;
|
|
25004
|
+
const lastRun = result.runs[result.runs.length - 1];
|
|
25005
|
+
topTail =
|
|
25006
|
+
cache && (result.runs.length === 1 || lastRun.length > 1) ? { x: cache.top.endX, y: cache.top.endY } : tail;
|
|
25007
|
+
}
|
|
25008
|
+
else if (connectedType !== 'connect' && segmentPoints.length) {
|
|
25009
|
+
tail = topTail = undefined;
|
|
25010
|
+
}
|
|
25011
|
+
}
|
|
25012
|
+
if (!caches.length) {
|
|
25013
|
+
return null;
|
|
25014
|
+
}
|
|
25015
|
+
let direction = Direction.ROW;
|
|
25016
|
+
if (last.x1 != null) {
|
|
25017
|
+
const dx = abs(last.x - first.x);
|
|
25018
|
+
const dy = abs(last.y - first.y);
|
|
25019
|
+
if (last.y1 == null || (Number.isFinite(dx + dy) && dy >= dx)) {
|
|
25020
|
+
direction = Direction.COLUMN;
|
|
25021
|
+
}
|
|
25022
|
+
}
|
|
25023
|
+
for (let i = 0; i < caches.length; i++) {
|
|
25024
|
+
caches[i].direction = direction;
|
|
25025
|
+
}
|
|
25026
|
+
return segments ? caches : caches[0];
|
|
25027
|
+
}
|
|
25028
|
+
|
|
24862
25029
|
function drawEachCurve(path, curve, lastCurve, defined0, offsetX, offsetY, offsetZ) {
|
|
24863
25030
|
var _a;
|
|
24864
25031
|
let p0 = curve.p0;
|
|
@@ -24994,31 +25161,27 @@ function drawIncrementalSegments(path, lastSeg, segments, params) {
|
|
|
24994
25161
|
});
|
|
24995
25162
|
}
|
|
24996
25163
|
function drawIncrementalAreaSegments(path, lastSeg, segments, params) {
|
|
24997
|
-
|
|
24998
|
-
const {
|
|
24999
|
-
const
|
|
25000
|
-
|
|
25001
|
-
|
|
25002
|
-
}
|
|
25003
|
-
|
|
25004
|
-
|
|
25005
|
-
|
|
25006
|
-
|
|
25007
|
-
|
|
25008
|
-
points.
|
|
25009
|
-
|
|
25010
|
-
|
|
25011
|
-
|
|
25012
|
-
|
|
25013
|
-
|
|
25014
|
-
});
|
|
25015
|
-
for (let i = points.length - 1; i >= 0; i--) {
|
|
25016
|
-
const p = points[i];
|
|
25164
|
+
var _a, _b;
|
|
25165
|
+
const { offsetX = 0, offsetY = 0, connectedType = 'none' } = params || {};
|
|
25166
|
+
const startPoint = params && 'startPoint' in params
|
|
25167
|
+
? params.startPoint
|
|
25168
|
+
: lastSeg && getAreaPointRuns(lastSeg.points, connectedType).tail;
|
|
25169
|
+
const { runs } = getAreaPointRuns(segments.points, connectedType, startPoint);
|
|
25170
|
+
for (let i = 0; i < runs.length; i++) {
|
|
25171
|
+
const points = runs[i];
|
|
25172
|
+
if (points.length < 2) {
|
|
25173
|
+
continue;
|
|
25174
|
+
}
|
|
25175
|
+
path.moveTo(points[0].x + offsetX, points[0].y + offsetY);
|
|
25176
|
+
for (let j = 1; j < points.length; j++) {
|
|
25177
|
+
path.lineTo(points[j].x + offsetX, points[j].y + offsetY);
|
|
25178
|
+
}
|
|
25179
|
+
for (let j = points.length - 1; j >= 0; j--) {
|
|
25180
|
+
const p = points[j];
|
|
25017
25181
|
path.lineTo((_a = p.x1) !== null && _a !== void 0 ? _a : p.x, (_b = p.y1) !== null && _b !== void 0 ? _b : p.y);
|
|
25018
25182
|
}
|
|
25019
|
-
path.lineTo((_c = startP.x1) !== null && _c !== void 0 ? _c : startP.x, (_d = startP.y1) !== null && _d !== void 0 ? _d : startP.y);
|
|
25020
25183
|
path.closePath();
|
|
25021
|
-
}
|
|
25184
|
+
}
|
|
25022
25185
|
}
|
|
25023
25186
|
|
|
25024
25187
|
class DefaultCanvasLineRender extends BaseRender {
|
|
@@ -25447,7 +25610,6 @@ class DefaultCanvasAreaRender extends BaseRender {
|
|
|
25447
25610
|
_runStroke();
|
|
25448
25611
|
}
|
|
25449
25612
|
drawShape(area, context, x, y, drawContext, params, fillCb, strokeCb) {
|
|
25450
|
-
var _a, _b, _c, _d, _e, _f;
|
|
25451
25613
|
const areaAttribute = getTheme(area, params === null || params === void 0 ? void 0 : params.theme).area;
|
|
25452
25614
|
const { fill = areaAttribute.fill, stroke = areaAttribute.stroke, fillOpacity = areaAttribute.fillOpacity, z = areaAttribute.z, strokeOpacity = areaAttribute.strokeOpacity, curveTension = areaAttribute.curveTension, connectedType = areaAttribute.connectedType } = area.attribute;
|
|
25453
25615
|
const data = this.valid(area, areaAttribute, fillCb, strokeCb);
|
|
@@ -25461,104 +25623,24 @@ class DefaultCanvasAreaRender extends BaseRender {
|
|
|
25461
25623
|
if (closePath && curveType === 'linear') {
|
|
25462
25624
|
curveType = 'linearClosed';
|
|
25463
25625
|
}
|
|
25464
|
-
function parsePoint(points, connectedType) {
|
|
25465
|
-
if (connectedType !== 'connect') {
|
|
25466
|
-
return points;
|
|
25467
|
-
}
|
|
25468
|
-
return points.filter(p => p.defined !== false);
|
|
25469
|
-
}
|
|
25470
25626
|
if (clipRange === 1 && !segments && !points.some(p => p.defined === false) && curveType === 'linear') {
|
|
25471
25627
|
return this.drawLinearAreaHighPerformance(area, context, !!fill, doStroke, fillOpacity, strokeOpacity, x, y, areaAttribute, drawContext, params, fillCb, strokeCb);
|
|
25472
25628
|
}
|
|
25473
25629
|
if (area.shouldUpdateShape()) {
|
|
25474
|
-
|
|
25475
|
-
let startPoint;
|
|
25476
|
-
let lastTopSeg;
|
|
25477
|
-
const topCaches = segments
|
|
25478
|
-
.map((seg, index) => {
|
|
25479
|
-
if (seg.points.length <= 1) {
|
|
25480
|
-
if (index === 0) {
|
|
25481
|
-
seg.points[0] && (lastTopSeg = { endX: seg.points[0].x, endY: seg.points[0].y });
|
|
25482
|
-
return null;
|
|
25483
|
-
}
|
|
25484
|
-
}
|
|
25485
|
-
if (index === 1) {
|
|
25486
|
-
startPoint = { x: lastTopSeg.endX, y: lastTopSeg.endY };
|
|
25487
|
-
}
|
|
25488
|
-
else if (index > 1) {
|
|
25489
|
-
startPoint.x = lastTopSeg.endX;
|
|
25490
|
-
startPoint.y = lastTopSeg.endY;
|
|
25491
|
-
}
|
|
25492
|
-
const data = calcLineCache(parsePoint(seg.points, connectedType), curveType, {
|
|
25493
|
-
startPoint,
|
|
25494
|
-
curveTension
|
|
25495
|
-
});
|
|
25496
|
-
lastTopSeg = data;
|
|
25497
|
-
return data;
|
|
25498
|
-
})
|
|
25499
|
-
.filter(item => !!item);
|
|
25500
|
-
let lastBottomSeg;
|
|
25501
|
-
const bottomCaches = [];
|
|
25502
|
-
for (let i = segments.length - 1; i >= 0; i--) {
|
|
25503
|
-
const points = segments[i].points;
|
|
25504
|
-
const bottomPoints = [];
|
|
25505
|
-
for (let i = points.length - 1; i >= 0; i--) {
|
|
25506
|
-
bottomPoints.push({
|
|
25507
|
-
x: (_a = points[i].x1) !== null && _a !== void 0 ? _a : points[i].x,
|
|
25508
|
-
y: (_b = points[i].y1) !== null && _b !== void 0 ? _b : points[i].y
|
|
25509
|
-
});
|
|
25510
|
-
}
|
|
25511
|
-
if (i !== 0) {
|
|
25512
|
-
const lastSegmentPoints = segments[i - 1].points;
|
|
25513
|
-
const endPoint = lastSegmentPoints[lastSegmentPoints.length - 1];
|
|
25514
|
-
endPoint &&
|
|
25515
|
-
bottomPoints.push({
|
|
25516
|
-
x: (_c = endPoint.x1) !== null && _c !== void 0 ? _c : endPoint.x,
|
|
25517
|
-
y: (_d = endPoint.y1) !== null && _d !== void 0 ? _d : endPoint.y
|
|
25518
|
-
});
|
|
25519
|
-
}
|
|
25520
|
-
if (bottomPoints.length > 1) {
|
|
25521
|
-
lastBottomSeg = calcLineCache(parsePoint(bottomPoints, connectedType), curveType === 'stepBefore' ? 'stepAfter' : curveType === 'stepAfter' ? 'stepBefore' : curveType, { curveTension });
|
|
25522
|
-
bottomCaches.unshift(lastBottomSeg);
|
|
25523
|
-
}
|
|
25524
|
-
}
|
|
25525
|
-
area.cacheArea = bottomCaches.map((item, index) => ({
|
|
25526
|
-
top: topCaches[index],
|
|
25527
|
-
bottom: item
|
|
25528
|
-
}));
|
|
25529
|
-
}
|
|
25530
|
-
else if (points && points.length) {
|
|
25531
|
-
const topPoints = parsePoint(points, connectedType);
|
|
25532
|
-
const bottomPoints = [];
|
|
25533
|
-
for (let i = topPoints.length - 1; i >= 0; i--) {
|
|
25534
|
-
bottomPoints.push({
|
|
25535
|
-
x: (_e = topPoints[i].x1) !== null && _e !== void 0 ? _e : topPoints[i].x,
|
|
25536
|
-
y: (_f = topPoints[i].y1) !== null && _f !== void 0 ? _f : topPoints[i].y
|
|
25537
|
-
});
|
|
25538
|
-
}
|
|
25539
|
-
const topCache = calcLineCache(topPoints, curveType, { curveTension });
|
|
25540
|
-
const bottomCache = calcLineCache(bottomPoints, curveType === 'stepBefore' ? 'stepAfter' : curveType === 'stepAfter' ? 'stepBefore' : curveType, { curveTension });
|
|
25541
|
-
area.cacheArea = { top: topCache, bottom: bottomCache };
|
|
25542
|
-
}
|
|
25543
|
-
else {
|
|
25544
|
-
area.cacheArea = null;
|
|
25545
|
-
area.clearUpdateShapeTag();
|
|
25546
|
-
return;
|
|
25547
|
-
}
|
|
25630
|
+
area.cacheArea = calcAreaCache(points, segments, curveType, connectedType, curveTension);
|
|
25548
25631
|
area.clearUpdateShapeTag();
|
|
25549
25632
|
}
|
|
25633
|
+
if (!area.cacheArea) {
|
|
25634
|
+
return;
|
|
25635
|
+
}
|
|
25550
25636
|
if (Array.isArray(area.cacheArea)) {
|
|
25551
|
-
const segments = area.attribute.segments.filter(item => item.points.length);
|
|
25552
|
-
if (segments[0].points.length === 1) {
|
|
25553
|
-
segments.shift();
|
|
25554
|
-
}
|
|
25555
25637
|
if (clipRange === 1) {
|
|
25556
25638
|
let skip = false;
|
|
25557
|
-
area.cacheArea.forEach(
|
|
25639
|
+
area.cacheArea.forEach(cache => {
|
|
25558
25640
|
if (skip) {
|
|
25559
25641
|
return;
|
|
25560
25642
|
}
|
|
25561
|
-
skip = this.drawSegmentItem(context, cache, doFill, fillOpacity, doStroke, strokeOpacity, segments[
|
|
25643
|
+
skip = this.drawSegmentItem(context, cache, doFill, fillOpacity, doStroke, strokeOpacity, segments[cache.sourceSegmentIndex], [areaAttribute, area.attribute], clipRange, x, y, z, area, drawContext, fillCb, strokeCb);
|
|
25562
25644
|
});
|
|
25563
25645
|
}
|
|
25564
25646
|
else {
|
|
@@ -25566,7 +25648,7 @@ class DefaultCanvasAreaRender extends BaseRender {
|
|
|
25566
25648
|
const totalDrawLength = clipRange * totalLength;
|
|
25567
25649
|
let drawedLengthUntilLast = 0;
|
|
25568
25650
|
let skip = false;
|
|
25569
|
-
area.cacheArea.forEach(
|
|
25651
|
+
area.cacheArea.forEach(cache => {
|
|
25570
25652
|
if (skip) {
|
|
25571
25653
|
return;
|
|
25572
25654
|
}
|
|
@@ -25574,7 +25656,7 @@ class DefaultCanvasAreaRender extends BaseRender {
|
|
|
25574
25656
|
const _cr = (totalDrawLength - drawedLengthUntilLast) / curSegLength;
|
|
25575
25657
|
drawedLengthUntilLast += curSegLength;
|
|
25576
25658
|
if (_cr > 0) {
|
|
25577
|
-
skip = this.drawSegmentItem(context, cache, doFill, fillOpacity, doStroke, strokeOpacity, segments[
|
|
25659
|
+
skip = this.drawSegmentItem(context, cache, doFill, fillOpacity, doStroke, strokeOpacity, segments[cache.sourceSegmentIndex], [areaAttribute, area.attribute], min(_cr, 1), x, y, z, area, drawContext, fillCb, strokeCb);
|
|
25578
25660
|
}
|
|
25579
25661
|
});
|
|
25580
25662
|
}
|
|
@@ -25591,6 +25673,7 @@ class DefaultCanvasAreaRender extends BaseRender {
|
|
|
25591
25673
|
return this._drawSegmentItem(context, cache, fill, fillOpacity, stroke, strokeOpacity, attribute, defaultAttribute, clipRange, offsetX, offsetY, offsetZ, area, drawContext, fillCb, strokeCb);
|
|
25592
25674
|
}
|
|
25593
25675
|
_drawSegmentItem(context, cache, fill, fillOpacity, stroke, strokeOpacity, attribute, defaultAttribute, clipRange, offsetX, offsetY, offsetZ, area, drawContext, fillCb, strokeCb) {
|
|
25676
|
+
var _a;
|
|
25594
25677
|
if (!(cache &&
|
|
25595
25678
|
cache.top &&
|
|
25596
25679
|
cache.bottom &&
|
|
@@ -25602,34 +25685,7 @@ class DefaultCanvasAreaRender extends BaseRender {
|
|
|
25602
25685
|
}
|
|
25603
25686
|
context.beginPath();
|
|
25604
25687
|
const ret = false;
|
|
25605
|
-
const
|
|
25606
|
-
let direction = Direction.ROW;
|
|
25607
|
-
let endP;
|
|
25608
|
-
let startP;
|
|
25609
|
-
if (segments) {
|
|
25610
|
-
const endSeg = segments[segments.length - 1];
|
|
25611
|
-
const startSeg = segments[0];
|
|
25612
|
-
startP = startSeg.points[0];
|
|
25613
|
-
endP = endSeg.points[endSeg.points.length - 1];
|
|
25614
|
-
}
|
|
25615
|
-
else {
|
|
25616
|
-
startP = points[0];
|
|
25617
|
-
endP = points[points.length - 1];
|
|
25618
|
-
}
|
|
25619
|
-
const xTotalLength = abs(endP.x - startP.x);
|
|
25620
|
-
const yTotalLength = abs(endP.y - startP.y);
|
|
25621
|
-
if (endP.x1 == null) {
|
|
25622
|
-
direction = Direction.ROW;
|
|
25623
|
-
}
|
|
25624
|
-
else if (endP.y1 == null) {
|
|
25625
|
-
direction = Direction.COLUMN;
|
|
25626
|
-
}
|
|
25627
|
-
else if (!Number.isFinite(xTotalLength + yTotalLength)) {
|
|
25628
|
-
direction = Direction.ROW;
|
|
25629
|
-
}
|
|
25630
|
-
else {
|
|
25631
|
-
direction = xTotalLength > yTotalLength ? Direction.ROW : Direction.COLUMN;
|
|
25632
|
-
}
|
|
25688
|
+
const direction = (_a = cache.direction) !== null && _a !== void 0 ? _a : cache.top.direction;
|
|
25633
25689
|
drawAreaSegments(context, cache, clipRange, {
|
|
25634
25690
|
offsetX,
|
|
25635
25691
|
offsetY,
|
|
@@ -27270,6 +27326,21 @@ function createMiniappApp(options = {}) {
|
|
|
27270
27326
|
return new MiniappEntry(options);
|
|
27271
27327
|
}
|
|
27272
27328
|
|
|
27329
|
+
function previousPoint(segments, index, connectedType) {
|
|
27330
|
+
for (let i = index - 1; i >= 0; i--) {
|
|
27331
|
+
const points = segments[i].points;
|
|
27332
|
+
for (let j = points.length - 1; j >= 0; j--) {
|
|
27333
|
+
const point = points[j];
|
|
27334
|
+
if (point.defined !== false) {
|
|
27335
|
+
return point;
|
|
27336
|
+
}
|
|
27337
|
+
if (connectedType !== 'connect') {
|
|
27338
|
+
return undefined;
|
|
27339
|
+
}
|
|
27340
|
+
}
|
|
27341
|
+
}
|
|
27342
|
+
return undefined;
|
|
27343
|
+
}
|
|
27273
27344
|
class DefaultIncrementalCanvasAreaRender extends DefaultCanvasAreaRender {
|
|
27274
27345
|
constructor() {
|
|
27275
27346
|
super(...arguments);
|
|
@@ -27283,7 +27354,7 @@ class DefaultIncrementalCanvasAreaRender extends DefaultCanvasAreaRender {
|
|
|
27283
27354
|
return;
|
|
27284
27355
|
}
|
|
27285
27356
|
const areaAttribute = getTheme(area).area;
|
|
27286
|
-
const { fill = areaAttribute.fill, fillOpacity = areaAttribute.fillOpacity, opacity = areaAttribute.opacity, visible = areaAttribute.visible } = area.attribute;
|
|
27357
|
+
const { fill = areaAttribute.fill, fillOpacity = areaAttribute.fillOpacity, opacity = areaAttribute.opacity, visible = areaAttribute.visible, connectedType = areaAttribute.connectedType } = area.attribute;
|
|
27287
27358
|
const fVisible = fillVisible(opacity, fillOpacity, fill);
|
|
27288
27359
|
const doFill = runFill(fill);
|
|
27289
27360
|
if (!(area.valid && visible)) {
|
|
@@ -27295,22 +27366,33 @@ class DefaultIncrementalCanvasAreaRender extends DefaultCanvasAreaRender {
|
|
|
27295
27366
|
if (!(fVisible || fillCb)) {
|
|
27296
27367
|
return;
|
|
27297
27368
|
}
|
|
27298
|
-
|
|
27299
|
-
|
|
27369
|
+
const endIndex = Math.min(startAtIdx + length, segments.length);
|
|
27370
|
+
for (let i = startAtIdx; i < endIndex; i++) {
|
|
27371
|
+
if (!segments[i].points.some(p => p.defined !== false)) {
|
|
27372
|
+
continue;
|
|
27373
|
+
}
|
|
27374
|
+
this.drawIncreaseSegment(area, context, segments[i - 1], segments[i], area.attribute.segments[i], [areaAttribute, area.attribute], x, y, { connectedType, startPoint: previousPoint(segments, i, connectedType) });
|
|
27300
27375
|
}
|
|
27301
27376
|
}
|
|
27302
27377
|
else {
|
|
27303
27378
|
super.drawShape(area, context, x, y, drawContext, params, fillCb);
|
|
27304
27379
|
}
|
|
27305
27380
|
}
|
|
27306
|
-
drawIncreaseSegment(area, context, lastSeg, seg, attribute, defaultAttribute, offsetX, offsetY) {
|
|
27381
|
+
drawIncreaseSegment(area, context, lastSeg, seg, attribute, defaultAttribute, offsetX, offsetY, continuity) {
|
|
27382
|
+
var _a, _b;
|
|
27307
27383
|
if (!seg) {
|
|
27308
27384
|
return;
|
|
27309
27385
|
}
|
|
27386
|
+
const connectedType = (_b = (_a = continuity === null || continuity === void 0 ? void 0 : continuity.connectedType) !== null && _a !== void 0 ? _a : area.attribute.connectedType) !== null && _b !== void 0 ? _b : getTheme(area).area.connectedType;
|
|
27387
|
+
const startPoint = continuity
|
|
27388
|
+
? continuity.startPoint
|
|
27389
|
+
: lastSeg && getAreaPointRuns(lastSeg.points, connectedType).tail;
|
|
27310
27390
|
context.beginPath();
|
|
27311
27391
|
drawIncrementalAreaSegments(context.camera ? context : context.nativeContext, lastSeg, seg, {
|
|
27312
27392
|
offsetX,
|
|
27313
|
-
offsetY
|
|
27393
|
+
offsetY,
|
|
27394
|
+
connectedType,
|
|
27395
|
+
startPoint
|
|
27314
27396
|
});
|
|
27315
27397
|
context.setShadowBlendStyle && context.setShadowBlendStyle(area, attribute, defaultAttribute);
|
|
27316
27398
|
context.setCommonStyle(area, attribute, offsetX, offsetY, defaultAttribute);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type IPointLike } from '@visactor/vutils';
|
|
2
|
+
import type { IAreaCacheItem, IAreaSegment, ICurveType, IDirection } from '../interface';
|
|
3
|
+
export interface AreaRenderCacheItem extends IAreaCacheItem {
|
|
4
|
+
sourceSegmentIndex: number;
|
|
5
|
+
direction: IDirection;
|
|
6
|
+
}
|
|
7
|
+
export declare function getAreaPointRuns(points: IPointLike[], connectedType: 'none' | 'connect', startPoint?: IPointLike): {
|
|
8
|
+
runs: IPointLike[][];
|
|
9
|
+
tail: IPointLike;
|
|
10
|
+
};
|
|
11
|
+
export declare function calcAreaCache(points: IPointLike[] | undefined, segments: IAreaSegment[] | undefined, curveType: ICurveType, connectedType: 'none' | 'connect', curveTension: number): AreaRenderCacheItem | AreaRenderCacheItem[] | null;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { abs } from "@visactor/vutils";
|
|
2
|
+
|
|
3
|
+
import { Direction } from "./enums";
|
|
4
|
+
|
|
5
|
+
import { calcLineCache } from "./segment";
|
|
6
|
+
|
|
7
|
+
import { LineCurve } from "./segment/curve/line";
|
|
8
|
+
|
|
9
|
+
export function getAreaPointRuns(points, connectedType, startPoint) {
|
|
10
|
+
const runs = [];
|
|
11
|
+
if (!points.some((p => !1 === p.defined))) {
|
|
12
|
+
const run = startPoint ? [ startPoint, ...points ] : points;
|
|
13
|
+
return run.length && runs.push(run), {
|
|
14
|
+
runs: runs,
|
|
15
|
+
tail: run[run.length - 1]
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
let run = startPoint ? [ startPoint ] : [];
|
|
19
|
+
for (let i = 0; i < points.length; i++) {
|
|
20
|
+
const point = points[i];
|
|
21
|
+
!1 !== point.defined ? run.push(point) : "connect" !== connectedType && (run.length && runs.push(run),
|
|
22
|
+
run = []);
|
|
23
|
+
}
|
|
24
|
+
return run.length && runs.push(run), {
|
|
25
|
+
runs: runs,
|
|
26
|
+
tail: run[run.length - 1]
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function joinAreaPaths(paths) {
|
|
31
|
+
var _a;
|
|
32
|
+
if (1 === paths.length) return paths[0];
|
|
33
|
+
const curves = [];
|
|
34
|
+
for (let i = 0; i < paths.length; i++) {
|
|
35
|
+
const next = paths[i].curves;
|
|
36
|
+
if (curves.length) {
|
|
37
|
+
const previous = curves[curves.length - 1], gap = new LineCurve(null !== (_a = previous.p3) && void 0 !== _a ? _a : previous.p1, next[0].p0);
|
|
38
|
+
gap.defined = !1, gap.originP1 = previous.originP2, gap.originP2 = next[0].originP1,
|
|
39
|
+
curves.push(gap);
|
|
40
|
+
}
|
|
41
|
+
for (let j = 0; j < next.length; j++) curves.push(next[j]);
|
|
42
|
+
}
|
|
43
|
+
const path = paths[paths.length - 1];
|
|
44
|
+
return path.curves = curves, path.length = NaN, path;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function compileAreaRuns(runs, curveType, curveTension, sourceSegmentIndex, topStart, bottomStart) {
|
|
48
|
+
var _a, _b, _c, _d;
|
|
49
|
+
const tops = [], bottoms = [], bottomType = "stepBefore" === curveType ? "stepAfter" : "stepAfter" === curveType ? "stepBefore" : curveType;
|
|
50
|
+
for (let i = 0; i < runs.length; i++) {
|
|
51
|
+
const points = runs[i], startPoint = 0 === i ? topStart : void 0;
|
|
52
|
+
if (points.length < 2 - Number(!!startPoint)) continue;
|
|
53
|
+
const bottomPoints = [];
|
|
54
|
+
for (let j = points.length - 1; j >= 0; j--) {
|
|
55
|
+
const p = points[j];
|
|
56
|
+
bottomPoints.push({
|
|
57
|
+
x: null !== (_a = p.x1) && void 0 !== _a ? _a : p.x,
|
|
58
|
+
y: null !== (_b = p.y1) && void 0 !== _b ? _b : p.y
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
0 === i && bottomStart && bottomPoints.push({
|
|
62
|
+
x: null !== (_c = bottomStart.x1) && void 0 !== _c ? _c : bottomStart.x,
|
|
63
|
+
y: null !== (_d = bottomStart.y1) && void 0 !== _d ? _d : bottomStart.y
|
|
64
|
+
});
|
|
65
|
+
const top = calcLineCache(points, curveType, {
|
|
66
|
+
startPoint: startPoint,
|
|
67
|
+
curveTension: curveTension
|
|
68
|
+
}), bottom = calcLineCache(bottomPoints, bottomType, {
|
|
69
|
+
curveTension: curveTension
|
|
70
|
+
});
|
|
71
|
+
(null == top ? void 0 : top.curves.length) && (null == bottom ? void 0 : bottom.curves.length) && (tops.push(top),
|
|
72
|
+
bottoms.push(bottom));
|
|
73
|
+
}
|
|
74
|
+
return tops.length ? {
|
|
75
|
+
top: joinAreaPaths(tops),
|
|
76
|
+
bottom: joinAreaPaths(bottoms.reverse()),
|
|
77
|
+
sourceSegmentIndex: sourceSegmentIndex,
|
|
78
|
+
direction: Direction.ROW
|
|
79
|
+
} : null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function calcAreaCache(points, segments, curveType, connectedType, curveTension) {
|
|
83
|
+
var _a;
|
|
84
|
+
const caches = [];
|
|
85
|
+
let tail, topTail, first, last;
|
|
86
|
+
const count = segments ? segments.length : 1;
|
|
87
|
+
for (let i = 0; i < count; i++) {
|
|
88
|
+
const segmentPoints = segments ? segments[i].points : null != points ? points : [], result = getAreaPointRuns(segmentPoints, connectedType), canContinue = "connect" === connectedType || !1 !== (null === (_a = segmentPoints[0]) || void 0 === _a ? void 0 : _a.defined);
|
|
89
|
+
if (result.runs.length) {
|
|
90
|
+
first = null != first ? first : result.runs[0][0];
|
|
91
|
+
const lastRun = result.runs[result.runs.length - 1];
|
|
92
|
+
last = lastRun[lastRun.length - 1];
|
|
93
|
+
}
|
|
94
|
+
const cache = compileAreaRuns(result.runs, curveType, curveTension, i, canContinue ? topTail : void 0, canContinue ? tail : void 0);
|
|
95
|
+
if (cache && caches.push(cache), result.tail) {
|
|
96
|
+
tail = result.tail;
|
|
97
|
+
const lastRun = result.runs[result.runs.length - 1];
|
|
98
|
+
topTail = cache && (1 === result.runs.length || lastRun.length > 1) ? {
|
|
99
|
+
x: cache.top.endX,
|
|
100
|
+
y: cache.top.endY
|
|
101
|
+
} : tail;
|
|
102
|
+
} else "connect" !== connectedType && segmentPoints.length && (tail = topTail = void 0);
|
|
103
|
+
}
|
|
104
|
+
if (!caches.length) return null;
|
|
105
|
+
let direction = Direction.ROW;
|
|
106
|
+
if (null != last.x1) {
|
|
107
|
+
const dx = abs(last.x - first.x), dy = abs(last.y - first.y);
|
|
108
|
+
(null == last.y1 || Number.isFinite(dx + dy) && dy >= dx) && (direction = Direction.COLUMN);
|
|
109
|
+
}
|
|
110
|
+
for (let i = 0; i < caches.length; i++) caches[i].direction = direction;
|
|
111
|
+
return segments ? caches : caches[0];
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=area-cache.js.map
|