@antv/l7-layers 2.9.23 → 2.9.25
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/es/Geometry/models/plane.d.ts +1 -0
- package/es/citybuliding/building.js +1 -1
- package/es/core/BaseLayer.js +10 -3
- package/es/core/interface.d.ts +26 -48
- package/es/core/interface.js +3 -0
- package/es/core/schema.d.ts +3 -3
- package/es/core/triangulation.d.ts +4 -3
- package/es/core/triangulation.js +54 -39
- package/es/heatmap/models/heatmap.js +1 -1
- package/es/image/models/image.js +7 -1
- package/es/line/index.js +4 -1
- package/es/line/models/arc.js +1 -1
- package/es/line/models/simpleLine.js +1 -1
- package/es/line/shaders/line_arc_vert.glsl +5 -3
- package/es/line/shaders/simple/simpleline_vert.glsl +1 -0
- package/es/plugins/FeatureScalePlugin.js +0 -1
- package/es/point/index.js +3 -1
- package/es/point/models/fill.js +5 -2
- package/es/point/models/fillmage.js +9 -3
- package/es/point/models/image.js +8 -2
- package/es/point/models/radar.js +2 -3
- package/es/point/models/tile.js +1 -1
- package/es/point/shaders/fill_vert.glsl +13 -6
- package/es/point/shaders/image/fillImage_vert.glsl +13 -5
- package/es/point/shaders/image_vert.glsl +17 -8
- package/es/polygon/index.js +4 -1
- package/es/raster/index.js +3 -1
- package/es/tile/manager/tileLayerManager.d.ts +3 -2
- package/es/tile/manager/tileLayerManager.js +5 -2
- package/es/tile/models/tileModel.js +4 -3
- package/es/tile/tileFactory/base.d.ts +1 -1
- package/es/tile/tileFactory/base.js +32 -5
- package/es/tile/tileFactory/vectorLayer.d.ts +3 -1
- package/es/tile/tileFactory/vectorLayer.js +22 -1
- package/es/tile/tileLayer/baseTileLayer.d.ts +1 -1
- package/es/tile/tileLayer/baseTileLayer.js +3 -2
- package/es/tile/utils.d.ts +2 -0
- package/es/tile/utils.js +5 -1
- package/lib/Geometry/index.js +114 -77
- package/lib/Geometry/models/billboard.js +232 -181
- package/lib/Geometry/models/index.js +18 -34
- package/lib/Geometry/models/plane.js +407 -278
- package/lib/Geometry/models/sprite.js +291 -189
- package/lib/canvas/index.js +101 -66
- package/lib/canvas/models/canvas.js +207 -140
- package/lib/canvas/models/index.js +12 -30
- package/lib/citybuliding/building.js +98 -63
- package/lib/citybuliding/models/build.js +192 -146
- package/lib/core/BaseLayer.js +1331 -809
- package/lib/core/BaseModel.js +457 -279
- package/lib/core/interface.js +40 -53
- package/lib/core/schema.js +21 -39
- package/lib/core/shape/Path.js +67 -79
- package/lib/core/shape/extrude.js +132 -91
- package/lib/core/triangulation.js +412 -213
- package/lib/earth/index.js +100 -62
- package/lib/earth/models/atmosphere.js +146 -112
- package/lib/earth/models/base.js +210 -150
- package/lib/earth/models/bloomsphere.js +146 -112
- package/lib/earth/utils.js +111 -91
- package/lib/heatmap/index.js +149 -92
- package/lib/heatmap/models/grid.js +118 -91
- package/lib/heatmap/models/grid3d.js +155 -123
- package/lib/heatmap/models/heatmap.js +475 -338
- package/lib/heatmap/models/hexagon.js +121 -92
- package/lib/heatmap/models/index.js +22 -37
- package/lib/heatmap/triangulation.js +31 -47
- package/lib/image/index.js +111 -74
- package/lib/image/models/dataImage.js +232 -174
- package/lib/image/models/image.js +175 -123
- package/lib/image/models/index.js +15 -32
- package/lib/index.js +263 -97
- package/lib/line/index.js +131 -83
- package/lib/line/models/arc.js +352 -237
- package/lib/line/models/arc_3d.js +334 -228
- package/lib/line/models/earthArc_3d.js +336 -228
- package/lib/line/models/great_circle.js +291 -200
- package/lib/line/models/half.js +286 -201
- package/lib/line/models/index.js +42 -50
- package/lib/line/models/line.js +428 -299
- package/lib/line/models/linearline.js +277 -203
- package/lib/line/models/simpleLine.js +239 -175
- package/lib/line/models/tile.js +348 -237
- package/lib/line/models/wall.js +327 -235
- package/lib/line/shaders/line_arc_vert.glsl +5 -3
- package/lib/line/shaders/simple/simpleline_vert.glsl +1 -0
- package/lib/mask/index.js +92 -59
- package/lib/mask/models/fill.js +134 -82
- package/lib/mask/models/index.js +12 -30
- package/lib/plugins/DataMappingPlugin.js +342 -224
- package/lib/plugins/DataSourcePlugin.js +102 -87
- package/lib/plugins/FeatureScalePlugin.js +330 -241
- package/lib/plugins/LayerAnimateStylePlugin.js +61 -55
- package/lib/plugins/LayerModelPlugin.js +80 -73
- package/lib/plugins/LayerStylePlugin.js +48 -51
- package/lib/plugins/LightingPlugin.js +80 -68
- package/lib/plugins/MultiPassRendererPlugin.js +91 -65
- package/lib/plugins/PixelPickingPlugin.js +150 -109
- package/lib/plugins/RegisterStyleAttributePlugin.js +110 -110
- package/lib/plugins/ShaderUniformPlugin.js +118 -99
- package/lib/plugins/UpdateModelPlugin.js +40 -47
- package/lib/plugins/UpdateStyleAttributePlugin.js +93 -75
- package/lib/point/index.js +226 -148
- package/lib/point/models/earthExtrude.js +279 -201
- package/lib/point/models/earthFill.js +287 -202
- package/lib/point/models/extrude.js +299 -203
- package/lib/point/models/fill.js +406 -273
- package/lib/point/models/fillmage.js +365 -252
- package/lib/point/models/image.js +241 -164
- package/lib/point/models/index.js +46 -52
- package/lib/point/models/normal.js +183 -134
- package/lib/point/models/radar.js +304 -212
- package/lib/point/models/simplePoint.js +194 -142
- package/lib/point/models/text.js +608 -385
- package/lib/point/models/tile.js +314 -223
- package/lib/point/shaders/fill_vert.glsl +13 -6
- package/lib/point/shaders/image/fillImage_vert.glsl +13 -5
- package/lib/point/shaders/image_vert.glsl +17 -8
- package/lib/point/shape/extrude.js +56 -52
- package/lib/polygon/index.js +154 -100
- package/lib/polygon/models/extrude.js +311 -223
- package/lib/polygon/models/fill.js +215 -153
- package/lib/polygon/models/index.js +46 -52
- package/lib/polygon/models/ocean.js +244 -173
- package/lib/polygon/models/tile.js +144 -100
- package/lib/polygon/models/water.js +222 -153
- package/lib/raster/buffers/triangulation.js +27 -40
- package/lib/raster/index.js +115 -74
- package/lib/raster/models/index.js +16 -33
- package/lib/raster/models/raster.js +178 -135
- package/lib/raster/raster.js +187 -132
- package/lib/tile/interface.js +4 -16
- package/lib/tile/manager/tileConfigManager.js +125 -86
- package/lib/tile/manager/tileLayerManager.js +314 -227
- package/lib/tile/manager/tilePickerManager.js +192 -123
- package/lib/tile/models/tileModel.js +71 -51
- package/lib/tile/tileFactory/base.js +433 -292
- package/lib/tile/tileFactory/index.js +51 -49
- package/lib/tile/tileFactory/line.js +65 -50
- package/lib/tile/tileFactory/point.js +65 -50
- package/lib/tile/tileFactory/polygon.js +65 -50
- package/lib/tile/tileFactory/raster.js +66 -54
- package/lib/tile/tileFactory/rasterData.js +88 -76
- package/lib/tile/tileFactory/rasterDataLayer.js +97 -62
- package/lib/tile/tileFactory/vectorLayer.js +169 -95
- package/lib/tile/tileLayer/baseTileLayer.js +420 -220
- package/lib/tile/tmsTileLayer.js +110 -67
- package/lib/tile/utils.js +113 -87
- package/lib/utils/blend.js +59 -79
- package/lib/utils/collision-index.js +107 -64
- package/lib/utils/dataMappingStyle.js +105 -60
- package/lib/utils/extrude_polyline.js +600 -398
- package/lib/utils/grid-index.js +163 -111
- package/lib/utils/layerData.js +130 -99
- package/lib/utils/multiPassRender.js +49 -41
- package/lib/utils/polylineNormal.js +148 -96
- package/lib/utils/simpleLine.js +100 -85
- package/lib/utils/symbol-layout.js +219 -116
- package/lib/utils/updateShape.js +15 -41
- package/lib/wind/index.js +109 -71
- package/lib/wind/models/index.js +12 -30
- package/lib/wind/models/utils.js +144 -105
- package/lib/wind/models/wind.js +333 -224
- package/lib/wind/models/windRender.js +329 -218
- package/lib/wind/models/windShader.js +23 -181
- package/package.json +7 -6
|
@@ -1,205 +1,308 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/utils/symbol-layout.ts
|
|
20
|
-
var symbol_layout_exports = {};
|
|
21
|
-
__export(symbol_layout_exports, {
|
|
22
|
-
getGlyphQuads: () => getGlyphQuads,
|
|
23
|
-
shapeText: () => shapeText
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
24
5
|
});
|
|
25
|
-
|
|
6
|
+
exports.getGlyphQuads = getGlyphQuads;
|
|
7
|
+
exports.shapeText = shapeText;
|
|
8
|
+
|
|
9
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
10
|
+
|
|
11
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
12
|
+
|
|
13
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 返回文本相对锚点位置
|
|
17
|
+
* @param {string} anchor 锚点位置
|
|
18
|
+
* @return {alignment} alignment
|
|
19
|
+
*/
|
|
26
20
|
function getAnchorAlignment(anchor) {
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
var horizontalAlign = 0.5;
|
|
22
|
+
var verticalAlign = 0.5;
|
|
23
|
+
|
|
29
24
|
switch (anchor) {
|
|
30
|
-
case
|
|
31
|
-
case
|
|
32
|
-
case
|
|
25
|
+
case 'right':
|
|
26
|
+
case 'top-right':
|
|
27
|
+
case 'bottom-right':
|
|
33
28
|
horizontalAlign = 1;
|
|
34
29
|
break;
|
|
35
|
-
|
|
36
|
-
case
|
|
37
|
-
case
|
|
30
|
+
|
|
31
|
+
case 'left':
|
|
32
|
+
case 'top-left':
|
|
33
|
+
case 'bottom-left':
|
|
38
34
|
horizontalAlign = 0;
|
|
39
35
|
break;
|
|
36
|
+
|
|
40
37
|
default:
|
|
41
38
|
horizontalAlign = 0.5;
|
|
42
39
|
}
|
|
40
|
+
|
|
43
41
|
switch (anchor) {
|
|
44
|
-
case
|
|
45
|
-
case
|
|
46
|
-
case
|
|
42
|
+
case 'bottom':
|
|
43
|
+
case 'bottom-right':
|
|
44
|
+
case 'bottom-left':
|
|
47
45
|
verticalAlign = 1;
|
|
48
46
|
break;
|
|
49
|
-
|
|
50
|
-
case
|
|
51
|
-
case
|
|
47
|
+
|
|
48
|
+
case 'top':
|
|
49
|
+
case 'top-right':
|
|
50
|
+
case 'top-left':
|
|
52
51
|
verticalAlign = 0;
|
|
53
52
|
break;
|
|
53
|
+
|
|
54
54
|
default:
|
|
55
55
|
verticalAlign = 0.5;
|
|
56
56
|
}
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
horizontalAlign: horizontalAlign,
|
|
60
|
+
verticalAlign: verticalAlign
|
|
61
|
+
};
|
|
62
|
+
} // justify right = 1, left = 0, center = 0.5
|
|
63
|
+
|
|
64
|
+
|
|
59
65
|
function justifyLine(positionedGlyphs, glyphMap, start, end, justify) {
|
|
60
66
|
if (!justify) {
|
|
61
67
|
return;
|
|
62
68
|
}
|
|
63
|
-
|
|
64
|
-
|
|
69
|
+
|
|
70
|
+
var lastPositionedGlyph = positionedGlyphs[end];
|
|
71
|
+
var glyph = lastPositionedGlyph.glyph;
|
|
72
|
+
|
|
65
73
|
if (glyph) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
74
|
+
var lastAdvance = glyphMap[glyph].advance * lastPositionedGlyph.scale;
|
|
75
|
+
var lineIndent = (positionedGlyphs[end].x + lastAdvance) * justify;
|
|
76
|
+
|
|
77
|
+
for (var j = start; j <= end; j++) {
|
|
69
78
|
positionedGlyphs[j].x -= lineIndent;
|
|
70
79
|
}
|
|
71
80
|
}
|
|
72
|
-
}
|
|
81
|
+
} // justify right=1 left=0 center=0.5
|
|
82
|
+
// horizontalAlign right=1 left=0 center=0.5
|
|
83
|
+
// verticalAlign right=1 left=0 center=0.5
|
|
84
|
+
|
|
85
|
+
|
|
73
86
|
function align(positionedGlyphs, justify, horizontalAlign, verticalAlign, maxLineLength, lineHeight, lineCount) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
87
|
+
var shiftX = (justify - horizontalAlign) * maxLineLength;
|
|
88
|
+
var shiftY = (-verticalAlign * lineCount + 0.5) * lineHeight;
|
|
89
|
+
|
|
90
|
+
var _iterator = _createForOfIteratorHelper(positionedGlyphs),
|
|
91
|
+
_step;
|
|
92
|
+
|
|
93
|
+
try {
|
|
94
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
95
|
+
var glyphs = _step.value;
|
|
96
|
+
glyphs.x += shiftX;
|
|
97
|
+
glyphs.y += shiftY;
|
|
98
|
+
}
|
|
99
|
+
} catch (err) {
|
|
100
|
+
_iterator.e(err);
|
|
101
|
+
} finally {
|
|
102
|
+
_iterator.f();
|
|
79
103
|
}
|
|
80
104
|
}
|
|
105
|
+
|
|
81
106
|
function shapeLines(shaping, glyphMap, lines, lineHeight, textAnchor, textJustify, spacing) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
107
|
+
// buffer 为 4
|
|
108
|
+
var yOffset = -8;
|
|
109
|
+
var x = 0;
|
|
110
|
+
var y = yOffset;
|
|
111
|
+
var maxLineLength = 0;
|
|
112
|
+
var positionedGlyphs = shaping.positionedGlyphs;
|
|
113
|
+
var justify = textJustify === 'right' ? 1 : textJustify === 'left' ? 0 : 0.5;
|
|
114
|
+
var lineStartIndex = positionedGlyphs.length;
|
|
115
|
+
lines.forEach(function (line) {
|
|
116
|
+
line.split('').forEach(function (char) {
|
|
117
|
+
var glyph = glyphMap[char];
|
|
118
|
+
var baselineOffset = 0;
|
|
119
|
+
|
|
93
120
|
if (glyph) {
|
|
94
121
|
positionedGlyphs.push({
|
|
95
122
|
glyph: char,
|
|
96
|
-
x,
|
|
123
|
+
x: x,
|
|
97
124
|
y: y + baselineOffset,
|
|
98
125
|
vertical: false,
|
|
126
|
+
// TODO:目前只支持水平方向
|
|
99
127
|
scale: 1,
|
|
100
128
|
metrics: glyph
|
|
101
129
|
});
|
|
102
130
|
x += glyph.advance + spacing;
|
|
103
131
|
}
|
|
104
|
-
});
|
|
132
|
+
}); // 左右对齐
|
|
133
|
+
|
|
105
134
|
if (positionedGlyphs.length !== lineStartIndex) {
|
|
106
|
-
|
|
135
|
+
var lineLength = x - spacing;
|
|
107
136
|
maxLineLength = Math.max(lineLength, maxLineLength);
|
|
108
137
|
justifyLine(positionedGlyphs, glyphMap, lineStartIndex, positionedGlyphs.length - 1, justify);
|
|
109
138
|
}
|
|
139
|
+
|
|
110
140
|
x = 0;
|
|
111
141
|
y -= lineHeight + 5;
|
|
112
142
|
});
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
143
|
+
|
|
144
|
+
var _getAnchorAlignment = getAnchorAlignment(textAnchor),
|
|
145
|
+
horizontalAlign = _getAnchorAlignment.horizontalAlign,
|
|
146
|
+
verticalAlign = _getAnchorAlignment.verticalAlign;
|
|
147
|
+
|
|
148
|
+
align(positionedGlyphs, justify, horizontalAlign, verticalAlign, maxLineLength, lineHeight, lines.length); // 计算包围盒
|
|
149
|
+
|
|
150
|
+
var height = y - yOffset;
|
|
116
151
|
shaping.top += -verticalAlign * height;
|
|
117
152
|
shaping.bottom = shaping.top - height;
|
|
118
153
|
shaping.left += -horizontalAlign * maxLineLength;
|
|
119
154
|
shaping.right = shaping.left + maxLineLength;
|
|
120
155
|
}
|
|
156
|
+
|
|
121
157
|
function shapeIconFont(shaping, glyphMap, iconfonts, lineHeight, textAnchor, textJustify, spacing) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
158
|
+
// buffer 为 4
|
|
159
|
+
var yOffset = -8;
|
|
160
|
+
var x = 0;
|
|
161
|
+
var y = yOffset;
|
|
162
|
+
var maxLineLength = 0;
|
|
163
|
+
var positionedGlyphs = shaping.positionedGlyphs;
|
|
164
|
+
var justify = textJustify === 'right' ? 1 : textJustify === 'left' ? 0 : 0.5;
|
|
165
|
+
var lineStartIndex = positionedGlyphs.length;
|
|
166
|
+
iconfonts.forEach(function (iconfont) {
|
|
167
|
+
var glyph = glyphMap[iconfont];
|
|
168
|
+
var baselineOffset = 0;
|
|
169
|
+
|
|
132
170
|
if (glyph) {
|
|
133
171
|
positionedGlyphs.push({
|
|
134
172
|
glyph: iconfont,
|
|
173
|
+
// x,
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* iconfont
|
|
177
|
+
* 在计算大小的时候计算的是 unicode 字符 如 
|
|
178
|
+
* 在布局计算 icon 位置的时候应该始终保持居中(且 icon 只占一个字符的位置)
|
|
179
|
+
*/
|
|
135
180
|
x: glyph.advance / 2,
|
|
136
181
|
y: y + baselineOffset,
|
|
137
182
|
vertical: false,
|
|
183
|
+
// TODO:目前只支持水平方向
|
|
138
184
|
scale: 1,
|
|
139
185
|
metrics: glyph
|
|
140
186
|
});
|
|
141
187
|
x += glyph.advance + spacing;
|
|
142
|
-
}
|
|
188
|
+
} // 左右对齐
|
|
189
|
+
|
|
190
|
+
|
|
143
191
|
if (positionedGlyphs.length !== lineStartIndex) {
|
|
144
|
-
|
|
192
|
+
var lineLength = x - spacing;
|
|
145
193
|
maxLineLength = Math.max(lineLength, maxLineLength);
|
|
146
194
|
justifyLine(positionedGlyphs, glyphMap, lineStartIndex, positionedGlyphs.length - 1, justify);
|
|
147
195
|
}
|
|
196
|
+
|
|
148
197
|
x = 0;
|
|
149
198
|
y -= lineHeight + 5;
|
|
150
199
|
});
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
200
|
+
|
|
201
|
+
var _getAnchorAlignment2 = getAnchorAlignment(textAnchor),
|
|
202
|
+
horizontalAlign = _getAnchorAlignment2.horizontalAlign,
|
|
203
|
+
verticalAlign = _getAnchorAlignment2.verticalAlign;
|
|
204
|
+
|
|
205
|
+
align(positionedGlyphs, justify, horizontalAlign, verticalAlign, maxLineLength, lineHeight, iconfonts.length); // 计算包围盒
|
|
206
|
+
|
|
207
|
+
var height = y - yOffset;
|
|
154
208
|
shaping.top += -verticalAlign * height;
|
|
155
209
|
shaping.bottom = shaping.top - height;
|
|
156
210
|
shaping.left += -horizontalAlign * maxLineLength;
|
|
157
211
|
shaping.right = shaping.left + maxLineLength;
|
|
158
212
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
213
|
+
/**
|
|
214
|
+
* 计算文本中每个独立字符相对锚点的位置
|
|
215
|
+
*
|
|
216
|
+
* @param {string} text 原始文本
|
|
217
|
+
* @param {*} glyphs mapping
|
|
218
|
+
* @param {number} lineHeight 行高
|
|
219
|
+
* @param {string} textAnchor 文本相对于锚点的位置
|
|
220
|
+
* @param {string} textJustify 左右对齐
|
|
221
|
+
* @param {number} spacing 字符间距
|
|
222
|
+
* @param {[number, number]} translate 文本水平 & 垂直偏移量
|
|
223
|
+
* @param {[boolean]} isIconFont 是否是 iconfont
|
|
224
|
+
* @return {boolean|shaping} 每个字符相对于锚点的位置
|
|
225
|
+
*/
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
function shapeText(text, glyphs, lineHeight, textAnchor, textJustify, spacing) {
|
|
229
|
+
var translate = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : [0, 0];
|
|
230
|
+
var isIconFont = arguments.length > 7 ? arguments[7] : undefined;
|
|
231
|
+
// TODO:处理换行
|
|
232
|
+
var lines = text.split('\n');
|
|
233
|
+
var positionedGlyphs = [];
|
|
234
|
+
var shaping = {
|
|
235
|
+
positionedGlyphs: positionedGlyphs,
|
|
164
236
|
top: translate[1],
|
|
165
237
|
bottom: translate[1],
|
|
166
238
|
left: translate[0],
|
|
167
239
|
right: translate[0],
|
|
168
240
|
lineCount: lines.length,
|
|
169
|
-
text
|
|
241
|
+
text: text
|
|
170
242
|
};
|
|
171
243
|
isIconFont ? shapeIconFont(shaping, glyphs, lines, lineHeight, textAnchor, textJustify, spacing) : shapeLines(shaping, glyphs, lines, lineHeight, textAnchor, textJustify, spacing);
|
|
244
|
+
|
|
172
245
|
if (!positionedGlyphs.length) {
|
|
173
246
|
return false;
|
|
174
247
|
}
|
|
248
|
+
|
|
175
249
|
return shaping;
|
|
176
250
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
251
|
+
|
|
252
|
+
function getGlyphQuads(shaping) {
|
|
253
|
+
var textOffset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [0, 0];
|
|
254
|
+
var alongLine = arguments.length > 2 ? arguments[2] : undefined;
|
|
255
|
+
var _shaping$positionedGl = shaping.positionedGlyphs,
|
|
256
|
+
positionedGlyphs = _shaping$positionedGl === void 0 ? [] : _shaping$positionedGl;
|
|
257
|
+
var quads = [];
|
|
258
|
+
|
|
259
|
+
var _iterator2 = _createForOfIteratorHelper(positionedGlyphs),
|
|
260
|
+
_step2;
|
|
261
|
+
|
|
262
|
+
try {
|
|
263
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
264
|
+
var positionedGlyph = _step2.value;
|
|
265
|
+
var rect = positionedGlyph.metrics; // The rects have an addditional buffer that is not included in their size.
|
|
266
|
+
|
|
267
|
+
var rectBuffer = 4;
|
|
268
|
+
var halfAdvance = rect.advance * positionedGlyph.scale / 2;
|
|
269
|
+
var glyphOffset = alongLine ? [positionedGlyph.x + halfAdvance, positionedGlyph.y] : [0, 0];
|
|
270
|
+
var builtInOffset = alongLine ? [0, 0] : [positionedGlyph.x + halfAdvance + textOffset[0], positionedGlyph.y + textOffset[1]];
|
|
271
|
+
var x1 = (0 - rectBuffer) * positionedGlyph.scale - halfAdvance + builtInOffset[0];
|
|
272
|
+
var y1 = (0 - rectBuffer) * positionedGlyph.scale + builtInOffset[1];
|
|
273
|
+
var x2 = x1 + rect.width * positionedGlyph.scale;
|
|
274
|
+
var y2 = y1 + rect.height * positionedGlyph.scale;
|
|
275
|
+
var tl = {
|
|
276
|
+
x: x1,
|
|
277
|
+
y: y1
|
|
278
|
+
};
|
|
279
|
+
var tr = {
|
|
280
|
+
x: x2,
|
|
281
|
+
y: y1
|
|
282
|
+
};
|
|
283
|
+
var bl = {
|
|
284
|
+
x: x1,
|
|
285
|
+
y: y2
|
|
286
|
+
};
|
|
287
|
+
var br = {
|
|
288
|
+
x: x2,
|
|
289
|
+
y: y2
|
|
290
|
+
}; // TODO:处理字符旋转的情况
|
|
291
|
+
|
|
292
|
+
quads.push({
|
|
293
|
+
tl: tl,
|
|
294
|
+
tr: tr,
|
|
295
|
+
bl: bl,
|
|
296
|
+
br: br,
|
|
297
|
+
tex: rect,
|
|
298
|
+
glyphOffset: glyphOffset
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
} catch (err) {
|
|
302
|
+
_iterator2.e(err);
|
|
303
|
+
} finally {
|
|
304
|
+
_iterator2.f();
|
|
198
305
|
}
|
|
306
|
+
|
|
199
307
|
return quads;
|
|
200
|
-
}
|
|
201
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
202
|
-
0 && (module.exports = {
|
|
203
|
-
getGlyphQuads,
|
|
204
|
-
shapeText
|
|
205
|
-
});
|
|
308
|
+
}
|
package/lib/utils/updateShape.js
CHANGED
|
@@ -1,53 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";
|
|
18
2
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
__export(updateShape_exports, {
|
|
22
|
-
updateShape: () => updateShape
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
23
5
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
["hexagon", "cylinder"],
|
|
31
|
-
["octogon", "cylinder"],
|
|
32
|
-
["hexagram", "cylinder"],
|
|
33
|
-
["rhombus", "cylinder"],
|
|
34
|
-
["vesica", "cylinder"]
|
|
35
|
-
];
|
|
6
|
+
exports.updateShape = updateShape;
|
|
7
|
+
// TODO: shapeUpdateList 存储一系列的 shape 类型
|
|
8
|
+
// 当这一系列的 shape 相互切换的时候需要重构 layer 的 model (顶点数据集)
|
|
9
|
+
var shapeUpdateList = [// PointLayer
|
|
10
|
+
['circle', 'cylinder'], ['square', 'cylinder'], ['triangle', 'cylinder'], ['pentagon', 'cylinder'], ['hexagon', 'cylinder'], ['octogon', 'cylinder'], ['hexagram', 'cylinder'], ['rhombus', 'cylinder'], ['vesica', 'cylinder']];
|
|
11
|
+
|
|
36
12
|
function updateShape(layer, lastShape, currentShape) {
|
|
37
|
-
if (typeof lastShape ===
|
|
38
|
-
if (layer.type ===
|
|
13
|
+
if (typeof lastShape === 'string' && typeof currentShape === 'string' && lastShape !== currentShape) {
|
|
14
|
+
if (layer.type === 'PointLayer') {
|
|
39
15
|
layer.dataState.dataSourceNeedUpdate = true;
|
|
40
16
|
return;
|
|
41
17
|
}
|
|
42
|
-
|
|
18
|
+
|
|
19
|
+
shapeUpdateList.map(function (shapes) {
|
|
43
20
|
if (shapes.includes(lastShape) && shapes.includes(currentShape)) {
|
|
21
|
+
// TODO: dataSourceNeedUpdate 借用数据更新时更新 layer model 的工作流
|
|
44
22
|
layer.dataState.dataSourceNeedUpdate = true;
|
|
45
23
|
return;
|
|
46
24
|
}
|
|
47
25
|
});
|
|
48
26
|
}
|
|
49
|
-
}
|
|
50
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
-
0 && (module.exports = {
|
|
52
|
-
updateShape
|
|
53
|
-
});
|
|
27
|
+
}
|