fl-web-component 2.0.0-beta.8 → 2.0.0

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.
Files changed (33) hide show
  1. package/dist/fl-web-component.common.js +34645 -1611
  2. package/dist/fl-web-component.common.js.map +1 -1
  3. package/dist/fl-web-component.css +1 -1
  4. package/package.json +4 -15
  5. package/packages/components/com-card/index.vue +1 -1
  6. package/packages/components/com-flcanvas/components/bspline.js +31 -34
  7. package/packages/components/com-flcanvas/components/entityFormatting.js +810 -849
  8. package/packages/components/com-flcanvas/components/round10.js +17 -17
  9. package/packages/components/com-flcanvas/index.vue +314 -333
  10. package/packages/components/com-formDialog/index.vue +6 -4
  11. package/packages/components/com-graphics/component/ann-tool.vue +263 -208
  12. package/packages/components/com-graphics/index.vue +366 -773
  13. package/packages/components/com-graphics/pid.vue +304 -295
  14. package/packages/components/com-table/column-default.vue +2 -3
  15. package/packages/components/com-table/column-dynamic.vue +7 -4
  16. package/packages/components/com-table/column.vue +1 -2
  17. package/packages/components/com-table/index.vue +6 -5
  18. package/packages/components/com-tabs/index.vue +1 -2
  19. package/packages/components/com-tiles/index.vue +134 -136
  20. package/packages/components/com-treeDynamic/index.vue +1 -1
  21. package/packages/utils/StreamLoader.js +1548 -1489
  22. package/packages/utils/StreamLoaderParser.worker.js +9 -14
  23. package/src/main.js +2 -8
  24. package/src/utils/cloud.js +28 -28
  25. package/src/utils/cursor.js +11 -9
  26. package/src/utils/flgltf-parser.js +257 -245
  27. package/src/utils/instance-parser.js +20 -22
  28. package/src/utils/mini-devtool.js +94 -39
  29. package/src/utils/threejs/measure-angle.js +51 -13
  30. package/src/utils/threejs/measure-area.js +43 -12
  31. package/src/utils/threejs/measure-distance.js +43 -12
  32. package/src/utils/threejs/rain-shader.js +10 -10
  33. package/src/utils/threejs/snow-shader.js +9 -9
@@ -1,902 +1,863 @@
1
- import bSpline from "./bspline";
2
- import * as THREE from "three";
1
+ import bSpline from './bspline';
2
+ import * as THREE from 'three';
3
3
 
4
4
  //rgb转换
5
5
 
6
6
  function decimalToRGBHex(decimalValue) {
7
- // Ensure the input is a valid integer
8
- if (!Number.isInteger(decimalValue)) {
9
- throw new Error("Input must be an integer.");
10
- }
11
-
12
- // Ensure the input is within the valid range for 24-bit colors
13
- if (decimalValue < 0 || decimalValue > 0xFFFFFF) {
14
- throw new Error("Input must be between 0 and 16777215 (0xFFFFFF).");
15
- }
16
-
17
- // Extract the red, green, and blue components
18
- var red = (decimalValue >> 16) & 0xFF;
19
- var green = (decimalValue >> 8) & 0xFF;
20
- var blue = decimalValue & 0xFF;
21
-
22
- // Convert the RGB components to hexadecimal and format as a string
23
- var hex = "#" + red.toString(16).padStart(2, '0') +
24
- green.toString(16).padStart(2, '0') +
25
- blue.toString(16).padStart(2, '0');
26
-
27
- return {
28
- red: red,
29
- green: green,
30
- blue: blue,
31
- hex: hex.toUpperCase()
32
- };
7
+ // Ensure the input is a valid integer
8
+ if (!Number.isInteger(decimalValue)) {
9
+ throw new Error('Input must be an integer.');
10
+ }
11
+
12
+ // Ensure the input is within the valid range for 24-bit colors
13
+ if (decimalValue < 0 || decimalValue > 0xffffff) {
14
+ throw new Error('Input must be between 0 and 16777215 (0xFFFFFF).');
15
+ }
16
+
17
+ // Extract the red, green, and blue components
18
+ var red = (decimalValue >> 16) & 0xff;
19
+ var green = (decimalValue >> 8) & 0xff;
20
+ var blue = decimalValue & 0xff;
21
+
22
+ // Convert the RGB components to hexadecimal and format as a string
23
+ var hex =
24
+ '#' +
25
+ red.toString(16).padStart(2, '0') +
26
+ green.toString(16).padStart(2, '0') +
27
+ blue.toString(16).padStart(2, '0');
28
+
29
+ return {
30
+ red: red,
31
+ green: green,
32
+ blue: blue,
33
+ hex: hex.toUpperCase(),
34
+ };
33
35
  }
34
36
  export function handleFn(functionName, recordDxf, entity, group, key, configParams, konvaLayer) {
35
- console.log(functionName);
36
-
37
- switch (functionName) {
38
- case 'LINE': drawLine(recordDxf, entity, group, key, configParams)
39
- break;
40
- case 'TEXT': drawText(recordDxf, entity, group, key, configParams)
41
- break;
42
- case 'LWPOLYLINE': drawLwLine(recordDxf, entity, group, key, configParams)
43
- break;
44
- case 'ARC': drawArc(recordDxf, entity, group, key, configParams)
45
- break;
46
- case 'CIRCLE': drawArc(recordDxf, entity, group, key, configParams)
47
- break;
48
- case 'ELLIPSE': drawEllpse(recordDxf, entity, group, key, configParams)
49
- break;
50
- case 'HATCH':drawHatch(recordDxf, entity, group, key, configParams)
51
- break;
52
- //case 'MTEXT': drawMtext(recordDxf, entity, group, key, configParams)
53
- //break;
54
- case 'SPLINE': drawSpline(recordDxf, entity, group, key, configParams)
55
- break;
56
- // case 'INSERT': drawInsert(recordDxf, entity, group, key, configParams, konvaLayer)
57
- // break;
58
- }
37
+ console.log(functionName);
38
+
39
+ switch (functionName) {
40
+ case 'LINE':
41
+ drawLine(recordDxf, entity, group, key, configParams);
42
+ break;
43
+ case 'TEXT':
44
+ drawText(recordDxf, entity, group, key, configParams);
45
+ break;
46
+ case 'LWPOLYLINE':
47
+ drawLwLine(recordDxf, entity, group, key, configParams);
48
+ break;
49
+ case 'ARC':
50
+ drawArc(recordDxf, entity, group, key, configParams);
51
+ break;
52
+ case 'CIRCLE':
53
+ drawArc(recordDxf, entity, group, key, configParams);
54
+ break;
55
+ case 'ELLIPSE':
56
+ drawEllpse(recordDxf, entity, group, key, configParams);
57
+ break;
58
+ case 'HATCH':
59
+ drawHatch(recordDxf, entity, group, key, configParams);
60
+ break;
61
+ //case 'MTEXT': drawMtext(recordDxf, entity, group, key, configParams)
62
+ //break;
63
+ case 'SPLINE':
64
+ drawSpline(recordDxf, entity, group, key, configParams);
65
+ break;
66
+ // case 'INSERT': drawInsert(recordDxf, entity, group, key, configParams, konvaLayer)
67
+ // break;
68
+ }
59
69
  }
