@visactor/vrender 0.13.7 → 0.14.0-alpha.1
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/canvas/contributions/browser/context.d.ts +1 -0
- package/cjs/common/render-area.d.ts +4 -0
- package/cjs/common/render-area.js +31 -6
- package/cjs/common/render-area.js.map +1 -1
- package/cjs/common/render-curve.d.ts +4 -0
- package/cjs/common/render-curve.js +18 -5
- package/cjs/common/render-curve.js.map +1 -1
- package/cjs/core/contributions/textMeasure/AtextMeasure.d.ts +24 -0
- package/cjs/core/contributions/textMeasure/AtextMeasure.js +42 -0
- package/cjs/core/contributions/textMeasure/AtextMeasure.js.map +1 -1
- package/cjs/graphic/config.d.ts +2 -1
- package/cjs/graphic/config.js +11 -5
- package/cjs/graphic/config.js.map +1 -1
- package/cjs/graphic/text.d.ts +5 -1
- package/cjs/graphic/text.js +94 -2
- package/cjs/graphic/text.js.map +1 -1
- package/cjs/graphic/tools.d.ts +8 -0
- package/cjs/graphic/tools.js +38 -2
- package/cjs/graphic/tools.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/interface/graphic/area.d.ts +3 -3
- package/cjs/interface/graphic/area.js.map +1 -1
- package/cjs/interface/graphic/line.d.ts +3 -3
- package/cjs/interface/graphic/line.js.map +1 -1
- package/cjs/interface/graphic/text.d.ts +6 -0
- package/cjs/interface/graphic/text.js.map +1 -1
- package/cjs/interface/graphic.d.ts +16 -0
- package/cjs/interface/graphic.js.map +1 -1
- package/cjs/interface/text.d.ts +24 -0
- package/cjs/interface/text.js.map +1 -1
- package/cjs/render/contributions/render/area-render.d.ts +1 -0
- package/cjs/render/contributions/render/area-render.js +31 -5
- package/cjs/render/contributions/render/area-render.js.map +1 -1
- package/cjs/render/contributions/render/line-render.js +28 -3
- package/cjs/render/contributions/render/line-render.js.map +1 -1
- package/cjs/render/contributions/render/text-render.js +62 -13
- package/cjs/render/contributions/render/text-render.js.map +1 -1
- package/dist/index.js +631 -82
- package/dist/index.min.js +1 -1
- package/es/canvas/contributions/browser/context.d.ts +1 -0
- package/es/common/render-area.d.ts +4 -0
- package/es/common/render-area.js +31 -6
- package/es/common/render-area.js.map +1 -1
- package/es/common/render-curve.d.ts +4 -0
- package/es/common/render-curve.js +18 -5
- package/es/common/render-curve.js.map +1 -1
- package/es/core/contributions/textMeasure/AtextMeasure.d.ts +24 -0
- package/es/core/contributions/textMeasure/AtextMeasure.js +42 -0
- package/es/core/contributions/textMeasure/AtextMeasure.js.map +1 -1
- package/es/graphic/config.d.ts +2 -1
- package/es/graphic/config.js +11 -3
- package/es/graphic/config.js.map +1 -1
- package/es/graphic/text.d.ts +5 -1
- package/es/graphic/text.js +95 -1
- package/es/graphic/text.js.map +1 -1
- package/es/graphic/tools.d.ts +8 -0
- package/es/graphic/tools.js +38 -0
- package/es/graphic/tools.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/interface/graphic/area.d.ts +3 -3
- package/es/interface/graphic/area.js.map +1 -1
- package/es/interface/graphic/line.d.ts +3 -3
- package/es/interface/graphic/line.js.map +1 -1
- package/es/interface/graphic/text.d.ts +6 -0
- package/es/interface/graphic/text.js.map +1 -1
- package/es/interface/graphic.d.ts +16 -0
- package/es/interface/graphic.js.map +1 -1
- package/es/interface/text.d.ts +24 -0
- package/es/interface/text.js.map +1 -1
- package/es/render/contributions/render/area-render.d.ts +1 -0
- package/es/render/contributions/render/area-render.js +31 -5
- package/es/render/contributions/render/area-render.js.map +1 -1
- package/es/render/contributions/render/line-render.js +28 -3
- package/es/render/contributions/render/line-render.js.map +1 -1
- package/es/render/contributions/render/text-render.js +65 -12
- package/es/render/contributions/render/text-render.js.map +1 -1
- package/es/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9287,7 +9287,8 @@
|
|
|
9287
9287
|
lineHeight: undefined,
|
|
9288
9288
|
underline: 0,
|
|
9289
9289
|
lineThrough: 0,
|
|
9290
|
-
scaleIn3d: false
|
|
9290
|
+
scaleIn3d: false,
|
|
9291
|
+
direction: 'horizontal'
|
|
9291
9292
|
};
|
|
9292
9293
|
const DefaultStyle = {
|
|
9293
9294
|
opacity: 1,
|
|
@@ -9302,6 +9303,12 @@
|
|
|
9302
9303
|
...DefaultFillStyle,
|
|
9303
9304
|
...DefaultStrokeStyle
|
|
9304
9305
|
};
|
|
9306
|
+
const DefaultConnectAttribute = {
|
|
9307
|
+
connectedType: 'none',
|
|
9308
|
+
connectedStyle: {},
|
|
9309
|
+
connectedX: NaN,
|
|
9310
|
+
connectedY: NaN
|
|
9311
|
+
};
|
|
9305
9312
|
const DefaultAttribute = {
|
|
9306
9313
|
strokeSeg: null,
|
|
9307
9314
|
pickable: true,
|
|
@@ -9339,6 +9346,7 @@
|
|
|
9339
9346
|
};
|
|
9340
9347
|
const DefaultAreaAttribute = {
|
|
9341
9348
|
...DefaultAttribute,
|
|
9349
|
+
...DefaultConnectAttribute,
|
|
9342
9350
|
points: [],
|
|
9343
9351
|
segments: [],
|
|
9344
9352
|
curveType: 'linear',
|
|
@@ -9369,6 +9377,7 @@
|
|
|
9369
9377
|
};
|
|
9370
9378
|
const DefaultLineAttribute = {
|
|
9371
9379
|
...DefaultAttribute,
|
|
9380
|
+
...DefaultConnectAttribute,
|
|
9372
9381
|
points: [],
|
|
9373
9382
|
segments: [],
|
|
9374
9383
|
curveType: 'linear',
|
|
@@ -9508,6 +9517,36 @@
|
|
|
9508
9517
|
this.context.setTextStyleWithoutAlignBaseline(options);
|
|
9509
9518
|
return this.context.measureText(text);
|
|
9510
9519
|
}
|
|
9520
|
+
clipTextVertical(verticalList, options, width) {
|
|
9521
|
+
if (verticalList.length === 0) {
|
|
9522
|
+
return { verticalList, width: 0 };
|
|
9523
|
+
}
|
|
9524
|
+
const { fontSize = 12 } = options;
|
|
9525
|
+
verticalList.forEach(item => {
|
|
9526
|
+
item.width = item.direction === 0 ? fontSize : this.measureTextWidth(item.text, options);
|
|
9527
|
+
});
|
|
9528
|
+
const out = [];
|
|
9529
|
+
let length = 0;
|
|
9530
|
+
let i = 0;
|
|
9531
|
+
for (; i < verticalList.length; i++) {
|
|
9532
|
+
if (length + verticalList[i].width < width) {
|
|
9533
|
+
length += verticalList[i].width;
|
|
9534
|
+
out.push(verticalList[i]);
|
|
9535
|
+
}
|
|
9536
|
+
else {
|
|
9537
|
+
break;
|
|
9538
|
+
}
|
|
9539
|
+
}
|
|
9540
|
+
if (verticalList[i] && verticalList[i].text.length > 1) {
|
|
9541
|
+
const clipedData = this._clipText(verticalList[i].text, options, width - length, 0, verticalList[i].text.length - 1);
|
|
9542
|
+
out.push({ ...verticalList[i], text: clipedData.str });
|
|
9543
|
+
length += clipedData.width;
|
|
9544
|
+
}
|
|
9545
|
+
return {
|
|
9546
|
+
verticalList: out,
|
|
9547
|
+
width: length
|
|
9548
|
+
};
|
|
9549
|
+
}
|
|
9511
9550
|
clipText(text, options, width) {
|
|
9512
9551
|
if (text.length === 0) {
|
|
9513
9552
|
return { str: '', width: 0 };
|
|
@@ -9551,6 +9590,32 @@
|
|
|
9551
9590
|
}
|
|
9552
9591
|
return { str: subText, width: strWidth };
|
|
9553
9592
|
}
|
|
9593
|
+
clipTextWithSuffixVertical(verticalList, options, width, suffix) {
|
|
9594
|
+
if (suffix === '') {
|
|
9595
|
+
return this.clipTextVertical(verticalList, options, width);
|
|
9596
|
+
}
|
|
9597
|
+
if (verticalList.length === 0) {
|
|
9598
|
+
return { verticalList, width: 0 };
|
|
9599
|
+
}
|
|
9600
|
+
const output = this.clipTextVertical(verticalList, options, width);
|
|
9601
|
+
if (output.verticalList.length === verticalList.length &&
|
|
9602
|
+
output.verticalList[output.verticalList.length - 1].width === verticalList[verticalList.length - 1].width) {
|
|
9603
|
+
return output;
|
|
9604
|
+
}
|
|
9605
|
+
const suffixWidth = this.measureTextWidth(suffix, options);
|
|
9606
|
+
if (suffixWidth > width) {
|
|
9607
|
+
return output;
|
|
9608
|
+
}
|
|
9609
|
+
width -= suffixWidth;
|
|
9610
|
+
const out = this.clipTextVertical(verticalList, options, width);
|
|
9611
|
+
out.width += suffixWidth;
|
|
9612
|
+
out.verticalList.push({
|
|
9613
|
+
text: suffix,
|
|
9614
|
+
direction: 1,
|
|
9615
|
+
width: suffixWidth
|
|
9616
|
+
});
|
|
9617
|
+
return out;
|
|
9618
|
+
}
|
|
9554
9619
|
clipTextWithSuffix(text, options, width, suffix) {
|
|
9555
9620
|
if (suffix === '') {
|
|
9556
9621
|
return this.clipText(text, options, width);
|
|
@@ -17877,6 +17942,68 @@
|
|
|
17877
17942
|
function genNumberType() {
|
|
17878
17943
|
return NUMBER_TYPE++;
|
|
17879
17944
|
}
|
|
17945
|
+
exports.TextDirection = void 0;
|
|
17946
|
+
(function (TextDirection) {
|
|
17947
|
+
TextDirection[TextDirection["HORIZONTAL"] = 0] = "HORIZONTAL";
|
|
17948
|
+
TextDirection[TextDirection["VERTICAL"] = 1] = "VERTICAL";
|
|
17949
|
+
})(exports.TextDirection || (exports.TextDirection = {}));
|
|
17950
|
+
function verticalLayout(text) {
|
|
17951
|
+
const nextCharacter = [];
|
|
17952
|
+
let flag = 0;
|
|
17953
|
+
let currStr = '';
|
|
17954
|
+
for (let i = 0; i < text.length; i++) {
|
|
17955
|
+
if (rotateText(text[i])) {
|
|
17956
|
+
if (flag) {
|
|
17957
|
+
currStr += text[i];
|
|
17958
|
+
}
|
|
17959
|
+
else {
|
|
17960
|
+
flag = 1;
|
|
17961
|
+
currStr = text[i];
|
|
17962
|
+
}
|
|
17963
|
+
}
|
|
17964
|
+
else {
|
|
17965
|
+
if (flag) {
|
|
17966
|
+
nextCharacter.push({
|
|
17967
|
+
text: currStr,
|
|
17968
|
+
direction: exports.TextDirection.VERTICAL
|
|
17969
|
+
});
|
|
17970
|
+
currStr = '';
|
|
17971
|
+
flag = 0;
|
|
17972
|
+
}
|
|
17973
|
+
nextCharacter.push({
|
|
17974
|
+
text: text[i],
|
|
17975
|
+
direction: exports.TextDirection.HORIZONTAL
|
|
17976
|
+
});
|
|
17977
|
+
}
|
|
17978
|
+
}
|
|
17979
|
+
if (currStr) {
|
|
17980
|
+
nextCharacter.push({
|
|
17981
|
+
text: currStr,
|
|
17982
|
+
direction: exports.TextDirection.VERTICAL
|
|
17983
|
+
});
|
|
17984
|
+
}
|
|
17985
|
+
return nextCharacter;
|
|
17986
|
+
}
|
|
17987
|
+
const rotateCharList = ['…', '(', ')', '—', '【', '】', '「', '」', '《', '》'];
|
|
17988
|
+
const rotateCharMap = new Map();
|
|
17989
|
+
rotateCharList.forEach(c => rotateCharMap.set(c, true));
|
|
17990
|
+
const noRotateCharList = [''];
|
|
17991
|
+
const noRotateCharMap = new Map();
|
|
17992
|
+
noRotateCharList.forEach(c => noRotateCharMap.set(c, true));
|
|
17993
|
+
function rotateText(c) {
|
|
17994
|
+
if (rotateCharMap.has(c)) {
|
|
17995
|
+
return true;
|
|
17996
|
+
}
|
|
17997
|
+
if (noRotateCharMap.has(c)) {
|
|
17998
|
+
return false;
|
|
17999
|
+
}
|
|
18000
|
+
const cp = c.codePointAt(0);
|
|
18001
|
+
let rotate = false;
|
|
18002
|
+
if (cp < 256) {
|
|
18003
|
+
rotate = true;
|
|
18004
|
+
}
|
|
18005
|
+
return rotate;
|
|
18006
|
+
}
|
|
17880
18007
|
|
|
17881
18008
|
const ARC_NUMBER_TYPE = genNumberType();
|
|
17882
18009
|
const ARC3D_NUMBER_TYPE = genNumberType();
|
|
@@ -19724,6 +19851,20 @@
|
|
|
19724
19851
|
return bounds;
|
|
19725
19852
|
}
|
|
19726
19853
|
updateSingallineAABBBounds(text) {
|
|
19854
|
+
const textTheme = getTheme(this).text;
|
|
19855
|
+
const { direction = textTheme.direction } = this.attribute;
|
|
19856
|
+
return direction === 'horizontal'
|
|
19857
|
+
? this.updateHorizontalSinglelineAABBBounds(text)
|
|
19858
|
+
: this.updateVerticalSinglelineAABBBounds(text);
|
|
19859
|
+
}
|
|
19860
|
+
updateMultilineAABBBounds(text) {
|
|
19861
|
+
const textTheme = getTheme(this).text;
|
|
19862
|
+
const { direction = textTheme.direction } = this.attribute;
|
|
19863
|
+
return direction === 'horizontal'
|
|
19864
|
+
? this.updateHorizontalMultilineAABBBounds(text)
|
|
19865
|
+
: this.updateVerticalMultilineAABBBounds(text);
|
|
19866
|
+
}
|
|
19867
|
+
updateHorizontalSinglelineAABBBounds(text) {
|
|
19727
19868
|
const textTheme = getTheme(this).text;
|
|
19728
19869
|
const textMeasure = application.graphicUtil.textMeasure;
|
|
19729
19870
|
let width;
|
|
@@ -19770,7 +19911,63 @@
|
|
|
19770
19911
|
}
|
|
19771
19912
|
return this._AABBBounds;
|
|
19772
19913
|
}
|
|
19773
|
-
|
|
19914
|
+
updateVerticalSinglelineAABBBounds(text) {
|
|
19915
|
+
const textTheme = getTheme(this).text;
|
|
19916
|
+
const textMeasure = application.graphicUtil.textMeasure;
|
|
19917
|
+
let width;
|
|
19918
|
+
const buf = 2;
|
|
19919
|
+
const attribute = this.attribute;
|
|
19920
|
+
const { maxLineWidth = textTheme.maxLineWidth, ellipsis = textTheme.ellipsis, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, stroke = textTheme.stroke, lineHeight = attribute.lineHeight ?? (attribute.fontSize || textTheme.fontSize) + buf, lineWidth = textTheme.lineWidth } = attribute;
|
|
19921
|
+
if (!this.shouldUpdateShape() && this.cache) {
|
|
19922
|
+
width = this.cache.clipedWidth;
|
|
19923
|
+
const dx = textDrawOffsetX(textAlign, width);
|
|
19924
|
+
const dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
|
|
19925
|
+
this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width);
|
|
19926
|
+
if (stroke) {
|
|
19927
|
+
this._AABBBounds.expand(lineWidth / 2);
|
|
19928
|
+
}
|
|
19929
|
+
return this._AABBBounds;
|
|
19930
|
+
}
|
|
19931
|
+
let verticalList = [
|
|
19932
|
+
verticalLayout(text.toString())
|
|
19933
|
+
];
|
|
19934
|
+
if (Number.isFinite(maxLineWidth)) {
|
|
19935
|
+
if (ellipsis) {
|
|
19936
|
+
const strEllipsis = (ellipsis === true ? textTheme.ellipsis : ellipsis);
|
|
19937
|
+
const data = textMeasure.clipTextWithSuffixVertical(verticalList[0], { fontSize, fontWeight }, maxLineWidth, strEllipsis);
|
|
19938
|
+
verticalList = [data.verticalList];
|
|
19939
|
+
width = data.width;
|
|
19940
|
+
}
|
|
19941
|
+
else {
|
|
19942
|
+
const data = textMeasure.clipTextVertical(verticalList[0], { fontSize, fontWeight }, maxLineWidth);
|
|
19943
|
+
verticalList = [data.verticalList];
|
|
19944
|
+
width = data.width;
|
|
19945
|
+
}
|
|
19946
|
+
this.cache.verticalList = verticalList;
|
|
19947
|
+
this.cache.clipedWidth = width;
|
|
19948
|
+
}
|
|
19949
|
+
else {
|
|
19950
|
+
width = 0;
|
|
19951
|
+
verticalList[0].forEach(t => {
|
|
19952
|
+
const w = t.direction === exports.TextDirection.HORIZONTAL
|
|
19953
|
+
? fontSize
|
|
19954
|
+
: textMeasure.measureTextWidth(t.text, { fontSize, fontWeight });
|
|
19955
|
+
width += w;
|
|
19956
|
+
t.width = w;
|
|
19957
|
+
});
|
|
19958
|
+
this.cache.verticalList = verticalList;
|
|
19959
|
+
this.cache.clipedWidth = width;
|
|
19960
|
+
}
|
|
19961
|
+
this.clearUpdateShapeTag();
|
|
19962
|
+
const dx = textDrawOffsetX(textAlign, width);
|
|
19963
|
+
const dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
|
|
19964
|
+
this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width);
|
|
19965
|
+
if (stroke) {
|
|
19966
|
+
this._AABBBounds.expand(lineWidth / 2);
|
|
19967
|
+
}
|
|
19968
|
+
return this._AABBBounds;
|
|
19969
|
+
}
|
|
19970
|
+
updateHorizontalMultilineAABBBounds(text) {
|
|
19774
19971
|
const textTheme = getTheme(this).text;
|
|
19775
19972
|
const attribute = this.attribute;
|
|
19776
19973
|
const { fontFamily = textTheme.fontFamily, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, lineHeight = attribute.lineHeight || attribute.fontSize || textTheme.fontSize, ellipsis = textTheme.ellipsis, maxLineWidth, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth } = attribute;
|
|
@@ -19794,6 +19991,71 @@
|
|
|
19794
19991
|
}
|
|
19795
19992
|
return this._AABBBounds;
|
|
19796
19993
|
}
|
|
19994
|
+
updateVerticalMultilineAABBBounds(text) {
|
|
19995
|
+
const textTheme = getTheme(this).text;
|
|
19996
|
+
const textMeasure = application.graphicUtil.textMeasure;
|
|
19997
|
+
let width;
|
|
19998
|
+
const buf = 2;
|
|
19999
|
+
const attribute = this.attribute;
|
|
20000
|
+
const { maxLineWidth = textTheme.maxLineWidth, ellipsis = textTheme.ellipsis, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, stroke = textTheme.stroke, lineHeight = attribute.lineHeight ?? (attribute.fontSize || textTheme.fontSize) + buf, lineWidth = textTheme.lineWidth } = attribute;
|
|
20001
|
+
width = 0;
|
|
20002
|
+
if (!this.shouldUpdateShape() && this.cache) {
|
|
20003
|
+
this.cache.verticalList.forEach(item => {
|
|
20004
|
+
const w = item.reduce((a, b) => a + b.width, 0);
|
|
20005
|
+
width = max(w, width);
|
|
20006
|
+
});
|
|
20007
|
+
const dx = textDrawOffsetX(textAlign, width);
|
|
20008
|
+
const height = this.cache.verticalList.length * lineHeight;
|
|
20009
|
+
const dy = textLayoutOffsetY(textBaseline, height, fontSize);
|
|
20010
|
+
this._AABBBounds.set(dy, dx, dy + height, dx + width);
|
|
20011
|
+
if (stroke) {
|
|
20012
|
+
this._AABBBounds.expand(lineWidth / 2);
|
|
20013
|
+
}
|
|
20014
|
+
return this._AABBBounds;
|
|
20015
|
+
}
|
|
20016
|
+
const verticalLists = text.map(str => {
|
|
20017
|
+
return verticalLayout(str.toString());
|
|
20018
|
+
});
|
|
20019
|
+
verticalLists.forEach((verticalData, i) => {
|
|
20020
|
+
if (Number.isFinite(maxLineWidth)) {
|
|
20021
|
+
if (ellipsis) {
|
|
20022
|
+
const strEllipsis = (ellipsis === true ? textTheme.ellipsis : ellipsis);
|
|
20023
|
+
const data = textMeasure.clipTextWithSuffixVertical(verticalData, { fontSize, fontWeight }, maxLineWidth, strEllipsis);
|
|
20024
|
+
verticalLists[i] = data.verticalList;
|
|
20025
|
+
width = data.width;
|
|
20026
|
+
}
|
|
20027
|
+
else {
|
|
20028
|
+
const data = textMeasure.clipTextVertical(verticalData, { fontSize, fontWeight }, maxLineWidth);
|
|
20029
|
+
verticalLists[i] = data.verticalList;
|
|
20030
|
+
width = data.width;
|
|
20031
|
+
}
|
|
20032
|
+
}
|
|
20033
|
+
else {
|
|
20034
|
+
width = 0;
|
|
20035
|
+
verticalData.forEach(t => {
|
|
20036
|
+
const w = t.direction === exports.TextDirection.HORIZONTAL
|
|
20037
|
+
? fontSize
|
|
20038
|
+
: textMeasure.measureTextWidth(t.text, { fontSize, fontWeight });
|
|
20039
|
+
width += w;
|
|
20040
|
+
t.width = w;
|
|
20041
|
+
});
|
|
20042
|
+
}
|
|
20043
|
+
});
|
|
20044
|
+
this.cache.verticalList = verticalLists;
|
|
20045
|
+
this.clearUpdateShapeTag();
|
|
20046
|
+
this.cache.verticalList.forEach(item => {
|
|
20047
|
+
const w = item.reduce((a, b) => a + b.width, 0);
|
|
20048
|
+
width = max(w, width);
|
|
20049
|
+
});
|
|
20050
|
+
const dx = textDrawOffsetX(textAlign, width);
|
|
20051
|
+
const height = this.cache.verticalList.length * lineHeight;
|
|
20052
|
+
const dy = textLayoutOffsetY(textBaseline, height, fontSize);
|
|
20053
|
+
this._AABBBounds.set(dy, dx, dy + height, dx + width);
|
|
20054
|
+
if (stroke) {
|
|
20055
|
+
this._AABBBounds.expand(lineWidth / 2);
|
|
20056
|
+
}
|
|
20057
|
+
return this._AABBBounds;
|
|
20058
|
+
}
|
|
19797
20059
|
tryUpdateOBBBounds() {
|
|
19798
20060
|
throw new Error('暂不支持');
|
|
19799
20061
|
}
|
|
@@ -24400,24 +24662,50 @@
|
|
|
24400
24662
|
], exports.BaseRender);
|
|
24401
24663
|
|
|
24402
24664
|
function drawSegments(path, segPath, percent, clipRangeByDimension, params) {
|
|
24665
|
+
const { offsetX = 0, offsetY = 0, offsetZ = 0, mode = 'none', drawConnect = false, zeroX = 0, zeroY = 0 } = params || {};
|
|
24666
|
+
if (drawConnect && mode === 'none') {
|
|
24667
|
+
return;
|
|
24668
|
+
}
|
|
24403
24669
|
if (!segPath) {
|
|
24404
24670
|
return;
|
|
24405
24671
|
}
|
|
24406
|
-
const { offsetX = 0, offsetY = 0, offsetZ = 0 } = params || {};
|
|
24407
24672
|
let needMoveTo = true;
|
|
24408
24673
|
const { curves } = segPath;
|
|
24409
24674
|
if (percent >= 1) {
|
|
24410
|
-
|
|
24411
|
-
|
|
24412
|
-
|
|
24413
|
-
|
|
24414
|
-
|
|
24415
|
-
|
|
24416
|
-
|
|
24417
|
-
|
|
24418
|
-
|
|
24419
|
-
|
|
24420
|
-
|
|
24675
|
+
if (drawConnect) {
|
|
24676
|
+
curves.forEach((curve, i) => {
|
|
24677
|
+
if (curve.defined) {
|
|
24678
|
+
if (needMoveTo && i !== 0) {
|
|
24679
|
+
path.lineTo(curve.p0.x + offsetX, curve.p0.y + offsetY, offsetZ);
|
|
24680
|
+
}
|
|
24681
|
+
needMoveTo = false;
|
|
24682
|
+
}
|
|
24683
|
+
else {
|
|
24684
|
+
if (!needMoveTo) {
|
|
24685
|
+
path.moveTo(curve.p0.x + offsetX, curve.p0.y + offsetY, offsetZ);
|
|
24686
|
+
}
|
|
24687
|
+
else {
|
|
24688
|
+
if (mode === 'zero') {
|
|
24689
|
+
path.lineTo((isFinite(zeroX) ? zeroX : curve.p0.x) + offsetX, (isFinite(zeroY) ? zeroY : curve.p0.y) + offsetY, offsetZ);
|
|
24690
|
+
}
|
|
24691
|
+
}
|
|
24692
|
+
needMoveTo = true;
|
|
24693
|
+
}
|
|
24694
|
+
});
|
|
24695
|
+
}
|
|
24696
|
+
else {
|
|
24697
|
+
curves.forEach(curve => {
|
|
24698
|
+
if (!curve.defined) {
|
|
24699
|
+
needMoveTo = true;
|
|
24700
|
+
return;
|
|
24701
|
+
}
|
|
24702
|
+
if (needMoveTo) {
|
|
24703
|
+
path.moveTo(curve.p0.x + offsetX, curve.p0.y + offsetY, offsetZ);
|
|
24704
|
+
}
|
|
24705
|
+
drawSegItem$1(path, curve, 1, params);
|
|
24706
|
+
needMoveTo = false;
|
|
24707
|
+
});
|
|
24708
|
+
}
|
|
24421
24709
|
return;
|
|
24422
24710
|
}
|
|
24423
24711
|
if (percent <= 0) {
|
|
@@ -24444,15 +24732,36 @@
|
|
|
24444
24732
|
if (_p < 0) {
|
|
24445
24733
|
break;
|
|
24446
24734
|
}
|
|
24447
|
-
if (
|
|
24448
|
-
|
|
24449
|
-
|
|
24735
|
+
if (drawConnect) {
|
|
24736
|
+
if (curve.defined) {
|
|
24737
|
+
if (needMoveTo && i !== 0) {
|
|
24738
|
+
path.lineTo(curve.p0.x + offsetX, curve.p0.y + offsetY, offsetZ);
|
|
24739
|
+
}
|
|
24740
|
+
needMoveTo = false;
|
|
24741
|
+
}
|
|
24742
|
+
else {
|
|
24743
|
+
if (!needMoveTo) {
|
|
24744
|
+
path.moveTo(curve.p0.x + offsetX, curve.p0.y + offsetY, offsetZ);
|
|
24745
|
+
}
|
|
24746
|
+
else {
|
|
24747
|
+
if (mode === 'zero') {
|
|
24748
|
+
path.lineTo((isFinite(zeroX) ? zeroX : curve.p0.x) + offsetX, (isFinite(zeroY) ? zeroY : curve.p0.y) + offsetY, offsetZ);
|
|
24749
|
+
}
|
|
24750
|
+
}
|
|
24751
|
+
needMoveTo = true;
|
|
24752
|
+
}
|
|
24450
24753
|
}
|
|
24451
|
-
|
|
24452
|
-
|
|
24754
|
+
else {
|
|
24755
|
+
if (!curve.defined) {
|
|
24756
|
+
needMoveTo = true;
|
|
24757
|
+
continue;
|
|
24758
|
+
}
|
|
24759
|
+
if (needMoveTo) {
|
|
24760
|
+
path.moveTo(curve.p0.x + offsetX, curve.p0.y + offsetY, offsetZ);
|
|
24761
|
+
}
|
|
24762
|
+
drawSegItem$1(path, curve, min(_p, 1), params);
|
|
24763
|
+
needMoveTo = false;
|
|
24453
24764
|
}
|
|
24454
|
-
drawSegItem$1(path, curve, min(_p, 1), params);
|
|
24455
|
-
needMoveTo = false;
|
|
24456
24765
|
}
|
|
24457
24766
|
}
|
|
24458
24767
|
function drawIncrementalSegments(path, lastSeg, segments, params) {
|
|
@@ -24575,6 +24884,60 @@
|
|
|
24575
24884
|
context.stroke();
|
|
24576
24885
|
}
|
|
24577
24886
|
}
|
|
24887
|
+
let { connectedType, connectedX, connectedY, connectedStyle } = attribute;
|
|
24888
|
+
if (isArray(defaultAttribute)) {
|
|
24889
|
+
connectedType = connectedType ?? defaultAttribute[0].connectedType ?? defaultAttribute[1].connectedType;
|
|
24890
|
+
connectedX = connectedX ?? defaultAttribute[0].connectedX ?? defaultAttribute[1].connectedX;
|
|
24891
|
+
connectedY = connectedY ?? defaultAttribute[0].connectedY ?? defaultAttribute[1].connectedY;
|
|
24892
|
+
connectedStyle = connectedStyle ?? defaultAttribute[0].connectedStyle ?? defaultAttribute[1].connectedStyle;
|
|
24893
|
+
}
|
|
24894
|
+
else {
|
|
24895
|
+
connectedType = connectedType ?? defaultAttribute.connectedType;
|
|
24896
|
+
connectedX = connectedX ?? defaultAttribute.connectedX;
|
|
24897
|
+
connectedY = connectedY ?? defaultAttribute.connectedY;
|
|
24898
|
+
connectedStyle = connectedStyle ?? defaultAttribute.connectedStyle;
|
|
24899
|
+
}
|
|
24900
|
+
if (connectedType !== 'connect' && connectedType !== 'zero') {
|
|
24901
|
+
connectedType = 'none';
|
|
24902
|
+
}
|
|
24903
|
+
if (connectedType !== 'none') {
|
|
24904
|
+
context.beginPath();
|
|
24905
|
+
drawSegments(context.camera ? context : context.nativeContext, cache, clipRange, clipRangeByDimension, {
|
|
24906
|
+
offsetX,
|
|
24907
|
+
offsetY,
|
|
24908
|
+
offsetZ: z,
|
|
24909
|
+
drawConnect: true,
|
|
24910
|
+
mode: connectedType,
|
|
24911
|
+
zeroX: connectedX,
|
|
24912
|
+
zeroY: connectedY
|
|
24913
|
+
});
|
|
24914
|
+
const da = [];
|
|
24915
|
+
if (isArray(defaultAttribute)) {
|
|
24916
|
+
defaultAttribute.forEach(i => da.push(i));
|
|
24917
|
+
}
|
|
24918
|
+
else {
|
|
24919
|
+
da.push(defaultAttribute);
|
|
24920
|
+
}
|
|
24921
|
+
da.push(attribute);
|
|
24922
|
+
if (fill !== false) {
|
|
24923
|
+
if (fillCb) {
|
|
24924
|
+
fillCb(context, attribute, defaultAttribute);
|
|
24925
|
+
}
|
|
24926
|
+
else if (fillOpacity) {
|
|
24927
|
+
context.setCommonStyle(line, connectedStyle, originX - offsetX, originY - offsetY, da);
|
|
24928
|
+
context.fill();
|
|
24929
|
+
}
|
|
24930
|
+
}
|
|
24931
|
+
if (stroke !== false) {
|
|
24932
|
+
if (strokeCb) {
|
|
24933
|
+
strokeCb(context, attribute, defaultAttribute);
|
|
24934
|
+
}
|
|
24935
|
+
else if (strokeOpacity) {
|
|
24936
|
+
context.setStrokeStyle(line, connectedStyle, originX - offsetX, originY - offsetY, da);
|
|
24937
|
+
context.stroke();
|
|
24938
|
+
}
|
|
24939
|
+
}
|
|
24940
|
+
}
|
|
24578
24941
|
return !!ret;
|
|
24579
24942
|
}
|
|
24580
24943
|
drawShape(line, context, x, y, drawContext, params, fillCb, strokeCb) {
|
|
@@ -24667,33 +25030,63 @@
|
|
|
24667
25030
|
], exports.DefaultCanvasLineRender);
|
|
24668
25031
|
|
|
24669
25032
|
function drawAreaSegments(path, segPath, percent, params) {
|
|
25033
|
+
const { drawConnect = false, mode = 'none' } = params || {};
|
|
25034
|
+
if (drawConnect && mode === 'none') {
|
|
25035
|
+
return;
|
|
25036
|
+
}
|
|
24670
25037
|
const { top, bottom } = segPath;
|
|
24671
25038
|
if (percent >= 1) {
|
|
24672
25039
|
const topList = [];
|
|
24673
25040
|
const bottomList = [];
|
|
24674
25041
|
let lastDefined = true;
|
|
24675
|
-
|
|
24676
|
-
|
|
24677
|
-
|
|
24678
|
-
if (lastDefined) {
|
|
24679
|
-
|
|
24680
|
-
|
|
24681
|
-
|
|
25042
|
+
if (drawConnect) {
|
|
25043
|
+
for (let i = 0, n = top.curves.length; i < n; i++) {
|
|
25044
|
+
const topCurve = top.curves[i];
|
|
25045
|
+
if (lastDefined !== topCurve.defined) {
|
|
25046
|
+
if (!lastDefined) {
|
|
25047
|
+
drawAreaConnectBlock(path, topList, bottomList, params);
|
|
25048
|
+
topList.length = 0;
|
|
25049
|
+
bottomList.length = 0;
|
|
25050
|
+
}
|
|
25051
|
+
else {
|
|
25052
|
+
topList.push(topCurve);
|
|
25053
|
+
bottomList.push(bottom.curves[n - i - 1]);
|
|
25054
|
+
}
|
|
25055
|
+
lastDefined = !lastDefined;
|
|
24682
25056
|
}
|
|
24683
25057
|
else {
|
|
24684
|
-
|
|
24685
|
-
|
|
25058
|
+
if (!lastDefined) {
|
|
25059
|
+
topList.push(topCurve);
|
|
25060
|
+
bottomList.push(bottom.curves[n - i - 1]);
|
|
25061
|
+
}
|
|
24686
25062
|
}
|
|
24687
|
-
lastDefined = !lastDefined;
|
|
24688
25063
|
}
|
|
24689
|
-
|
|
24690
|
-
|
|
24691
|
-
|
|
24692
|
-
|
|
25064
|
+
drawAreaBlock(path, topList, bottomList, params);
|
|
25065
|
+
}
|
|
25066
|
+
else {
|
|
25067
|
+
for (let i = 0, n = top.curves.length; i < n; i++) {
|
|
25068
|
+
const topCurve = top.curves[i];
|
|
25069
|
+
if (lastDefined !== topCurve.defined) {
|
|
25070
|
+
if (lastDefined) {
|
|
25071
|
+
drawAreaBlock(path, topList, bottomList, params);
|
|
25072
|
+
topList.length = 0;
|
|
25073
|
+
bottomList.length = 0;
|
|
25074
|
+
}
|
|
25075
|
+
else {
|
|
25076
|
+
topList.push(topCurve);
|
|
25077
|
+
bottomList.push(bottom.curves[n - i - 1]);
|
|
25078
|
+
}
|
|
25079
|
+
lastDefined = !lastDefined;
|
|
25080
|
+
}
|
|
25081
|
+
else {
|
|
25082
|
+
if (lastDefined) {
|
|
25083
|
+
topList.push(topCurve);
|
|
25084
|
+
bottomList.push(bottom.curves[n - i - 1]);
|
|
25085
|
+
}
|
|
24693
25086
|
}
|
|
24694
25087
|
}
|
|
25088
|
+
drawAreaBlock(path, topList, bottomList, params);
|
|
24695
25089
|
}
|
|
24696
|
-
drawAreaBlock(path, topList, bottomList, params);
|
|
24697
25090
|
return;
|
|
24698
25091
|
}
|
|
24699
25092
|
if (percent <= 0) {
|
|
@@ -24770,6 +25163,23 @@
|
|
|
24770
25163
|
}
|
|
24771
25164
|
drawAreaBlock(path, topList, bottomList, params);
|
|
24772
25165
|
}
|
|
25166
|
+
function drawAreaConnectBlock(path, topList, bottomList, params) {
|
|
25167
|
+
if (topList.length < 2) {
|
|
25168
|
+
return;
|
|
25169
|
+
}
|
|
25170
|
+
const { offsetX = 0, offsetY = 0, offsetZ = 0, mode } = params || {};
|
|
25171
|
+
let curve = topList[0];
|
|
25172
|
+
path.moveTo(curve.p0.x + offsetX, curve.p0.y + offsetY, offsetZ);
|
|
25173
|
+
curve = topList[topList.length - 1];
|
|
25174
|
+
let end = curve.p3 || curve.p1;
|
|
25175
|
+
path.lineTo(end.x + offsetX, end.y + offsetY, offsetZ);
|
|
25176
|
+
curve = bottomList[bottomList.length - 1];
|
|
25177
|
+
path.lineTo(curve.p0.x + offsetX, curve.p0.y + offsetY, offsetZ);
|
|
25178
|
+
curve = bottomList[0];
|
|
25179
|
+
end = curve.p3 || curve.p1;
|
|
25180
|
+
path.lineTo(end.x + offsetX, end.y + offsetY, offsetZ);
|
|
25181
|
+
path.closePath();
|
|
25182
|
+
}
|
|
24773
25183
|
function drawAreaBlock(path, topList, bottomList, params) {
|
|
24774
25184
|
const { offsetX = 0, offsetY = 0, offsetZ = 0 } = params || {};
|
|
24775
25185
|
let needMoveTo = true;
|
|
@@ -24931,7 +25341,7 @@
|
|
|
24931
25341
|
area.cacheArea = { top: topCache, bottom: bottomCache };
|
|
24932
25342
|
}
|
|
24933
25343
|
else {
|
|
24934
|
-
area.
|
|
25344
|
+
area.cacheArea = null;
|
|
24935
25345
|
area.clearUpdateShapeTag();
|
|
24936
25346
|
return;
|
|
24937
25347
|
}
|
|
@@ -24993,6 +25403,45 @@
|
|
|
24993
25403
|
context.highPerformanceRestore();
|
|
24994
25404
|
}
|
|
24995
25405
|
drawSegmentItem(context, cache, fill, fillOpacity, stroke, strokeOpacity, attribute, defaultAttribute, clipRange, offsetX, offsetY, offsetZ, area, drawContext, fillCb, strokeCb) {
|
|
25406
|
+
let ret = false;
|
|
25407
|
+
ret =
|
|
25408
|
+
ret ||
|
|
25409
|
+
this._drawSegmentItem(context, cache, fill, fillOpacity, stroke, strokeOpacity, attribute, defaultAttribute, clipRange, offsetX, offsetY, offsetZ, area, drawContext, false, fillCb, strokeCb);
|
|
25410
|
+
ret =
|
|
25411
|
+
ret ||
|
|
25412
|
+
this._drawSegmentItem(context, cache, fill, fillOpacity, stroke, strokeOpacity, attribute, defaultAttribute, clipRange, offsetX, offsetY, offsetZ, area, drawContext, true, fillCb, strokeCb);
|
|
25413
|
+
return ret;
|
|
25414
|
+
}
|
|
25415
|
+
_drawSegmentItem(context, cache, fill, fillOpacity, stroke, strokeOpacity, attribute, defaultAttribute, clipRange, offsetX, offsetY, offsetZ, area, drawContext, connect, fillCb, strokeCb) {
|
|
25416
|
+
let { connectedType, connectedX, connectedY, connectedStyle } = attribute;
|
|
25417
|
+
const da = [];
|
|
25418
|
+
if (connect) {
|
|
25419
|
+
if (isArray(defaultAttribute)) {
|
|
25420
|
+
connectedType = connectedType ?? defaultAttribute[0].connectedType ?? defaultAttribute[1].connectedType;
|
|
25421
|
+
connectedX = connectedX ?? defaultAttribute[0].connectedX ?? defaultAttribute[1].connectedX;
|
|
25422
|
+
connectedY = connectedY ?? defaultAttribute[0].connectedY ?? defaultAttribute[1].connectedY;
|
|
25423
|
+
connectedStyle = connectedStyle ?? defaultAttribute[0].connectedStyle ?? defaultAttribute[1].connectedStyle;
|
|
25424
|
+
}
|
|
25425
|
+
else {
|
|
25426
|
+
connectedType = connectedType ?? defaultAttribute.connectedType;
|
|
25427
|
+
connectedX = connectedX ?? defaultAttribute.connectedX;
|
|
25428
|
+
connectedY = connectedY ?? defaultAttribute.connectedY;
|
|
25429
|
+
connectedStyle = connectedStyle ?? defaultAttribute.connectedStyle;
|
|
25430
|
+
}
|
|
25431
|
+
if (connectedType !== 'connect' && connectedType !== 'zero') {
|
|
25432
|
+
connectedType = 'none';
|
|
25433
|
+
}
|
|
25434
|
+
if (isArray(defaultAttribute)) {
|
|
25435
|
+
defaultAttribute.forEach(i => da.push(i));
|
|
25436
|
+
}
|
|
25437
|
+
else {
|
|
25438
|
+
da.push(defaultAttribute);
|
|
25439
|
+
}
|
|
25440
|
+
da.push(attribute);
|
|
25441
|
+
}
|
|
25442
|
+
if (connect && connectedType === 'none') {
|
|
25443
|
+
return false;
|
|
25444
|
+
}
|
|
24996
25445
|
if (!cache) {
|
|
24997
25446
|
return;
|
|
24998
25447
|
}
|
|
@@ -25001,7 +25450,11 @@
|
|
|
25001
25450
|
drawAreaSegments(context.camera ? context : context.nativeContext, cache, clipRange, {
|
|
25002
25451
|
offsetX,
|
|
25003
25452
|
offsetY,
|
|
25004
|
-
offsetZ
|
|
25453
|
+
offsetZ,
|
|
25454
|
+
drawConnect: connect,
|
|
25455
|
+
mode: connectedType,
|
|
25456
|
+
zeroX: connectedX,
|
|
25457
|
+
zeroY: connectedY
|
|
25005
25458
|
});
|
|
25006
25459
|
if (!this._areaRenderContribitions) {
|
|
25007
25460
|
this._areaRenderContribitions = this.areaRenderContribitions.getContributions() || [];
|
|
@@ -25019,7 +25472,7 @@
|
|
|
25019
25472
|
fillCb(context, attribute, defaultAttribute);
|
|
25020
25473
|
}
|
|
25021
25474
|
else if (fillOpacity) {
|
|
25022
|
-
context.setCommonStyle(area, attribute, originX - offsetX, originY - offsetY, defaultAttribute);
|
|
25475
|
+
context.setCommonStyle(area, connect ? connectedStyle : attribute, originX - offsetX, originY - offsetY, connect ? da : defaultAttribute);
|
|
25023
25476
|
context.fill();
|
|
25024
25477
|
}
|
|
25025
25478
|
}
|
|
@@ -25042,10 +25495,14 @@
|
|
|
25042
25495
|
drawSegments(context.camera ? context : context.nativeContext, stroke[0] ? cache.top : cache.bottom, clipRange, 'auto', {
|
|
25043
25496
|
offsetX,
|
|
25044
25497
|
offsetY,
|
|
25045
|
-
offsetZ
|
|
25498
|
+
offsetZ,
|
|
25499
|
+
drawConnect: connect,
|
|
25500
|
+
mode: connectedType,
|
|
25501
|
+
zeroX: connectedX,
|
|
25502
|
+
zeroY: connectedY
|
|
25046
25503
|
});
|
|
25047
25504
|
}
|
|
25048
|
-
context.setStrokeStyle(area, attribute, originX - offsetX, originY - offsetY, defaultAttribute);
|
|
25505
|
+
context.setStrokeStyle(area, connect ? connectedStyle : attribute, originX - offsetX, originY - offsetY, connect ? da : defaultAttribute);
|
|
25049
25506
|
context.stroke();
|
|
25050
25507
|
}
|
|
25051
25508
|
}
|
|
@@ -25471,7 +25928,7 @@
|
|
|
25471
25928
|
}
|
|
25472
25929
|
drawShape(text, context, x, y, drawContext, params, fillCb, strokeCb) {
|
|
25473
25930
|
const textAttribute = getTheme(text, params?.theme).text;
|
|
25474
|
-
const { text: str, fill = textAttribute.fill, stroke = textAttribute.stroke, fillOpacity = textAttribute.fillOpacity, strokeOpacity = textAttribute.strokeOpacity, opacity = textAttribute.opacity, lineWidth = textAttribute.lineWidth, visible = textAttribute.visible, underline = textAttribute.underline, lineThrough = textAttribute.lineThrough, keepDirIn3d = textAttribute.keepDirIn3d, fontSize = textAttribute.fontSize, textBaseline = textAttribute.textBaseline, x: originX = textAttribute.x, y: originY = textAttribute.y } = text.attribute;
|
|
25931
|
+
const { text: str, fill = textAttribute.fill, stroke = textAttribute.stroke, fillOpacity = textAttribute.fillOpacity, strokeOpacity = textAttribute.strokeOpacity, opacity = textAttribute.opacity, lineWidth = textAttribute.lineWidth, visible = textAttribute.visible, underline = textAttribute.underline, lineThrough = textAttribute.lineThrough, keepDirIn3d = textAttribute.keepDirIn3d, direction = textAttribute.direction, fontSize = textAttribute.fontSize, textBaseline = textAttribute.textBaseline, textAlign = textAttribute.textAlign, x: originX = textAttribute.x, y: originY = textAttribute.y } = text.attribute;
|
|
25475
25932
|
const lineHeight = text.attribute.lineHeight ?? fontSize;
|
|
25476
25933
|
const fVisible = fillVisible(opacity, fillOpacity, fill);
|
|
25477
25934
|
const sVisible = strokeVisible(opacity, strokeOpacity);
|
|
@@ -25505,23 +25962,24 @@
|
|
|
25505
25962
|
});
|
|
25506
25963
|
context.setShadowStyle && context.setShadowStyle(text, text.attribute, textAttribute);
|
|
25507
25964
|
transform3dMatrixToContextMatrix && this.transformUseContext2d(text, textAttribute, z, context);
|
|
25508
|
-
|
|
25509
|
-
|
|
25510
|
-
const
|
|
25511
|
-
if (
|
|
25512
|
-
context.
|
|
25513
|
-
|
|
25965
|
+
const drawText = (t, offsetX, offsetY, direction) => {
|
|
25966
|
+
let _x = x + offsetX;
|
|
25967
|
+
const _y = y + offsetY;
|
|
25968
|
+
if (direction) {
|
|
25969
|
+
context.highPerformanceSave();
|
|
25970
|
+
_x += fontSize;
|
|
25971
|
+
const matrix = matrixAllocate.allocate(1, 0, 0, 1, 0, 0);
|
|
25972
|
+
matrix.rotateByCenter(Math.PI / 2, _x, _y);
|
|
25973
|
+
context.transformFromMatrix(matrix, true);
|
|
25974
|
+
matrixAllocate.free(matrix);
|
|
25514
25975
|
}
|
|
25515
|
-
const { xOffset, yOffset } = multilineLayout.bbox;
|
|
25516
25976
|
if (doStroke) {
|
|
25517
25977
|
if (strokeCb) {
|
|
25518
25978
|
strokeCb(context, text.attribute, textAttribute);
|
|
25519
25979
|
}
|
|
25520
25980
|
else if (sVisible) {
|
|
25521
25981
|
context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute);
|
|
25522
|
-
|
|
25523
|
-
context.strokeText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);
|
|
25524
|
-
});
|
|
25982
|
+
context.strokeText(t, _x, _y, z);
|
|
25525
25983
|
}
|
|
25526
25984
|
}
|
|
25527
25985
|
if (doFill) {
|
|
@@ -25530,45 +25988,134 @@
|
|
|
25530
25988
|
}
|
|
25531
25989
|
else if (fVisible) {
|
|
25532
25990
|
context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute);
|
|
25533
|
-
|
|
25534
|
-
|
|
25535
|
-
this.drawMultiUnderLine(underline, lineThrough, text, (line.leftOffset || 0) + x, (line.topOffset || 0) + yOffset + y, z, line.width, textAttribute, context);
|
|
25536
|
-
});
|
|
25991
|
+
context.fillText(t, _x, _y, z);
|
|
25992
|
+
this.drawUnderLine(underline, lineThrough, text, _x, _y, z, textAttribute, context);
|
|
25537
25993
|
}
|
|
25538
25994
|
}
|
|
25539
|
-
|
|
25540
|
-
|
|
25541
|
-
|
|
25542
|
-
|
|
25543
|
-
|
|
25544
|
-
|
|
25545
|
-
|
|
25546
|
-
|
|
25995
|
+
if (direction) {
|
|
25996
|
+
context.highPerformanceRestore();
|
|
25997
|
+
context.setTransformForCurrent();
|
|
25998
|
+
}
|
|
25999
|
+
};
|
|
26000
|
+
if (Array.isArray(str)) {
|
|
26001
|
+
context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z);
|
|
26002
|
+
if (direction === 'horizontal') {
|
|
26003
|
+
const { multilineLayout } = text;
|
|
26004
|
+
if (!multilineLayout) {
|
|
26005
|
+
context.highPerformanceRestore();
|
|
26006
|
+
return;
|
|
26007
|
+
}
|
|
26008
|
+
const { xOffset, yOffset } = multilineLayout.bbox;
|
|
26009
|
+
if (doStroke) {
|
|
26010
|
+
if (strokeCb) {
|
|
26011
|
+
strokeCb(context, text.attribute, textAttribute);
|
|
26012
|
+
}
|
|
26013
|
+
else if (sVisible) {
|
|
26014
|
+
context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute);
|
|
26015
|
+
multilineLayout.lines.forEach(line => {
|
|
26016
|
+
context.strokeText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);
|
|
26017
|
+
});
|
|
26018
|
+
}
|
|
25547
26019
|
}
|
|
25548
|
-
|
|
25549
|
-
|
|
25550
|
-
|
|
26020
|
+
if (doFill) {
|
|
26021
|
+
if (fillCb) {
|
|
26022
|
+
fillCb(context, text.attribute, textAttribute);
|
|
26023
|
+
}
|
|
26024
|
+
else if (fVisible) {
|
|
26025
|
+
context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute);
|
|
26026
|
+
multilineLayout.lines.forEach(line => {
|
|
26027
|
+
context.fillText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);
|
|
26028
|
+
this.drawMultiUnderLine(underline, lineThrough, text, (line.leftOffset || 0) + x, (line.topOffset || 0) + yOffset + y, z, line.width, textAttribute, context);
|
|
26029
|
+
});
|
|
26030
|
+
}
|
|
25551
26031
|
}
|
|
25552
|
-
else ;
|
|
25553
26032
|
}
|
|
25554
|
-
|
|
25555
|
-
|
|
25556
|
-
|
|
26033
|
+
else {
|
|
26034
|
+
const cache = text.cache;
|
|
26035
|
+
const { verticalList } = cache;
|
|
26036
|
+
context.textAlign = 'left';
|
|
26037
|
+
context.textBaseline = 'top';
|
|
26038
|
+
const totalHeight = lineHeight * verticalList.length;
|
|
26039
|
+
let totalW = 0;
|
|
26040
|
+
verticalList.forEach(verticalData => {
|
|
26041
|
+
const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
|
|
26042
|
+
totalW = max(_w, totalW);
|
|
26043
|
+
});
|
|
26044
|
+
let offsetY = 0;
|
|
26045
|
+
let offsetX = 0;
|
|
26046
|
+
if (textBaseline === 'bottom') {
|
|
26047
|
+
offsetX = -totalHeight;
|
|
25557
26048
|
}
|
|
25558
|
-
else if (
|
|
25559
|
-
|
|
25560
|
-
|
|
26049
|
+
else if (textBaseline === 'middle') {
|
|
26050
|
+
offsetX = -totalHeight / 2;
|
|
26051
|
+
}
|
|
26052
|
+
if (textAlign === 'center') {
|
|
26053
|
+
offsetY -= totalW / 2;
|
|
26054
|
+
}
|
|
26055
|
+
else if (textAlign === 'right') {
|
|
26056
|
+
offsetY -= totalW;
|
|
25561
26057
|
}
|
|
26058
|
+
verticalList.forEach((verticalData, i) => {
|
|
26059
|
+
const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0);
|
|
26060
|
+
const dw = totalW - currentW;
|
|
26061
|
+
let currentOffsetY = offsetY;
|
|
26062
|
+
if (textAlign === 'center') {
|
|
26063
|
+
currentOffsetY += dw / 2;
|
|
26064
|
+
}
|
|
26065
|
+
else if (textAlign === 'right') {
|
|
26066
|
+
currentOffsetY += dw;
|
|
26067
|
+
}
|
|
26068
|
+
verticalData.forEach(item => {
|
|
26069
|
+
const { text, width, direction } = item;
|
|
26070
|
+
drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction);
|
|
26071
|
+
currentOffsetY += width;
|
|
26072
|
+
});
|
|
26073
|
+
});
|
|
25562
26074
|
}
|
|
25563
|
-
|
|
25564
|
-
|
|
25565
|
-
|
|
26075
|
+
}
|
|
26076
|
+
else {
|
|
26077
|
+
const cache = text.cache;
|
|
26078
|
+
if (direction === 'horizontal') {
|
|
26079
|
+
context.setTextStyle(text.attribute, textAttribute, z);
|
|
26080
|
+
const t = text.clipedText;
|
|
26081
|
+
let dy = 0;
|
|
26082
|
+
if (lineHeight !== fontSize) {
|
|
26083
|
+
if (textBaseline === 'top') {
|
|
26084
|
+
dy = (lineHeight - fontSize) / 2;
|
|
26085
|
+
}
|
|
26086
|
+
else if (textBaseline === 'middle') ;
|
|
26087
|
+
else if (textBaseline === 'bottom') {
|
|
26088
|
+
dy = -(lineHeight - fontSize) / 2;
|
|
26089
|
+
}
|
|
26090
|
+
else ;
|
|
25566
26091
|
}
|
|
25567
|
-
|
|
25568
|
-
|
|
25569
|
-
|
|
25570
|
-
|
|
26092
|
+
drawText(t, 0, dy, 0);
|
|
26093
|
+
}
|
|
26094
|
+
else if (cache) {
|
|
26095
|
+
context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z);
|
|
26096
|
+
const { verticalList } = cache;
|
|
26097
|
+
let offsetY = 0;
|
|
26098
|
+
const totalW = verticalList[0].reduce((a, b) => a + (b.width || 0), 0);
|
|
26099
|
+
let offsetX = 0;
|
|
26100
|
+
if (textBaseline === 'bottom') {
|
|
26101
|
+
offsetX = -lineHeight;
|
|
25571
26102
|
}
|
|
26103
|
+
else if (textBaseline === 'middle') {
|
|
26104
|
+
offsetX = -lineHeight / 2;
|
|
26105
|
+
}
|
|
26106
|
+
if (textAlign === 'center') {
|
|
26107
|
+
offsetY -= totalW / 2;
|
|
26108
|
+
}
|
|
26109
|
+
else if (textAlign === 'right') {
|
|
26110
|
+
offsetY -= totalW;
|
|
26111
|
+
}
|
|
26112
|
+
context.textAlign = 'left';
|
|
26113
|
+
context.textBaseline = 'top';
|
|
26114
|
+
verticalList[0].forEach(item => {
|
|
26115
|
+
const { text, width, direction } = item;
|
|
26116
|
+
drawText(text, offsetX, offsetY, direction);
|
|
26117
|
+
offsetY += width;
|
|
26118
|
+
});
|
|
25572
26119
|
}
|
|
25573
26120
|
}
|
|
25574
26121
|
transform3dMatrixToContextMatrix && this.restoreTransformUseContext2d(text, textAttribute, z, context);
|
|
@@ -36343,7 +36890,7 @@
|
|
|
36343
36890
|
'rect'
|
|
36344
36891
|
];
|
|
36345
36892
|
|
|
36346
|
-
const version = "0.
|
|
36893
|
+
const version = "0.14.0-alpha.1";
|
|
36347
36894
|
|
|
36348
36895
|
exports.ACustomAnimate = ACustomAnimate;
|
|
36349
36896
|
exports.ARC3D_NUMBER_TYPE = ARC3D_NUMBER_TYPE;
|
|
@@ -36388,6 +36935,7 @@
|
|
|
36388
36935
|
exports.DefaultAreaAttribute = DefaultAreaAttribute;
|
|
36389
36936
|
exports.DefaultAttribute = DefaultAttribute;
|
|
36390
36937
|
exports.DefaultCircleAttribute = DefaultCircleAttribute;
|
|
36938
|
+
exports.DefaultConnectAttribute = DefaultConnectAttribute;
|
|
36391
36939
|
exports.DefaultFillStyle = DefaultFillStyle;
|
|
36392
36940
|
exports.DefaultGlyphAttribute = DefaultGlyphAttribute;
|
|
36393
36941
|
exports.DefaultGroupAttribute = DefaultGroupAttribute;
|
|
@@ -36656,6 +37204,7 @@
|
|
|
36656
37204
|
exports.transformUtil = transformUtil;
|
|
36657
37205
|
exports.translate = translate;
|
|
36658
37206
|
exports.version = version;
|
|
37207
|
+
exports.verticalLayout = verticalLayout;
|
|
36659
37208
|
exports.waitForAllSubLayers = waitForAllSubLayers;
|
|
36660
37209
|
exports.wrapCanvas = wrapCanvas;
|
|
36661
37210
|
exports.wrapContext = wrapContext;
|