60
- export function formatEntity(entities) {
61
- var obj = {}
62
- for (let i = 0; i < entities.length; i++) {
63
- if (obj.hasOwnProperty(entities[i].layer)) {
64
- obj[entities[i].layer].push(entities[i])
65
- } else {
66
- obj[entities[i].layer] = []
67
- obj[entities[i].layer].push(entities[i])
68
- }
70
+ export function formatEntity(entities) {
71
+ var obj = {};
72
+ for (let i = 0; i < entities.length; i++) {
73
+ if (obj.hasOwnProperty(entities[i].layer)) {
74
+ obj[entities[i].layer].push(entities[i]);
75
+ } else {
76
+ obj[entities[i].layer] = [];
77
+ obj[entities[i].layer].push(entities[i]);
69
78
  }
70
- return obj
79
+ }
80
+ return obj;
71
81
  }
72
82
  export function getAbsolutePoints(points) {
73
- let x = 0;
74
- let y = 0;
75
- points.forEach((point, index) => {
76
- if (index % 2 === 0) {
77
- x = x + point;
78
- } else {
79
- y = y + point;
80
- }
81
- });
82
- return {
83
- x: Math.ceil(x / (points.length / 2)),
84
- y: Math.ceil(y / (points.length / 2)),
85
- };
83
+ let x = 0;
84
+ let y = 0;
85
+ points.forEach((point, index) => {
86
+ if (index % 2 === 0) {
87
+ x = x + point;
88
+ } else {
89
+ y = y + point;
90
+ }
91
+ });
92
+ return {
93
+ x: Math.ceil(x / (points.length / 2)),
94
+ y: Math.ceil(y / (points.length / 2)),
95
+ };
86
96
  }
87
97
  export function getColors() {
88
- return colors;
98
+ return colors;
89
99
  }
90
100
  // 居中定位
91
101
  export function centering(obj, container, konvaStage, scaleBy) {
92
- // 由于图纸结构解析的变更 可能最外层的group x y 都是0所以 需要拿到x y有值的group
93
- const filterGroup = obj.filter(item => item.attrs.isGroup && !item.attrs.isMix)
94
- if (filterGroup.length > 0) {
95
- if (filterGroup[0].attrs.hasOwnProperty('isBlock') && filterGroup[0].attrs.isBlock) {
96
- computedCenter(filterGroup[0].attrs.x, filterGroup[0].attrs.y, container, konvaStage, scaleBy)
97
- } else {
98
- const target = obj.filter((item) => !item.attrs.isGroup);
99
- if (target[0].className === "Text") {
100
- computedCenter(target[0].x(), target[0].y(), container, konvaStage, scaleBy)
101
- } else if (target[0].className === "Line") {
102
- const p = getAbsolutePoints(target[0].getPoints());
103
- computedCenter(p.x, p.y, container, konvaStage, scaleBy)
104
- }
105
- }
102
+ // 由于图纸结构解析的变更 可能最外层的group x y 都是0所以 需要拿到x y有值的group
103
+ const filterGroup = obj.filter(item => item.attrs.isGroup && !item.attrs.isMix);
104
+ if (filterGroup.length > 0) {
105
+ if (filterGroup[0].attrs.hasOwnProperty('isBlock') && filterGroup[0].attrs.isBlock) {
106
+ computedCenter(
107
+ filterGroup[0].attrs.x,
108
+ filterGroup[0].attrs.y,
109
+ container,
110
+ konvaStage,
111
+ scaleBy
112
+ );
106
113
  } else {
107
- const target = obj.filter((item) => !item.attrs.isGroup);
108
- if (target[0].className === "Text") {
109
- computedCenter(target[0].x(), target[0].y(), container, konvaStage, scaleBy)
110
- } else if (target[0].className === "Line") {
111
- const p = getAbsolutePoints(target[0].getPoints());
112
- computedCenter(p.x, p.y, container, konvaStage, scaleBy)
113
- }
114
+ const target = obj.filter(item => !item.attrs.isGroup);
115
+ if (target[0].className === 'Text') {
116
+ computedCenter(target[0].x(), target[0].y(), container, konvaStage, scaleBy);
117
+ } else if (target[0].className === 'Line') {
118
+ const p = getAbsolutePoints(target[0].getPoints());
119
+ computedCenter(p.x, p.y, container, konvaStage, scaleBy);
120
+ }
121
+ }
122
+ } else {
123
+ const target = obj.filter(item => !item.attrs.isGroup);
124
+ if (target[0].className === 'Text') {
125
+ computedCenter(target[0].x(), target[0].y(), container, konvaStage, scaleBy);
126
+ } else if (target[0].className === 'Line') {
127
+ const p = getAbsolutePoints(target[0].getPoints());
128
+ computedCenter(p.x, p.y, container, konvaStage, scaleBy);
114
129
  }
130
+ }
115
131
  }
116
132
  // 计算居中位置
117
133
  function computedCenter(x, y, container, konvaStage, scaleBy) {
118
- let newX = container.clientWidth / 2 - x * scaleBy;
119
- let newY = container.clientHeight / 2 -y * scaleBy;
120
- konvaStage.position({ x: newX, y: newY });
134
+ let newX = container.clientWidth / 2 - x * scaleBy;
135
+ let newY = container.clientHeight / 2 - y * scaleBy;
136
+ konvaStage.position({ x: newX, y: newY });
121
137
  }
122
138
 
123
- function getBSplinePolyline(
124
- controlPoints,
125
- degree,
126
- knots,
127
- interpolationsPerSplineSegment,
128
- weights
129
- ) {
130
- const polyline = [];
131
- const controlPointsForLib = controlPoints.map(function (p) {
132
- return [p.x, p.y];
133
- });
134
- const segmentTs = [knots[degree]];
135
- const domain = [knots[degree], knots[knots.length - 1 - degree]];
136
- for (let k = degree + 1; k < knots.length - degree; ++k) {
137
- if (segmentTs[segmentTs.length - 1] !== knots[k]) {
138
- segmentTs.push(knots[k]);
139
- }
139
+ function getBSplinePolyline(controlPoints, degree, knots, interpolationsPerSplineSegment, weights) {
140
+ const polyline = [];
141
+ const controlPointsForLib = controlPoints.map(function (p) {
142
+ return [p.x, p.y];
143
+ });
144
+ const segmentTs = [knots[degree]];
145
+ const domain = [knots[degree], knots[knots.length - 1 - degree]];
146
+ for (let k = degree + 1; k < knots.length - degree; ++k) {
147
+ if (segmentTs[segmentTs.length - 1] !== knots[k]) {
148
+ segmentTs.push(knots[k]);
140
149
  }
141
- interpolationsPerSplineSegment = interpolationsPerSplineSegment || 25;
142
- for (let i = 1; i < segmentTs.length; ++i) {
143
- const uMin = segmentTs[i - 1];
144
- const uMax = segmentTs[i];
145
- for (let k = 0; k <= interpolationsPerSplineSegment; ++k) {
146
- const u = (k / interpolationsPerSplineSegment) * (uMax - uMin) + uMin;
147
- let t = (u - domain[0]) / (domain[1] - domain[0]);
148
- t = Math.max(t, 0);
149
- t = Math.min(t, 1);
150
- const p = bSpline(t, degree, controlPointsForLib, knots, weights);
151
- polyline.push(new THREE.Vector2(p[0], p[1]));
152
- }
150
+ }
151
+ interpolationsPerSplineSegment = interpolationsPerSplineSegment || 25;
152
+ for (let i = 1; i < segmentTs.length; ++i) {
153
+ const uMin = segmentTs[i - 1];
154
+ const uMax = segmentTs[i];
155
+ for (let k = 0; k <= interpolationsPerSplineSegment; ++k) {
156
+ const u = (k / interpolationsPerSplineSegment) * (uMax - uMin) + uMin;
157
+ let t = (u - domain[0]) / (domain[1] - domain[0]);
158
+ t = Math.max(t, 0);
159
+ t = Math.min(t, 1);
160
+ const p = bSpline(t, degree, controlPointsForLib, knots, weights);
161
+ polyline.push(new THREE.Vector2(p[0], p[1]));
153
162
  }
154
- return polyline;
163
+ }
164
+ return polyline;
155
165
  }
156
- function mtextContentAndFormattingToTextAndStyle(
157
- textAndControlChars,
158
- entity,
159
- configParams
160
- ) {
161
- let activeStyle = {
162
- horizontalAlignment: "left",
163
- textHeight: entity.height,
164
- };
165
- var text = [];
166
- for (let item of textAndControlChars) {
167
- if (typeof item === "string") {
168
- if (item.startsWith("pxq") && item.endsWith(";")) {
169
- if (item.indexOf("c") !== -1)
170
- activeStyle.horizontalAlignment = "center";
171
- else if (item.indexOf("l") !== -1)
172
- activeStyle.horizontalAlignment = "left";
173
- else if (item.indexOf("r") !== -1)
174
- activeStyle.horizontalAlignment = "right";
175
- else if (item.indexOf("j") !== -1)
176
- activeStyle.horizontalAlignment = "justify";
177
- } else {
178
- text.push(item);
179
- }
180
- } else if (Array.isArray(item)) {
181
- var nestedFormat = mtextContentAndFormattingToTextAndStyle(
182
- item,
183
- entity,
184
- configParams
185
- );
186
- text.push(nestedFormat.text);
187
- } else if (typeof item === "object") {
188
- if (item["S"] && item["S"].length === 3) {
189
- text.push(item["S"][0] + "/" + item["S"][2]);
190
- } else {
191
- // not yet supported.
192
- }
193
- }
166
+ function mtextContentAndFormattingToTextAndStyle(textAndControlChars, entity, configParams) {
167
+ let activeStyle = {
168
+ horizontalAlignment: 'left',
169
+ textHeight: entity.height,
170
+ };
171
+ var text = [];
172
+ for (let item of textAndControlChars) {
173
+ if (typeof item === 'string') {
174
+ if (item.startsWith('pxq') && item.endsWith(';')) {
175
+ if (item.indexOf('c') !== -1) activeStyle.horizontalAlignment = 'center';
176
+ else if (item.indexOf('l') !== -1) activeStyle.horizontalAlignment = 'left';
177
+ else if (item.indexOf('r') !== -1) activeStyle.horizontalAlignment = 'right';
178
+ else if (item.indexOf('j') !== -1) activeStyle.horizontalAlignment = 'justify';
179
+ } else {
180
+ text.push(item);
181
+ }
182
+ } else if (Array.isArray(item)) {
183
+ var nestedFormat = mtextContentAndFormattingToTextAndStyle(item, entity, configParams);
184
+ text.push(nestedFormat.text);
185
+ } else if (typeof item === 'object') {
186
+ if (item['S'] && item['S'].length === 3) {
187
+ text.push(item['S'][0] + '/' + item['S'][2]);
188
+ } else {
189
+ // not yet supported.
190
+ }
194
191
  }
195
- return {
196
- text: text.join(),
197
- style: activeStyle,
198
- };
192
+ }
193
+ return {
194
+ text: text.join(),
195
+ style: activeStyle,
196
+ };
199
197
  }
200
198
 
201
199
  function drawArc(recordDxf, entity, group, key, configParams) {
202
-
203
- let color=entity.color;
204
- let rgb=decimalToRGBHex(color);
205
- console.log(rgb);
206
- let hex=rgb.hex;
207
- let startAngle, endAngle;
208
- if (entity.type === "CIRCLE") {
209
- startAngle = entity.startAngle || 0;
210
- endAngle = startAngle + 2 * Math.PI;
211
- } else {
212
- startAngle = entity.startAngle;
213
- endAngle = entity.endAngle;
214
- }
215
- let curve = new THREE.ArcCurve(
216
- entity.center.x,
217
- parseFloat(entity.center.y),
218
- entity.radius,
219
- startAngle,
220
- endAngle
221
- );
222
- let points = curve.getPoints(32);
223
-
224
- let list = [];
225
- for (let i = 0; i < points.length; i++) {
226
- list.push(points[i].x);
227
- list.push(-parseFloat(points[i].y));
228
- }
229
- let width = 0.2;
230
- group.push({
231
- type:'polyline',
232
- points:list,
233
- name: key.replace(/\s*/g, ""),
234
- entityId: key,
235
- stroke: hex,
236
- customColor: configParams ? configParams.color : "",
237
- strokeWidth: width,
238
- visible: configParams ? configParams.visible :true,
239
- oldstrokeLength:width
240
- });
241
- // if(group.attrs.isBlock){
242
- // let scale=group.scale();
243
- // width=width/Math.abs(scale.x);
244
- // }
245
- // let line = new Konva.Line({
246
- // name: key.replace(/\s*/g, ""),
247
- // entityId: key,
248
- // isGroup: false,
249
- // points: list,
250
- // stroke: configParams ? configParams.color : "#000",
251
- // customColor: configParams ? configParams.color : "",
252
- // strokeWidth: width,
253
- // lineCap: "round",
254
- // lineJoin: "round",
255
- // visible: configParams ? configParams.visible :true,
256
- // oldstrokeLength:width
257
- // });
258
- // group.add(line);
200
+ let color = entity.color;
201
+ let rgb = decimalToRGBHex(color);
202
+ console.log(rgb);
203
+ let hex = rgb.hex;
204
+ let startAngle, endAngle;
205
+ if (entity.type === 'CIRCLE') {
206
+ startAngle = entity.startAngle || 0;
207
+ endAngle = startAngle + 2 * Math.PI;
208
+ } else {
209
+ startAngle = entity.startAngle;
210
+ endAngle = entity.endAngle;
211
+ }
212
+ let curve = new THREE.ArcCurve(
213
+ entity.center.x,
214
+ parseFloat(entity.center.y),
215
+ entity.radius,
216
+ startAngle,
217
+ endAngle
218
+ );
219
+ let points = curve.getPoints(32);
220
+
221
+ let list = [];
222
+ for (let i = 0; i < points.length; i++) {
223
+ list.push(points[i].x);
224
+ list.push(-parseFloat(points[i].y));
225
+ }
226
+ let width = 0.2;
227
+ group.push({
228
+ type: 'polyline',
229
+ points: list,
230
+ name: key.replace(/\s*/g, ''),
231
+ entityId: key,
232
+ stroke: hex,
233
+ customColor: configParams ? configParams.color : '',
234
+ strokeWidth: width,
235
+ visible: configParams ? configParams.visible : true,
236
+ oldstrokeLength: width,
237
+ });
238
+ // if(group.attrs.isBlock){
239
+ // let scale=group.scale();
240
+ // width=width/Math.abs(scale.x);
241
+ // }
242
+ // let line = new Konva.Line({
243
+ // name: key.replace(/\s*/g, ""),
244
+ // entityId: key,
245
+ // isGroup: false,
246
+ // points: list,
247
+ // stroke: configParams ? configParams.color : "#000",
248
+ // customColor: configParams ? configParams.color : "",
249
+ // strokeWidth: width,
250
+ // lineCap: "round",
251
+ // lineJoin: "round",
252
+ // visible: configParams ? configParams.visible :true,
253
+ // oldstrokeLength:width
254
+ // });
255
+ // group.add(line);
259
256
  }
260
257
 
261
258
  function drawEllpse(recordDxf, entity, group, key, configParams) {
262
- let xrad = Math.sqrt(
263
- Math.pow(parseFloat(entity.majorAxisEndPoint.x), 2) +
264
- Math.pow(parseFloat(entity.majorAxisEndPoint.y), 2)
265
- );
266
- let yrad = xrad * parseFloat(entity.axisRatio);
267
- let rotation = Math.atan2(
268
- parseFloat(entity.majorAxisEndPoint.y),
269
- parseFloat(entity.majorAxisEndPoint.x)
270
- );
271
- console.log(entity.startAngle);
272
- console.log(entity.endAngle);
273
- let curve = new THREE.EllipseCurve(
274
- parseFloat(entity.center.x),
275
- parseFloat(entity.center.y),
276
- xrad,
277
- yrad,
278
- parseFloat(entity.startAngle),
279
- parseFloat(entity.endAngle),
280
- false, // Always counterclockwise
281
- rotation
282
- );
283
- let points = curve.getPoints(200);
284
- let list = [];
285
- for (let i = 0; i < points.length; i++) {
286
- list.push(points[i].x);
287
- list.push(-parseFloat(points[i].y));
288
- }
289
- let width = 0.2;
290
-
291
-
292
-
293
- group.push({
294
- type:'polyline',
295
- points:list,
296
- name: key.replace(/\s*/g, ""),
297
- entityId: key,
298
- stroke: configParams ? configParams.color : "#000",
299
- customColor: configParams ? configParams.color : "",
300
- strokeWidth: width,
301
- visible: configParams ? configParams.visible : true,
302
- oldstrokeLength:width
303
- });
304
- // let line = new Konva.Line({
305
- // name: key.replace(/\s*/g, ""),
306
- // entityId: key,
307
- // isGroup: false,
308
- // points: list,
309
- // stroke: configParams ? configParams.color : "#000",
310
- // customColor: configParams ? configParams.color : "",
311
- // strokeWidth: width,
312
- // lineCap: "round",
313
- // lineJoin: "round",
314
- // visible: configParams ? configParams.visible : true,
315
- // oldstrokeLength:width
316
-
317
- // });
318
- // group.add(line);
259
+ let xrad = Math.sqrt(
260
+ Math.pow(parseFloat(entity.majorAxisEndPoint.x), 2) +
261
+ Math.pow(parseFloat(entity.majorAxisEndPoint.y), 2)
262
+ );
263
+ let yrad = xrad * parseFloat(entity.axisRatio);
264
+ let rotation = Math.atan2(
265
+ parseFloat(entity.majorAxisEndPoint.y),
266
+ parseFloat(entity.majorAxisEndPoint.x)
267
+ );
268
+ console.log(entity.startAngle);
269
+ console.log(entity.endAngle);
270
+ let curve = new THREE.EllipseCurve(
271
+ parseFloat(entity.center.x),
272
+ parseFloat(entity.center.y),
273
+ xrad,
274
+ yrad,
275
+ parseFloat(entity.startAngle),
276
+ parseFloat(entity.endAngle),
277
+ false, // Always counterclockwise
278
+ rotation
279
+ );
280
+ let points = curve.getPoints(200);
281
+ let list = [];
282
+ for (let i = 0; i < points.length; i++) {
283
+ list.push(points[i].x);
284
+ list.push(-parseFloat(points[i].y));
285
+ }
286
+ let width = 0.2;
287
+
288
+ group.push({
289
+ type: 'polyline',
290
+ points: list,
291
+ name: key.replace(/\s*/g, ''),
292
+ entityId: key,
293
+ stroke: configParams ? configParams.color : '#000',
294
+ customColor: configParams ? configParams.color : '',
295
+ strokeWidth: width,
296
+ visible: configParams ? configParams.visible : true,
297
+ oldstrokeLength: width,
298
+ });
299
+ // let line = new Konva.Line({
300
+ // name: key.replace(/\s*/g, ""),
301
+ // entityId: key,
302
+ // isGroup: false,
303
+ // points: list,
304
+ // stroke: configParams ? configParams.color : "#000",
305
+ // customColor: configParams ? configParams.color : "",
306
+ // strokeWidth: width,
307
+ // lineCap: "round",
308
+ // lineJoin: "round",
309
+ // visible: configParams ? configParams.visible : true,
310
+ // oldstrokeLength:width
311
+
312
+ // });
313
+ // group.add(line);
319
314
  }
320
315
  function drawLine(recordDxf, entity, group, key, configParams) {
321
- let color=entity.color;
322
- let rgb=decimalToRGBHex(color);
323
- console.log(rgb);
324
- let hex=rgb.hex;
325
- let x1 = entity.vertices[0].x;
326
- let y1 = entity.vertices[0].y;
327
- let x2 = entity.vertices[1].x;
328
- let y2 = entity.vertices[1].y;
329
- let width = 0.2;
330
- group.push({
331
- type:"line",
332
- x1:x1,
333
- x2:x2,
334
- y1:y1,
335
- y2:y2,
336
- name: key.replace(/\s*/g, ""),
337
- entityId: key,
338
- isGroup: false,
339
- stroke: hex,
340
- customColor: configParams ? configParams.color : "",
341
- strokeWidth: width,
342
- visible: configParams ? configParams.visible : true,
343
- oldstrokeLength:width,
344
- });
345
- // if(group.attrs.isBlock){
346
- // let scale=group.scale();
347
- // width=width/Math.abs(scale.x);
348
- // }
349
- // let line = new Konva.Line({
350
- // name: key.replace(/\s*/g, ""),
351
- // entityId: key,
352
- // isGroup: false,
353
- // points: [x1, -parseFloat(y1), parseFloat(x2), -parseFloat(y2)],
354
- // stroke: configParams ? configParams.color : "#000",
355
- // customColor: configParams ? configParams.color : "",
356
- // strokeWidth: width,
357
- // //lineCap: "round",
358
- // //lineJoin: "round",
359
- // visible: configParams ? configParams.visible : true,
360
- // oldstrokeLength:width,
361
- // handle:entity.handle
362
-
363
- // });
364
-
365
- // group.add(line);
316
+ let color = entity.color;
317
+ let rgb = decimalToRGBHex(color);
318
+ console.log(rgb);
319
+ let hex = rgb.hex;
320
+ let x1 = entity.vertices[0].x;
321
+ let y1 = entity.vertices[0].y;
322
+ let x2 = entity.vertices[1].x;
323
+ let y2 = entity.vertices[1].y;
324
+ let width = 0.2;
325
+ group.push({
326
+ type: 'line',
327
+ x1: x1,
328
+ x2: x2,
329
+ y1: y1,
330
+ y2: y2,
331
+ name: key.replace(/\s*/g, ''),
332
+ entityId: key,
333
+ isGroup: false,
334
+ stroke: hex,
335
+ customColor: configParams ? configParams.color : '',
336
+ strokeWidth: width,
337
+ visible: configParams ? configParams.visible : true,
338
+ oldstrokeLength: width,
339
+ });
340
+ // if(group.attrs.isBlock){
341
+ // let scale=group.scale();
342
+ // width=width/Math.abs(scale.x);
343
+ // }
344
+ // let line = new Konva.Line({
345
+ // name: key.replace(/\s*/g, ""),
346
+ // entityId: key,
347
+ // isGroup: false,
348
+ // points: [x1, -parseFloat(y1), parseFloat(x2), -parseFloat(y2)],
349
+ // stroke: configParams ? configParams.color : "#000",
350
+ // customColor: configParams ? configParams.color : "",
351
+ // strokeWidth: width,
352
+ // //lineCap: "round",
353
+ // //lineJoin: "round",
354
+ // visible: configParams ? configParams.visible : true,
355
+ // oldstrokeLength:width,
356
+ // handle:entity.handle
357
+
358
+ // });
359
+
360
+ // group.add(line);
366
361
  }
367
- function drawText(recordDxf, entity, group, key, configParams) {
368
- let color=entity.color;
369
- let rgb=decimalToRGBHex(color);
370
- console.log(rgb);
371
- let hex=rgb.hex;
372
362
 
373
- if(hex=='#FFFFFF'){
374
- hex='#000';
363
+ function drawText(recordDxf, entity, group, key, configParams) {
364
+ let color = entity.color;
365
+ let rgb = decimalToRGBHex(color);
366
+ console.log(rgb);
367
+ let hex = rgb.hex;
368
+
369
+ if (hex == '#FFFFFF') {
370
+ hex = '#000';
371
+ }
372
+ let text = entity.text;
373
+ const fontSize = entity.textHeight;
374
+
375
+ // 与 AutoCAD TEXT 一致:绕插入点对齐锚点旋转;Y 轴翻转后角度用 360°-θ
376
+ const insert =
377
+ entity.endPoint && (entity.halign !== undefined || entity.valign !== undefined)
378
+ ? entity.endPoint
379
+ : entity.startPoint;
380
+
381
+ const dim = new Konva.Text({
382
+ x: 0,
383
+ y: 0,
384
+ text: text,
385
+ fontSize: fontSize,
386
+ align: 'left',
387
+ verticalAlign: 'top',
388
+ fill: hex,
389
+ customColor: configParams ? configParams.color : '',
390
+ name: key.replace(/\s*/g, ''),
391
+ entityId: key,
392
+ fontFamily: 'SimSun',
393
+ visible: configParams ? configParams.visible : true,
394
+ stroke: hex,
395
+ strokeWidth: 0.1,
396
+ });
397
+
398
+ if (entity.xScale) {
399
+ dim.scaleX(entity.xScale);
400
+ }
401
+
402
+ const tw = dim.width();
403
+ const th = dim.height();
404
+ const lh = dim.lineHeight() || 1;
405
+ // 用字体度量计算锚点,避免 valign=2(中线) 与 baseline 近似重合
406
+ let ascent = fontSize * lh * 0.8;
407
+ let descent = fontSize * lh * 0.2;
408
+ try {
409
+ const metrics = dim.measureSize(text || 'M');
410
+ const mAscent = metrics?.fontBoundingBoxAscent ?? metrics?.actualBoundingBoxAscent;
411
+ const mDescent = metrics?.fontBoundingBoxDescent ?? metrics?.actualBoundingBoxDescent;
412
+ if (typeof mAscent === 'number' && mAscent > 0) {
413
+ ascent = mAscent;
375
414
  }
376
- let text = entity.text;
377
- let fontSize=0;
378
- if(key==0){
379
- fontSize=entity.textHeight+0.35;
380
- }else{
381
- fontSize=entity.textHeight+0.35;
415
+ if (typeof mDescent === 'number' && mDescent >= 0) {
416
+ descent = mDescent;
382
417
  }
418
+ } catch (e) {
419
+ // ignore
420
+ }
421
+ const baselineOffset = ascent;
422
+
423
+ const halign = entity.halign != null ? Number(entity.halign) : 0;
424
+ const valign = entity.valign != null ? Number(entity.valign) : 0;
425
+
426
+ let anchorX = 0;
427
+ if (halign === 1 || halign === 4) {
428
+ anchorX = tw / 2;
429
+ } else if (halign === 2) {
430
+ anchorX = tw;
431
+ }
432
+
433
+ let anchorY = baselineOffset;
434
+ if (valign === 3) {
435
+ anchorY = 0;
436
+ } else if (valign === 2) {
437
+ // DXF Middle: 使用字形上下边界中心,而不是 Konva 文本框中心
438
+ anchorY = (ascent + descent) / 2;
439
+ } else if (valign === 1) {
440
+ anchorY = ascent + descent;
441
+ }
442
+
443
+ dim.x(-anchorX);
444
+ dim.y(-anchorY);
445
+
446
+ const rotation = Number(entity.rotation || 0);
447
+ const g = new Konva.Group({
448
+ x: parseFloat(insert.x),
449
+ y: -parseFloat(insert.y),
450
+ rotation: 360 - rotation,
451
+ name: key.replace(/\s*/g, ''),
452
+ entityId: key,
453
+ visible: configParams ? configParams.visible : true,
454
+ customColor: configParams ? configParams.color : '',
455
+ });
456
+ g.add(dim);
457
+
458
+ group.push({
459
+ type: 'text',
460
+ obj: g,
461
+ });
462
+ // group.add(dim);
463
+ }
383
464
 
465
+ function drawHatch(recordDxf, entity, group, key, configParams) {
466
+ console.log('hatch');
467
+ }
384
468
 
385
- let startPoint = entity.startPoint;
386
- let x = startPoint.x;
387
- let y = startPoint.y;
388
- let dim = new Konva.Text({
389
- x: parseFloat(x),
390
- y: -parseFloat(y),
391
- text: text,
392
- fontSize: fontSize,
393
- fill: hex,
394
- customColor: configParams ? configParams.color : "",
395
- name: key.replace(/\s*/g, ""),
396
- entityId: key,
397
- fontFamily: "SimSun",
398
- visible: configParams ? configParams.visible : true,
399
- stroke: hex,
400
- strokeWidth:0.1,
469
+ function drawLwLine(recordDxf, entity, group, key, configParams) {
470
+ let color = entity.color;
471
+ let rgb = decimalToRGBHex(color);
472
+ console.log(rgb);
473
+ let hex = rgb.hex;
474
+
475
+ if (hex == '#FFFFFF') {
476
+ hex = '#000';
477
+ }
478
+ let closed = entity.shape;
479
+ let list = [];
480
+ for (let i = 0; i < entity.vertices.length; i++) {
481
+ list.push(entity.vertices[i].x);
482
+ list.push(-parseFloat(entity.vertices[i].y));
483
+ }
484
+ let width = 0.2;
485
+ if (entity.width) {
486
+ width = width + parseFloat(entity.width);
487
+ } else {
488
+ width = 0.2;
489
+ }
490
+ group.push({
491
+ type: 'polyline',
492
+ points: list,
493
+ closed: closed,
494
+ name: key.replace(/\s*/g, ''),
495
+ entityId: key,
496
+ stroke: hex,
497
+ customColor: configParams ? configParams.color : '',
498
+ strokeWidth: width,
499
+ visible: configParams ? configParams.visible : true,
500
+ oldstrokeLength: width,
501
+ });
502
+ // let line = new Konva.Line({
503
+ // name: key.replace(/\s*/g, ""),
504
+ // entityId: key,
505
+ // isGroup: false,
506
+ // points: list,
507
+ // stroke: configParams ? configParams.color : "#000",
508
+ // customColor: configParams ? configParams.color : "",
509
+ // strokeWidth: width,
510
+ // visible: configParams ? configParams.visible : true,
511
+ // closed:closed,
512
+ // oldstrokeLength:width,
513
+ // handle:entity.handle
514
+
515
+ // });
516
+ // group.add(line);
517
+ }
518
+ function drawSpline(recordDxf, entity, group, key, configParams) {
519
+ let points = getBSplinePolyline(
520
+ entity.controlPoints,
521
+ entity.degreeOfSplineCurve,
522
+ entity.knotValues,
523
+ 100
524
+ );
525
+ let list = [];
526
+ for (let i = 0; i < points.length; i++) {
527
+ list.push(points[i].x);
528
+ list.push(-parseFloat(points[i].y));
529
+ }
530
+ let width = 0.1;
531
+ group.push({
532
+ type: 'polyline',
533
+ points: list,
534
+ name: key.replace(/\s*/g, ''),
535
+ entityId: key,
536
+ isGroup: false,
537
+ stroke: configParams ? configParams : '#000',
538
+ customColor: configParams ? configParams.color : '',
539
+ strokeWidth: width,
540
+ visible: configParams ? configParams.visible : true,
541
+ oldstrokeLength: width,
542
+ });
543
+ // let line = new Konva.Line({
544
+ // name: key.replace(/\s*/g, ""),
545
+ // entityId: key,
546
+ // isGroup: false,
547
+ // points: list,
548
+ // stroke: configParams ? configParams : "#000",
549
+ // customColor: configParams ? configParams.color : "",
550
+ // strokeWidth: width,
551
+ // lineCap: "round",
552
+ // lineJoin: "round",
553
+ // visible: configParams ? configParams.visible : true,
554
+ // oldstrokeLength:width
555
+ // });
556
+ // group.add(line);
557
+ }
558
+ function drawInsert(recordDxf, entities, group, key, configParams, konvaLayer) {
559
+ if (recordDxf.blocks[entities.name]) {
560
+ let group2 = new Konva.Group({
561
+ x: 0,
562
+ y: 0,
563
+ name: key.replace(/\s*/g, ''),
564
+ isBlock: true,
565
+ blockName: entities.name,
566
+ entityId: key,
567
+ isGroup: true,
568
+ visible: true,
401
569
  });
402
- let width=dim.getTextWidth()
403
- //let clientRect=dim.getClientRect()
404
- //let clientWidth=clientRect.width;
405
-
406
- if(entity.halign){
407
- if(entity.halign==1){
408
- dim.attrs.x= dim.attrs.x-(width/2);
409
- }
410
- }
411
-
412
-
570
+ let entity = entities;
571
+ let block = recordDxf.blocks[entities.name];
413
572
  if (entity.rotation) {
414
- if(entity.rotation==90||parseInt(entity.rotation)==90||parseInt(entity.rotation)==89||parseInt(entity.rotation)==450) {
415
- dim.attrs.x = parseFloat(x) - fontSize;
416
- }
417
- if(entity.rotation==270||parseInt(entity.rotation)==270)
418
- {
419
- dim.attrs.x = parseFloat(x) + fontSize;
420
- }
421
- if(entity.rotation==180||parseInt(entity.rotation)==180){
422
- dim.attrs.y= -parseFloat(y) - fontSize;
423
- }
424
- if(entity.rotation==360||parseFloat(entity.rotation)==360){
425
- dim.attrs.y= -parseFloat(y) - fontSize;
426
- }
427
- if(parseInt(entity.rotation)==30||parseInt(entity.rotation)==29) {
428
- //dim.attrs.x= parseFloat(x) -200;
429
-
430
- //console.log("rect");
431
- //console.log(rect);
432
- dim.attrs.y= -parseFloat(y) - fontSize*0.85;
433
- dim.attrs.x = parseFloat(x) - fontSize*0.85;
434
- if(text.length>9){
435
- let width=dim.getTextWidth()
436
- //let clientRect=dim.getClientRect()
437
- //let clientWidth=clientRect.width;
438
- dim.attrs.y= -parseFloat(y) +fontSize;
439
- if(entity.halign){
440
- if(entity.halign==1){
441
- dim.attrs.x= dim.attrs.x-(width/2);
442
- }
443
-
444
- }
445
- if (entity.valign === 3) { // Middle
446
- dim.attrs.x= dim.attrs.x+1;
447
- dim.attrs.y = -parseFloat(y) +fontSize*1.8 ;
448
- }
449
- }else{
450
- if (entity.valign === 3) { // Middle
451
- dim.attrs.x= dim.attrs.x+1;
452
- dim.attrs.y = -parseFloat(y) ;
453
- }
454
- }
455
- }
456
- if(parseInt(entity.rotation)==330||parseInt(entity.rotation)==329) {
457
- //dim.attrs.x= parseFloat(x) -200;
458
-
459
- //console.log("rect");
460
- //console.log(rect);
461
- dim.attrs.y= -parseFloat(y) -fontSize;
462
- dim.attrs.x = parseFloat(x) +0.5;
463
- }
464
- if(parseInt(entity.rotation)==60||parseInt(entity.rotation)==60) {
465
- //dim.attrs.x= parseFloat(x) -200;
466
-
467
- //console.log("rect");
468
- //console.log(rect);
469
- dim.attrs.y= -parseFloat(y) ;
470
- dim.attrs.x = parseFloat(x) -fontSize;
471
- }
472
-
473
-
474
- // dim.attrs.y= -parseFloat(y)+ fontSize*0.8;
475
-
476
- dim.attrs.rotation = 360-entity.rotation ;
477
-
478
- }else{
479
-
480
- // 支持 DXF 垂直对齐(valign),仅在未旋转时按插入点对齐
481
- if (entity.valign === 2) { // Middle
482
- dim.attrs.y = -parseFloat(y) - fontSize / 2;
483
- } else if (entity.valign === 3) { // Top
484
- dim.attrs.y = -parseFloat(y);
485
- } else { // Baseline / Bottom 或未设置,保持原逻辑
486
- dim.attrs.y = -parseFloat(y) - fontSize;
487
- }
573
+ group2.rotation(360 - entity.rotation);
488
574
  }
575
+
489
576
  if (entity.xScale) {
490
- dim.attrs.fontSize =(fontSize+0.35)* entity.xScale;
577
+ group2.scale({ x: entity.xScale, y: entity.yScale });
491
578
  }
492
-
493
-
494
-
495
- //dim.attrs.x= dim.attrs.x-parseFloat(2);
496
- group.push({
497
- "type":'text',
498
- 'obj':dim,
499
- })
500
- // group.add(dim);
501
- }
502
-
503
- function drawHatch(recordDxf,entity,group,key,configParams){
504
-
505
- console.log("hatch");
506
- }
507
-
508
- function drawLwLine(recordDxf, entity, group, key, configParams) {
509
- let color=entity.color;
510
- let rgb=decimalToRGBHex(color);
511
- console.log(rgb);
512
- let hex=rgb.hex;
513
-
514
- if(hex=='#FFFFFF'){
515
- hex='#000';
579
+ if (entity.yScale) {
580
+ group2.scale({ x: entity.xScale, y: entity.yScale });
516
581
  }
517
- let closed = entity.shape;
518
- let list=[];
519
- for(let i =0;i<entity.vertices.length;i++){
520
- list.push(entity.vertices[i].x);
521
- list.push(-parseFloat(entity.vertices[i].y));
582
+ if (entity.position) {
583
+ group2.attrs.x = parseFloat(entity.position.x);
584
+ group2.attrs.y = -parseFloat(entity.position.y);
522
585
  }
523
- let width = 0.2;
524
- if(entity.width){
525
- width=width+parseFloat(entity.width);
526
- }else{
527
- width=0.2;
586
+ if (entity.position.x < 0) {
587
+ group2.attrs.x = parseFloat(entity.position.x) * -1;
588
+ if (entity.xScale < 0) {
589
+ group2.scale({ x: Math.abs(entity.xScale), y: entity.yScale });
590
+ }
528
591
  }
529
- group.push({
530
- type:"polyline",
531
- points:list,
532
- closed:closed,
533
- name: key.replace(/\s*/g, ""),
534
- entityId: key,
535
- stroke: hex,
536
- customColor: configParams ? configParams.color : "",
537
- strokeWidth: width,
538
- visible: configParams ? configParams.visible : true,
539
- oldstrokeLength:width,
540
- })
541
- // let line = new Konva.Line({
542
- // name: key.replace(/\s*/g, ""),
543
- // entityId: key,
544
- // isGroup: false,
545
- // points: list,
546
- // stroke: configParams ? configParams.color : "#000",
547
- // customColor: configParams ? configParams.color : "",
548
- // strokeWidth: width,
549
- // visible: configParams ? configParams.visible : true,
550
- // closed:closed,
551
- // oldstrokeLength:width,
552
- // handle:entity.handle
553
-
554
- // });
555
- // group.add(line);
556
- }
557
- function drawSpline(recordDxf, entity, group, key, configParams) {
558
- let points = getBSplinePolyline(
559
- entity.controlPoints,
560
- entity.degreeOfSplineCurve,
561
- entity.knotValues,
562
- 100
563
- );
564
- let list = [];
565
- for (let i = 0; i < points.length; i++) {
566
- list.push(points[i].x);
567
- list.push(-parseFloat(points[i].y));
592
+ if (block.entities == undefined) {
593
+ return;
568
594
  }
569
- let width = 0.1;
570
- group.push({
571
- type:'polyline',
572
- points: list,
573
- name: key.replace(/\s*/g, ""),
574
- entityId: key,
575
- isGroup: false,
576
- stroke: configParams ? configParams : "#000",
577
- customColor: configParams ? configParams.color : "",
578
- strokeWidth: width,
579
- visible: configParams ? configParams.visible : true,
580
- oldstrokeLength: width
581
- });
582
- // let line = new Konva.Line({
583
- // name: key.replace(/\s*/g, ""),
584
- // entityId: key,
585
- // isGroup: false,
586
- // points: list,
587
- // stroke: configParams ? configParams : "#000",
588
- // customColor: configParams ? configParams.color : "",
589
- // strokeWidth: width,
590
- // lineCap: "round",
591
- // lineJoin: "round",
592
- // visible: configParams ? configParams.visible : true,
593
- // oldstrokeLength:width
594
- // });
595
- // group.add(line);
596
- }
597
- function drawInsert(recordDxf, entities, group, key, configParams, konvaLayer) {
598
- if (recordDxf.blocks[entities.name]) {
599
- let group2 = new Konva.Group({
600
- x: 0,
601
- y: 0,
602
- name: key.replace(/\s*/g, ""),
603
- isBlock: true,
604
- blockName: entities.name,
605
- entityId: key,
606
- isGroup: true,
607
- visible: true,
608
- });
609
- let entity = entities;
610
- let block = recordDxf.blocks[entities.name];
611
- if (entity.rotation) {
612
- group2.rotation(360-entity.rotation);
613
- }
614
-
615
- if (entity.xScale) {
616
- group2.scale({ x: entity.xScale, y: entity.yScale });
617
- }
618
- if (entity.yScale) {
619
- group2.scale({ x: entity.xScale, y: entity.yScale });
620
- }
621
- if (entity.position) {
622
- group2.attrs.x = parseFloat(entity.position.x);
623
- group2.attrs.y = -parseFloat(entity.position.y);
624
- }
625
- if(entity.position.x<0){
626
- group2.attrs.x = parseFloat(entity.position.x)*-1;
627
- if(entity.xScale<0){
628
- group2.scale({ x: Math.abs(entity.xScale), y: entity.yScale });
629
- }
630
- }
631
- if(block.entities==undefined){
632
- return ;
633
- }
634
- for (let j = 0; j < block.entities.length; j++) {
635
- let type = block.entities[j].type;
636
- handleFn(type, recordDxf, block.entities[j], group2, key, configParams, konvaLayer)
637
- }
638
- group.add(group2)
639
- // 区分块 因为有的块里面包含块 不区分会对点击定位有影响
640
- group.attrs.isMix = true
641
- konvaLayer.add(group)
595
+ for (let j = 0; j < block.entities.length; j++) {
596
+ let type = block.entities[j].type;
597
+ handleFn(type, recordDxf, block.entities[j], group2, key, configParams, konvaLayer);
642
598
  }
599
+ group.add(group2);
600
+ // 区分块 因为有的块里面包含块 不区分会对点击定位有影响
601
+ group.attrs.isMix = true;
602
+ konvaLayer.add(group);
603
+ }
643
604
  }
644
605
 
645
- let color= [
646
- '0,0,0',//1
647
- '255,0,0',//2
648
- '255,255,0',//3
649
- '0,255,0',//4
650
- '0,255,255',//5
651
- '0,0,255',//6
652
- '255,0,255',//7
653
- '255,255,255',//8
654
- '128,128,128',//9
655
- '192,192,192',//10
656
- '255,0,0',//11
657
- '255,120,112',//12
658
- '192,0,0',//13
659
- '207,103,96',//14
660
- '144,0,0',//15
661
- '144,72,79',//16
662
- '127,0,0',//17
663
- '112,56,48',//18
664
- '79,0,0',//19
665
- '79,39,32',//20
666
- '255,56,0',//21
667
- '255,159,127',//22
668
- '192,48,0',//23
669
- '207,127,96',//24
670
- '144,32,0',//25
671
- '144,88,64',// 26
672
- '112,24,0',//27
673
- '127,72,63',//28
674
- '79,16,0',//29
675
- '64,40,31',//30
676
- '255,127,0',//31
677
- '255,191,127',//32
678
- '207,103,0',//33
679
- '192,151,96',//34
680
- '159,72,0',//35
681
- '144,112,79',//36
682
- '127,63,0',//37
683
- '127,95,63',//38
684
- '64,32,0',//39
685
- '64,55,31',//40
686
- '255,191,0',// 41
687
- '255,216,127',//42
688
- '207,152,0',//43
689
- '192,175,96',//44
690
- '144,112,0',//45
691
- '144,128,64',//46
692
- '112,88,0',//47
693
- '127,111,63',//48
694
- '64,55,0',//49
695
- '64,63,31',//50
696
- '255,255,0',//51
697
- '255,255,112',//52
698
- '207,200,0',//53
699
- '192,200,96',//54
700
- '144,151,0',//55
701
- '144,151,64',//56
702
- '144,152,0',//57
703
- '127,120,63',//58
704
- '79,72,0',//59
705
- '79,72,32',//60
706
- '191,255,0',//61
707
- '208,255,112',//62
708
- '144,200,0',//63
709
- '176,200,96',//64
710
- '111,151,0',//65
711
- '128,151,79',//66
712
- '95,127,0',//67
713
- '111,127,63',//68
714
- '48,72,0',//69
715
- '63,72,31',//70
716
- '127,255,0',//71
717
- '191,255,127',//72
718
- '95,200,0',//73
719
- '159,200,96',//74
720
- '64,151,0',//75
721
- '111,151,64',//76
722
- '63,120,0',//77
723
- '95,127,63',//78
724
- '31,72,0',//79
725
- '48,72,32',//80
726
- '63,255,0',//81
727
- '159,255,127',//82
728
- '47,200,0',//83
729
- '127,200,96',//84
730
- '31,151,0',//85
731
- '80,151,64',//86
732
- '31,127,0',//87
733
- '79,127,63',//88
734
- '15,72,0',//89
735
- '47,72,32',//90
736
- '0,255,0',//91
737
- '127,255,127',//92
738
- '0,200,0',//93
739
- '95,200,95',//94
740
- '0,151,0',//95
741
- '79,151,79',//96
742
- '0,127,0',//97
743
- '63,127,63',//98
744
- '0,72,0',//99
745
- '32,72,32',//100
746
- '0,255,63',//101
747
- '127,255,159',//102
748
- '0,200,47',//103
749
- '95,200,112',//104
750
- '0,151,32',//105
751
- '64,151,95',//106
752
- '0,120,31',//107
753
- '63,127,79',//108
754
- '0,72,15',//109
755
- '32,72,47',//110
756
- '0,255,127',//111
757
- '127,255,191',//112
758
- '0,200,96',//113
759
- '95,200,144',//114
760
- '0,151,64',//115
761
- '79,151,111',//116
762
- '0,127,63',//117
763
- '63,127,95',//118
764
- '0,72,32',//119
765
- '31,72,48',//120
766
- '0,255,191',//121
767
- '127,255,223',//122
768
- '0,200,144',//123
769
- '95,200,175',//124
770
- '0,151,111',//125
771
- '79,151,128',//126
772
- '0,120,95',//127
773
- '63,127,111',//128
774
- '0,72,48',//129
775
- '32,72,63',//130
776
- '0,255,255',//131
777
- '127,255,255',//132
778
- '0,200,207',//133
779
- '96,200,207',//134
780
- '0,151,144',//135
781
- '64,151,144',//136
782
- '0,127,127',//137
783
- '63,127,127',//138
784
- '0,72,79',//139
785
- '32,72,79',//140
786
- '0,191,255',//141
787
- '127,223,255',//142
788
- '0,152,207',//143
789
- '96,176,207',//144
790
- '0,111,144',//145
791
- '64,128,144',//146
792
- '0,95,127',//147
793
- '63,111,127',//148
794
- '0,55,64',//149
795
- '31,63,64',//150
796
- '0,127,255',//151
797
- '112,184,255',//152
798
- '0,96,192',//153
799
- '96,151,207',//154
800
- '0,72,159',//155
801
- '79,112,144',//156
802
- '0,63,127',//157
803
- '63,95,127',//158
804
- '0,39,79',//159
805
- '32,56,79',//160
806
- '0,63,255',//161
807
- '127,159,255',//162
808
- '0,48,207',//163
809
- '96,127,207',//164
810
- '0,39,159',//165
811
- '64,95,144',//166
812
- '0,24,127',//167
813
- '63,79,127',//168
814
- '0,15,64',//169
815
- '32,47,79',//170
816
- '0,0,255',//171
817
- '127,127,255',//172
818
- '0,0,207',//173
819
- '95,96,192',//174
820
- '0,0,144',//175
821
- '79,72,159',//176
822
- '0,0,127',//177
823
- '63,63,127',//178
824
- '0,0,64',//179
825
- '32,39,79',//180
826
- '63,0,255',//181
827
- '159,127,255',//182
828
- '47,0,192',//183
829
- '127,103,207',//184
830
- '32,0,144',//185
831
- '80,72,144',//186
832
- '31,0,127',//187
833
- '79,63,127',//188
834
- '15,0,79',//189
835
- '47,39,79',//190
836
- '127,0,255',//191
837
- '191,127,255',//192
838
- '96,0,207',//193
839
- '144,103,207',//194
840
- '79,0,144',//195
841
- '111,72,144',//196
842
- '63,0,127',//197
843
- '95,63,127',//198
844
- '31,0,64',//199
845
- '48,39,79',//200
846
- '191,0,255',//201
847
- '223,127,255',//202
848
- '144,0,207',//203
849
- '175,96,192',//204
850
- '111,0,144',//205
851
- '128,72,159',//206
852
- '95,0,127',//207
853
- '96,56,112',//208
854
- '48,0,64',//209
855
- '64,39,79',//210
856
- '255,0,255',//211
857
- '255,127,255',//212
858
- '192,0,192',//213
859
- '192,96,192',//214
860
- '144,0,144',//215
861
- '144,72,144',//216
862
- '127,0,127',//217
863
- '127,63,127',//218
864
- '79,0,79',//219
865
- '64,32,64',//220
866
- '255,0,191',//221
867
- '255,127,223',//222
868
- '192,0,144',//223
869
- '192,96,175',//224
870
- '144,0,111',//225
871
- '144,72,128',//226
872
- '127,0,95',//227
873
- '127,56,111',//228
874
- '64,0,48',//229
875
- '79,39,63',//230
876
- '255,0,127',//231
877
- '255,127,191',//232
878
- '192,0,95',//233
879
- '192,96,144',//234
880
- '159,0,79',//235
881
- '144,72,111',//236
882
- '127,0,63',//237
883
- '127,63,95',//238
884
- '64,0,31',//239
885
- '64,32,48',//240
886
- '255,0,63',//241
887
- '255,127,159',//242
888
- '207,0,48',//243
889
- '207,103,127',//244
890
- '144,0,32',//245
891
- '144,72,95',//246
892
- '127,0,31',//247
893
- '127,63,79',//248
894
- '79,0,15',//249
895
- '64,32,47',//250
896
- '47,47,47',//251
897
- '80,88,80',//252
898
- '128,128,128',//253
899
- '175,175,175',//254
900
- '208,215,208',//255
901
- '255,255,255'//256
606
+ let color = [
607
+ '0,0,0', //1
608
+ '255,0,0', //2
609
+ '255,255,0', //3
610
+ '0,255,0', //4
611
+ '0,255,255', //5
612
+ '0,0,255', //6
613
+ '255,0,255', //7
614
+ '255,255,255', //8
615
+ '128,128,128', //9
616
+ '192,192,192', //10
617
+ '255,0,0', //11
618
+ '255,120,112', //12
619
+ '192,0,0', //13
620
+ '207,103,96', //14
621
+ '144,0,0', //15
622
+ '144,72,79', //16
623
+ '127,0,0', //17
624
+ '112,56,48', //18
625
+ '79,0,0', //19
626
+ '79,39,32', //20
627
+ '255,56,0', //21
628
+ '255,159,127', //22
629
+ '192,48,0', //23
630
+ '207,127,96', //24
631
+ '144,32,0', //25
632
+ '144,88,64', // 26
633
+ '112,24,0', //27
634
+ '127,72,63', //28
635
+ '79,16,0', //29
636
+ '64,40,31', //30
637
+ '255,127,0', //31
638
+ '255,191,127', //32
639
+ '207,103,0', //33
640
+ '192,151,96', //34
641
+ '159,72,0', //35
642
+ '144,112,79', //36
643
+ '127,63,0', //37
644
+ '127,95,63', //38
645
+ '64,32,0', //39
646
+ '64,55,31', //40
647
+ '255,191,0', // 41
648
+ '255,216,127', //42
649
+ '207,152,0', //43
650
+ '192,175,96', //44
651
+ '144,112,0', //45
652
+ '144,128,64', //46
653
+ '112,88,0', //47
654
+ '127,111,63', //48
655
+ '64,55,0', //49
656
+ '64,63,31', //50
657
+ '255,255,0', //51
658
+ '255,255,112', //52
659
+ '207,200,0', //53
660
+ '192,200,96', //54
661
+ '144,151,0', //55
662
+ '144,151,64', //56
663
+ '144,152,0', //57
664
+ '127,120,63', //58
665
+ '79,72,0', //59
666
+ '79,72,32', //60
667
+ '191,255,0', //61
668
+ '208,255,112', //62
669
+ '144,200,0', //63
670
+ '176,200,96', //64
671
+ '111,151,0', //65
672
+ '128,151,79', //66
673
+ '95,127,0', //67
674
+ '111,127,63', //68
675
+ '48,72,0', //69
676
+ '63,72,31', //70
677
+ '127,255,0', //71
678
+ '191,255,127', //72
679
+ '95,200,0', //73
680
+ '159,200,96', //74
681
+ '64,151,0', //75
682
+ '111,151,64', //76
683
+ '63,120,0', //77
684
+ '95,127,63', //78
685
+ '31,72,0', //79
686
+ '48,72,32', //80
687
+ '63,255,0', //81
688
+ '159,255,127', //82
689
+ '47,200,0', //83
690
+ '127,200,96', //84
691
+ '31,151,0', //85
692
+ '80,151,64', //86
693
+ '31,127,0', //87
694
+ '79,127,63', //88
695
+ '15,72,0', //89
696
+ '47,72,32', //90
697
+ '0,255,0', //91
698
+ '127,255,127', //92
699
+ '0,200,0', //93
700
+ '95,200,95', //94
701
+ '0,151,0', //95
702
+ '79,151,79', //96
703
+ '0,127,0', //97
704
+ '63,127,63', //98
705
+ '0,72,0', //99
706
+ '32,72,32', //100
707
+ '0,255,63', //101
708
+ '127,255,159', //102
709
+ '0,200,47', //103
710
+ '95,200,112', //104
711
+ '0,151,32', //105
712
+ '64,151,95', //106
713
+ '0,120,31', //107
714
+ '63,127,79', //108
715
+ '0,72,15', //109
716
+ '32,72,47', //110
717
+ '0,255,127', //111
718
+ '127,255,191', //112
719
+ '0,200,96', //113
720
+ '95,200,144', //114
721
+ '0,151,64', //115
722
+ '79,151,111', //116
723
+ '0,127,63', //117
724
+ '63,127,95', //118
725
+ '0,72,32', //119
726
+ '31,72,48', //120
727
+ '0,255,191', //121
728
+ '127,255,223', //122
729
+ '0,200,144', //123
730
+ '95,200,175', //124
731
+ '0,151,111', //125
732
+ '79,151,128', //126
733
+ '0,120,95', //127
734
+ '63,127,111', //128
735
+ '0,72,48', //129
736
+ '32,72,63', //130
737
+ '0,255,255', //131
738
+ '127,255,255', //132
739
+ '0,200,207', //133
740
+ '96,200,207', //134
741
+ '0,151,144', //135
742
+ '64,151,144', //136
743
+ '0,127,127', //137
744
+ '63,127,127', //138
745
+ '0,72,79', //139
746
+ '32,72,79', //140
747
+ '0,191,255', //141
748
+ '127,223,255', //142
749
+ '0,152,207', //143
750
+ '96,176,207', //144
751
+ '0,111,144', //145
752
+ '64,128,144', //146
753
+ '0,95,127', //147
754
+ '63,111,127', //148
755
+ '0,55,64', //149
756
+ '31,63,64', //150
757
+ '0,127,255', //151
758
+ '112,184,255', //152
759
+ '0,96,192', //153
760
+ '96,151,207', //154
761
+ '0,72,159', //155
762
+ '79,112,144', //156
763
+ '0,63,127', //157
764
+ '63,95,127', //158
765
+ '0,39,79', //159
766
+ '32,56,79', //160
767
+ '0,63,255', //161
768
+ '127,159,255', //162
769
+ '0,48,207', //163
770
+ '96,127,207', //164
771
+ '0,39,159', //165
772
+ '64,95,144', //166
773
+ '0,24,127', //167
774
+ '63,79,127', //168
775
+ '0,15,64', //169
776
+ '32,47,79', //170
777
+ '0,0,255', //171
778
+ '127,127,255', //172
779
+ '0,0,207', //173
780
+ '95,96,192', //174
781
+ '0,0,144', //175
782
+ '79,72,159', //176
783
+ '0,0,127', //177
784
+ '63,63,127', //178
785
+ '0,0,64', //179
786
+ '32,39,79', //180
787
+ '63,0,255', //181
788
+ '159,127,255', //182
789
+ '47,0,192', //183
790
+ '127,103,207', //184
791
+ '32,0,144', //185
792
+ '80,72,144', //186
793
+ '31,0,127', //187
794
+ '79,63,127', //188
795
+ '15,0,79', //189
796
+ '47,39,79', //190
797
+ '127,0,255', //191
798
+ '191,127,255', //192
799
+ '96,0,207', //193
800
+ '144,103,207', //194
801
+ '79,0,144', //195
802
+ '111,72,144', //196
803
+ '63,0,127', //197
804
+ '95,63,127', //198
805
+ '31,0,64', //199
806
+ '48,39,79', //200
807
+ '191,0,255', //201
808
+ '223,127,255', //202
809
+ '144,0,207', //203
810
+ '175,96,192', //204
811
+ '111,0,144', //205
812
+ '128,72,159', //206
813
+ '95,0,127', //207
814
+ '96,56,112', //208
815
+ '48,0,64', //209
816
+ '64,39,79', //210
817
+ '255,0,255', //211
818
+ '255,127,255', //212
819
+ '192,0,192', //213
820
+ '192,96,192', //214
821
+ '144,0,144', //215
822
+ '144,72,144', //216
823
+ '127,0,127', //217
824
+ '127,63,127', //218
825
+ '79,0,79', //219
826
+ '64,32,64', //220
827
+ '255,0,191', //221
828
+ '255,127,223', //222
829
+ '192,0,144', //223
830
+ '192,96,175', //224
831
+ '144,0,111', //225
832
+ '144,72,128', //226
833
+ '127,0,95', //227
834
+ '127,56,111', //228
835
+ '64,0,48', //229
836
+ '79,39,63', //230
837
+ '255,0,127', //231
838
+ '255,127,191', //232
839
+ '192,0,95', //233
840
+ '192,96,144', //234
841
+ '159,0,79', //235
842
+ '144,72,111', //236
843
+ '127,0,63', //237
844
+ '127,63,95', //238
845
+ '64,0,31', //239
846
+ '64,32,48', //240
847
+ '255,0,63', //241
848
+ '255,127,159', //242
849
+ '207,0,48', //243
850
+ '207,103,127', //244
851
+ '144,0,32', //245
852
+ '144,72,95', //246
853
+ '127,0,31', //247
854
+ '127,63,79', //248
855
+ '79,0,15', //249
856
+ '64,32,47', //250
857
+ '47,47,47', //251
858
+ '80,88,80', //252
859
+ '128,128,128', //253
860
+ '175,175,175', //254
861
+ '208,215,208', //255
862
+ '255,255,255', //256
902
863
  ];