wt-huatu 1.3.4

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 (110) hide show
  1. package/Readme.md +223 -0
  2. package/component/HuatuComponentCache.js +89 -0
  3. package/component/HuatuComponentDef.js +249 -0
  4. package/component/HuatuComponentPlacement.js +172 -0
  5. package/component/HuatuComponentPort.js +58 -0
  6. package/component/IHuatuComponent.js +2 -0
  7. package/for-node/node-cli-funcs.js +36 -0
  8. package/geometry/AngDeg.js +68 -0
  9. package/geometry/Angle.js +77 -0
  10. package/geometry/Bezier.js +623 -0
  11. package/geometry/Circle.js +143 -0
  12. package/geometry/Ellipse.js +546 -0
  13. package/geometry/EllipticalArc.js +337 -0
  14. package/geometry/IGeometry.js +1 -0
  15. package/geometry/Intersection.js +601 -0
  16. package/geometry/Line.js +136 -0
  17. package/geometry/LineSeg.js +179 -0
  18. package/geometry/Point.js +88 -0
  19. package/geometry/PolyLine.js +97 -0
  20. package/geometry/Polygon.js +122 -0
  21. package/geometry/Rect.js +149 -0
  22. package/geometry/Ring.js +91 -0
  23. package/geometry/SegmentModel.js +206 -0
  24. package/geometry/Triangle.js +168 -0
  25. package/geometry/Vector.js +92 -0
  26. package/huatu/Huatu.js +4279 -0
  27. package/huatu/HuatuAngleMark.js +400 -0
  28. package/huatu/HuatuBlock.js +26 -0
  29. package/huatu/HuatuClipPath.js +29 -0
  30. package/huatu/HuatuCompDrawing.js +77 -0
  31. package/huatu/HuatuDimMark.js +579 -0
  32. package/huatu/HuatuDrawing.js +185 -0
  33. package/huatu/HuatuDrawingGroup.js +52 -0
  34. package/huatu/HuatuJob.js +347 -0
  35. package/huatu/HuatuLabel.js +311 -0
  36. package/huatu/HuatuLabelStyle.js +190 -0
  37. package/huatu/HuatuLayer.js +10 -0
  38. package/huatu/HuatuMarker.js +209 -0
  39. package/huatu/HuatuParser.js +435 -0
  40. package/huatu/HuatuPath.js +131 -0
  41. package/huatu/HuatuPathSeries.js +51 -0
  42. package/huatu/HuatuPattern.js +54 -0
  43. package/huatu/HuatuPoint.js +20 -0
  44. package/huatu/HuatuPointSeries.js +67 -0
  45. package/huatu/HuatuStyle.js +394 -0
  46. package/huatu/HuatuSymbol.js +81 -0
  47. package/huatu/HuatuSymbolArray.js +235 -0
  48. package/huatu/HuatuTransform.js +113 -0
  49. package/huatu/HuatuVar.js +17 -0
  50. package/huatu/HuatuYml.js +271 -0
  51. package/huatu/IHuatu.js +2 -0
  52. package/huatu/IHuatuYml.js +1 -0
  53. package/huatu/IndentParsingStack.js +82 -0
  54. package/index.d.ts +1747 -0
  55. package/index.js +247 -0
  56. package/math/Complex.js +72 -0
  57. package/math/Matrix.js +31 -0
  58. package/math/NumberRange.js +38 -0
  59. package/math/VarFuncs.js +24 -0
  60. package/math/WtMath.js +217 -0
  61. package/package.json +34 -0
  62. package/path/PathBezier2.js +75 -0
  63. package/path/PathBezier3.js +89 -0
  64. package/path/PathCircle.js +82 -0
  65. package/path/PathConfig.js +81 -0
  66. package/path/PathContinuousSegmentedPath.js +390 -0
  67. package/path/PathEllipse.js +99 -0
  68. package/path/PathEllipticalArc.js +111 -0
  69. package/path/PathGeneric.js +59 -0
  70. package/path/PathLine.js +75 -0
  71. package/path/PathLines.js +46 -0
  72. package/path/PathPolygon.js +142 -0
  73. package/path/PathPolyline.js +266 -0
  74. package/path/PathRect.js +125 -0
  75. package/path/PathRing.js +51 -0
  76. package/path/PathSegmentedPath.js +199 -0
  77. package/path/PathTriangle.js +90 -0
  78. package/presets/marker.js +37 -0
  79. package/presets/pattern.js +85 -0
  80. package/shape/SvgShapeArrowHead.js +92 -0
  81. package/shape/SvgShapeCircle.js +26 -0
  82. package/shape/SvgShapeCross.js +43 -0
  83. package/shape/SvgShapeEllipse.js +28 -0
  84. package/shape/SvgShapeGeneric.js +50 -0
  85. package/shape/SvgShapeHeart.js +40 -0
  86. package/shape/SvgShapeIsoscelesTriangle.js +52 -0
  87. package/shape/SvgShapePolygon.js +39 -0
  88. package/shape/SvgShapeRect.js +26 -0
  89. package/shape/SvgShapeRhombus.js +27 -0
  90. package/shape/SvgShapeStar.js +103 -0
  91. package/svg/ISvg.js +1 -0
  92. package/svg/SvgBBox.js +149 -0
  93. package/svg/SvgConstants.js +14 -0
  94. package/svg/SvgGradient.js +97 -0
  95. package/svg/SvgMarker.js +221 -0
  96. package/svg/SvgPattern.js +228 -0
  97. package/svg/SvgPoint.js +33 -0
  98. package/svg/SvgPointSet.js +41 -0
  99. package/templates/lines.js +35 -0
  100. package/tools/gen-id.js +2 -0
  101. package/tools/html.js +2 -0
  102. package/tools/katex.js +75 -0
  103. package/tools/rand-str.js +122 -0
  104. package/tools/regex.js +15 -0
  105. package/tools/utils.js +438 -0
  106. package/tools/webColor.js +700 -0
  107. package/wire/HuatuNet.js +22 -0
  108. package/wire/HuatuWire.js +415 -0
  109. package/wire/HuatuWireDrawing.js +17 -0
  110. package/wire/IHuatuWire.js +1 -0
package/index.d.ts ADDED
@@ -0,0 +1,1747 @@
1
+ interface IPoint {
2
+ x: number;
3
+ y: number;
4
+ }
5
+ interface ILine {
6
+ anchor: IPoint;
7
+ ang: number;
8
+ slope: number;
9
+ }
10
+ interface IGeometryModel {
11
+ getPoint(pos: string | number, t?: number): IPoint | undefined;
12
+ getParam(name: string): number | undefined;
13
+ moveBy(dx: number, dy: number): IGeometryModel | undefined;
14
+ rotateBy(rotDeg: number, at?: IPoint): IGeometryModel | undefined;
15
+ }
16
+ interface ICurveFuncsByT {
17
+ px: (t: number) => number;
18
+ py: (t: number) => number;
19
+ dpx: (t: number) => number;
20
+ dpy: (t: number) => number;
21
+ }
22
+ interface ISegmentModel {
23
+ pStart: IPoint;
24
+ pEnd: IPoint;
25
+ getCurveFuncs(): ICurveFuncsByT;
26
+ getTofPoint(p: IPoint): number | undefined;
27
+ makeSubSeg(pStart: IPoint, pEnd: IPoint): ISegmentModel | undefined;
28
+ getTangentLineOfPoint(p: IPoint): ILine | undefined;
29
+ getNormalPoint(t: number, dist: number, dir: "right" | "left"): IPoint | undefined;
30
+ }
31
+
32
+ type TSvgLineJoin = "miter" | "round" | "bevel";
33
+ type TSvgLineCap = "butt" | "round" | "square";
34
+ interface ISvgBBoxMaxMin {
35
+ xMin: number;
36
+ xMax: number;
37
+ yMin: number;
38
+ yMax: number;
39
+ }
40
+ interface ISvgBBox {
41
+ x: number;
42
+ y: number;
43
+ w: number;
44
+ h: number;
45
+ isDummy: boolean;
46
+ buildString(): string;
47
+ toMaxMins(): ISvgBBoxMaxMin;
48
+ getAnchor(): ISvgPoint;
49
+ getCenter(): ISvgPoint;
50
+ extendByStroke(strokeWidth: number): ISvgBBox;
51
+ copy(): ISvgBBox;
52
+ mergeAnother(box: ISvgBBox): ISvgBBox;
53
+ moveBy(dx: number, dy: number): ISvgBBox;
54
+ rotateAt(rotCenter: ISvgPoint, rotDeg: number): ISvgBBox;
55
+ scale(t: number): ISvgBBox;
56
+ buildRectSvg(withClass?: boolean): string;
57
+ mirrorAt(mirrorX?: boolean, mirrorY?: boolean, at?: ISvgPoint): ISvgBBox;
58
+ }
59
+ interface ISvgPoint {
60
+ x: number;
61
+ y: number;
62
+ }
63
+ interface ISvgPath {
64
+ realPoints: ISvgPoint[];
65
+ auxPoints: ISvgPoint[];
66
+ centers: ISvgPoint[];
67
+ bbox: ISvgBBox;
68
+ stroke?: IStrokeConfig;
69
+ fill?: IFillConfig;
70
+ marker?: IMarkerConfig;
71
+ clip?: string | ISvgClipPath;
72
+ pathTag: string;
73
+ models: IGeometryModel[];
74
+ getPathAttr(): string[];
75
+ buildPathData(): string;
76
+ buildPathHtmlOnly(id?: string): string;
77
+ buildHtml(additional?: string): string;
78
+ buildHtmlFull(stroke?: IStrokeConfig, fill?: IFillConfig, marker?: IMarkerConfig, clip?: ISvgClipPath | string): string;
79
+ duplicateTo(distance: number, dir: "right" | "left" | "in" | "out", lineJoin?: TSvgLineJoin): ISvgPath | undefined;
80
+ }
81
+ interface ISvgPathSegment extends ISvgPath {
82
+ isStartSeg: boolean;
83
+ closePath: boolean;
84
+ pStart: ISvgPoint;
85
+ pEnd: ISvgPoint;
86
+ auxModel: ISegmentModel | undefined;
87
+ buildSegPathData(): string;
88
+ moveBy(dx: number, dy: number): ISvgPathSegment | undefined;
89
+ rotateBy(rotDeg: number, at?: ISvgPoint): ISvgPathSegment | undefined;
90
+ reverse(): ISvgPathSegment | undefined;
91
+ makeSubPath(pStart: ISvgPoint, pEnd: ISvgPoint): ISvgPathSegment | undefined;
92
+ }
93
+ interface IFillConfig {
94
+ color?: string;
95
+ opacity?: number;
96
+ rule?: "nonzero" | "evenodd";
97
+ }
98
+ interface IStrokeConfig {
99
+ color?: string;
100
+ width?: number;
101
+ opacity?: number;
102
+ lineCap?: TSvgLineCap;
103
+ lineJoin?: TSvgLineJoin;
104
+ miterLimit?: number;
105
+ dashArray?: number[] | "none";
106
+ dashOffset?: number;
107
+ }
108
+ interface IPathConfigs {
109
+ stroke?: IStrokeConfig;
110
+ fill?: IFillConfig;
111
+ marker?: IMarkerConfig;
112
+ clip?: string | ISvgClipPath;
113
+ }
114
+ interface ISvgShape {
115
+ hasStroke: boolean;
116
+ hasFill: boolean;
117
+ stroke?: IStrokeConfig;
118
+ fill?: IFillConfig;
119
+ primaryColor: "fill" | "stroke";
120
+ secondaryColor?: "fill" | "stroke";
121
+ paths: ISvgPath[];
122
+ bbox: ISvgBBox;
123
+ setStroke(stroke: IStrokeConfig): void;
124
+ setFill(fill: IFillConfig): void;
125
+ getBBox(strokeWidth?: number): ISvgBBox;
126
+ buildHtml(fillColor?: string, fillOpacity?: number, strokeColor?: string, strokeWidth?: number): string;
127
+ }
128
+ type SvgUnitsType = "userSpaceOnUse" | "objectBoundingBox";
129
+ interface ISvgPattern {
130
+ x: number;
131
+ y: number;
132
+ width: number;
133
+ height: number;
134
+ units: SvgUnitsType;
135
+ contentUnits?: SvgUnitsType;
136
+ viewBox?: ISvgBBox;
137
+ paths: ISvgPath[];
138
+ buildHtml(id?: string): string;
139
+ }
140
+ interface ISvgMarker {
141
+ id: string;
142
+ units: "strokeWidth" | "userSpaceOnUse";
143
+ refX: number;
144
+ refY: number;
145
+ orient: number | "auto" | "auto-start-reverse";
146
+ viewBox: ISvgBBox;
147
+ preserveAspectRatio?: boolean;
148
+ stroke?: IStrokeConfig;
149
+ fill?: IFillConfig;
150
+ shape: ISvgShape;
151
+ buildMarkerSvg(id?: string, primaryColor?: string, secondaryColor?: string): string;
152
+ }
153
+ interface ISvgClipPath {
154
+ id?: string;
155
+ path?: ISvgPath;
156
+ paths?: ISvgPath[];
157
+ group?: ISvgGroup;
158
+ }
159
+ interface IMarkerConfig {
160
+ start?: string;
161
+ mid?: string;
162
+ end?: string;
163
+ }
164
+ type ISvgElement = ISvgPath | ISvgGroup | ISvgLayer;
165
+ interface ISvgGroup {
166
+ bbox: ISvgBBox;
167
+ clipPath?: ISvgPath | string;
168
+ elements?: ISvgElement[];
169
+ stroke?: IStrokeConfig;
170
+ fill?: IFillConfig;
171
+ clip?: string | ISvgClipPath;
172
+ add(element: ISvgElement): void;
173
+ getBBox(): ISvgBBox;
174
+ }
175
+ interface ISvgLayer extends ISvgGroup {
176
+ name: string;
177
+ desc?: string;
178
+ visible: boolean;
179
+ zIndex: number;
180
+ indicator: string;
181
+ renderHtml(): string;
182
+ }
183
+
184
+ interface IHuatuYmlObj {
185
+ [key: string]: IHuatuYmlValueType;
186
+ }
187
+ type IHuatuYmlValueType = string | string[] | IHuatuYmlObj | undefined;
188
+ interface IHuatuYmlLabelStyle extends IHuatuYmlObj {
189
+ ref?: string;
190
+ refs?: string;
191
+ style?: string;
192
+ styles?: string;
193
+ color?: string;
194
+ font?: string;
195
+ size?: string;
196
+ fontSize?: string;
197
+ align?: string;
198
+ textAlign?: string;
199
+ bold?: string;
200
+ italic?: string;
201
+ line?: string;
202
+ addLine?: string;
203
+ }
204
+ interface IHuatuYmlStyle extends IHuatuYmlObj {
205
+ ref: string;
206
+ fillColor?: string;
207
+ fillOpacity?: string;
208
+ fillPattern?: string;
209
+ fillGradient?: string;
210
+ fillRule?: string;
211
+ fill?: string | {
212
+ color?: string;
213
+ opacity?: string;
214
+ pattern?: string;
215
+ gradient?: string;
216
+ rule?: string;
217
+ };
218
+ strokeColor?: string;
219
+ strokeWidth?: string;
220
+ strokeOpacity?: string;
221
+ strokeLineCap?: string;
222
+ strokeLineJoin?: string;
223
+ strokeMiterLimit?: string;
224
+ strokeDashArray?: string;
225
+ strokeDashOffset?: string;
226
+ stroke?: string | {
227
+ color?: string;
228
+ width?: string;
229
+ opacity?: string;
230
+ lineCap?: string;
231
+ lineJoin?: string;
232
+ miterLimit?: string;
233
+ dashArray?: string;
234
+ dashOffset?: string;
235
+ };
236
+ markerStart?: string;
237
+ markerMid?: string;
238
+ markerEnd?: string;
239
+ marker?: string | {
240
+ start?: string;
241
+ mid?: string;
242
+ end?: string;
243
+ };
244
+ clip?: string;
245
+ mask?: string;
246
+ }
247
+ interface IHuatuYmlMarker extends IHuatuYmlObj {
248
+ type?: string;
249
+ size?: string;
250
+ len?: string;
251
+ length?: string;
252
+ len2?: string;
253
+ length2?: string;
254
+ r?: string;
255
+ r1?: string;
256
+ r2?: string;
257
+ degStart?: string;
258
+ roundCorner?: string;
259
+ color1?: string;
260
+ priColor?: string;
261
+ primaryColor?: string;
262
+ color2?: string;
263
+ secColor?: string;
264
+ secondaryColor?: string;
265
+ close?: string;
266
+ fillOpacity?: string;
267
+ }
268
+ interface IHuatuYmlPattern extends IHuatuYmlObj {
269
+ type?: string;
270
+ density?: string;
271
+ lineDensity?: string;
272
+ dotsDensity?: string;
273
+ squareDensity?: string;
274
+ color?: string;
275
+ opacity?: string;
276
+ rotDeg?: string;
277
+ deg?: string;
278
+ lineDeg?: string;
279
+ lineWeight?: string;
280
+ lineWidth?: string;
281
+ lineStyle?: string;
282
+ dashDensity?: string;
283
+ dashedDensity?: string;
284
+ dottedDensity?: string;
285
+ size?: string;
286
+ bgColor?: string;
287
+ background?: string;
288
+ bgOpacity?: string;
289
+ sparseK?: string;
290
+ }
291
+ interface IHuatuYmlSymbolArray extends IHuatuYmlObj {
292
+ symbol?: string;
293
+ sym?: string;
294
+ startPoint?: string;
295
+ start?: string;
296
+ from?: string;
297
+ desc?: string;
298
+ method?: string;
299
+ arrayMethod?: string;
300
+ deltaX?: string;
301
+ dx?: string;
302
+ deltaY?: string;
303
+ dy?: string;
304
+ count?: string;
305
+ countX?: string;
306
+ countY?: string;
307
+ center?: string;
308
+ centerPoint?: string;
309
+ at?: string;
310
+ rotDeg?: string;
311
+ rot?: string;
312
+ rotate?: string;
313
+ alignCenter?: string;
314
+ radius?: string;
315
+ r?: string;
316
+ scale?: string;
317
+ notRotate?: string;
318
+ noRotate?: string;
319
+ noRot?: string;
320
+ startDeg?: string;
321
+ initialDeg?: string;
322
+ iniDeg?: string;
323
+ deltaDeg?: string;
324
+ degDelta?: string;
325
+ degD?: string;
326
+ dDeg?: string;
327
+ }
328
+ interface IHuatuYmlJob extends IHuatuYmlObj {
329
+ desc?: string;
330
+ viewBox?: string;
331
+ viewArea?: string;
332
+ viewBetween?: string;
333
+ width?: string;
334
+ height?: string;
335
+ size?: string;
336
+ drawings?: string | string[];
337
+ config?: IHuatuConfigInYml;
338
+ }
339
+ interface IHuatuConfigInYml extends IHuatuYmlObj {
340
+ labelBackground?: string;
341
+ labelBackgroundColor?: string;
342
+ labelBg?: string;
343
+ labelBgColor?: string;
344
+ labelBorder?: string;
345
+ labelBorderColor?: string;
346
+ markCenters?: string;
347
+ markBezierAuxLines?: string;
348
+ markNamedPoints?: string;
349
+ markPathPoints?: string;
350
+ markSize?: string;
351
+ markPositions?: string;
352
+ markAnchors?: string;
353
+ printUnusedModule?: string;
354
+ showBBox?: string;
355
+ [key: string]: string | undefined;
356
+ }
357
+
358
+ /** This file holds all the data structures designed for WT Huatu, all the modelling will be placed here. */
359
+
360
+ type IHuatuInputVarType = "number" | "text" | "color";
361
+ interface IHuatuInputVar {
362
+ name: string;
363
+ type: IHuatuInputVarType;
364
+ value: number | string;
365
+ }
366
+ interface IHuatuComponentInputVars {
367
+ [name: string]: string | number;
368
+ }
369
+ interface IHuatuComponentPort {
370
+ anchor: ISvgPoint;
371
+ name: string;
372
+ idx?: number;
373
+ rayDeg: number;
374
+ attr?: "in" | "out" | "inout" | "unset" | "hiz" | "pu" | "pd";
375
+ minHoldLen: number;
376
+ }
377
+ interface IHuatuComponentPortSettled {
378
+ name: string;
379
+ anchor: ISvgPoint;
380
+ freeStart: ISvgPoint;
381
+ lineAng: number;
382
+ lineDeg: number;
383
+ isH: boolean;
384
+ isV: boolean;
385
+ minHoldLen: number;
386
+ }
387
+ /**
388
+ * Model of the definition of the Component
389
+ */
390
+ interface IHuatuComponentDef {
391
+ name: string;
392
+ desc?: string;
393
+ def: IHuatuYmlObj;
394
+ inputVars: IHuatuInputVar[];
395
+ isValid: boolean;
396
+ }
397
+ type HuatuComponentPlacementRefPointType = "center" | "origin";
398
+ type HuatuComponentPlacementMirrorType = "x" | "y" | "xy";
399
+ /**
400
+ * Model of the instantiated component
401
+ */
402
+ interface IHuatuComponentPlacement {
403
+ isValid: boolean;
404
+ name: string;
405
+ location: ISvgPoint;
406
+ def?: IHuatuComponentDef;
407
+ huatuDef?: IHuatuYmlObj;
408
+ huatu?: IHuatu;
409
+ givenInputVars: IHuatuComponentInputVars;
410
+ ports: IHuatuComponentPort[];
411
+ mirror?: HuatuComponentPlacementMirrorType;
412
+ rotDeg?: number;
413
+ refPointType: HuatuComponentPlacementRefPointType;
414
+ rotateLabel?: boolean;
415
+ getRefPoint(): ISvgPoint;
416
+ }
417
+
418
+ /** This file holds all the data structures designed for WT Huatu, all the modelling will be placed here. */
419
+
420
+ interface IHuatuConfig {
421
+ labelBackground?: string;
422
+ labelBorder?: string;
423
+ markCenters?: boolean;
424
+ markBezierAuxLines?: boolean;
425
+ markNamedPoints?: string;
426
+ markPathPoints?: string;
427
+ markSize?: number;
428
+ markPositions?: string;
429
+ printUnusedModule?: boolean;
430
+ showBBox?: string;
431
+ noRefStyle?: boolean;
432
+ }
433
+ declare global {
434
+ var wtHuatuConfig: IHuatuConfig | undefined;
435
+ var buildType: SvgBuildType;
436
+ var huatuKatexCss: string;
437
+ var wthtJobBuildId: string;
438
+ }
439
+ interface IHuatuVar {
440
+ howGet: "direct" | "derived";
441
+ name: string;
442
+ value: number;
443
+ def?: string;
444
+ }
445
+ interface IHuatuPoint {
446
+ name: string;
447
+ howGet: "direct" | "derived" | "calculated" | "intersection";
448
+ x: number;
449
+ y: number;
450
+ toSvgPoint(): ISvgPoint;
451
+ toPoint(): IPoint;
452
+ }
453
+ interface IHuatuPointSeries {
454
+ name: string;
455
+ points: ISvgPoint[];
456
+ getPoint(idx: number): ISvgPoint | undefined;
457
+ count(): number;
458
+ }
459
+ interface ISolvedXPoints {
460
+ path1: string;
461
+ path2: string;
462
+ points: ISvgPoint[];
463
+ }
464
+ interface IResultResolveXPoints {
465
+ result: "Error" | "Invalid" | "Success";
466
+ errors: string[];
467
+ points: ISvgPoint[];
468
+ }
469
+ interface IHuatuPath {
470
+ name?: string;
471
+ path?: ISvgPath;
472
+ model?: IGeometryModel;
473
+ }
474
+ interface IHuatuPathSeries {
475
+ name?: string;
476
+ paths: ISvgPath[];
477
+ models: IGeometryModel[];
478
+ }
479
+ interface IHuatuLabelStylePure {
480
+ color?: string;
481
+ font?: string;
482
+ fontSize?: number;
483
+ textAlign?: string;
484
+ bold?: boolean;
485
+ italic?: boolean;
486
+ addLine?: string;
487
+ }
488
+ interface IHuatuLabelStyle extends IHuatuLabelStylePure {
489
+ name: string;
490
+ refStyles: IHuatuLabelStyle[];
491
+ }
492
+ interface IHuatuLabel extends IHuatuLabelStylePure {
493
+ text: string;
494
+ width: number;
495
+ height: number;
496
+ location?: ISvgPoint;
497
+ anchorOffset?: ISvgPoint;
498
+ rotDeg?: number;
499
+ /**
500
+ * The possible anchoring positions for a label are:
501
+ "tl" | "topleft"
502
+ | "tm" | "topmiddle"
503
+ | "tr" | "topright"
504
+ | "ml" | "middleleft"
505
+ | "mm" | "center" | "c" | "middlemiddle"
506
+ | "mr" | "middleright"
507
+ | "bl" | "bottomleft"
508
+ | "bm" | "bottommiddle"
509
+ | "br" | "bottomright";
510
+ */
511
+ anchorPos?: string;
512
+ styles: IHuatuLabelStyle[];
513
+ }
514
+ interface IHuatuStyle {
515
+ refStyles: IHuatuStyle[];
516
+ name?: string;
517
+ fillColor?: string;
518
+ fillOpacity?: number;
519
+ fillPattern?: string | IHuatuPattern;
520
+ fillRule?: "nonzero" | "evenodd";
521
+ fillGradient?: string;
522
+ strokeColor?: string;
523
+ strokeWidth?: number;
524
+ strokeOpacity?: number;
525
+ strokeLineCap?: TSvgLineCap;
526
+ strokeLineJoin?: TSvgLineJoin;
527
+ strokeMiterLimit?: number;
528
+ strokeDashArray?: number[] | "none";
529
+ strokeDashOffset?: number;
530
+ markerStart?: string | IHuatuMarker;
531
+ markerMid?: string | IHuatuMarker;
532
+ markerEnd?: string | IHuatuMarker;
533
+ clipPath?: string | IHuatuClipPath;
534
+ buildCss(): string;
535
+ buildSvgAttr(direct?: boolean): string;
536
+ }
537
+ interface IHuatuTransform {
538
+ x?: number;
539
+ y?: number;
540
+ rotCx?: number;
541
+ rotCy?: number;
542
+ rotDeg?: number;
543
+ scale?: number;
544
+ }
545
+ type SvgBuildType = "direct" | "linking";
546
+ interface IHuatuFinalDraw {
547
+ getBBox(): ISvgBBox;
548
+ /**
549
+ * The functions used to build SVG HTML in the final draw, It is designed for
550
+ * - HuatuDrawing, which has its own styles and transformations, and
551
+ * - Label, which is defined in just one line
552
+ */
553
+ buildHtml(buildType: SvgBuildType): string;
554
+ }
555
+ interface IHuatuDrawing {
556
+ /**
557
+ * Shared style if applicable
558
+ */
559
+ style?: IHuatuStyle;
560
+ /**
561
+ * The Transform control is used to place symbol/Symbol Array/block, if it is required.
562
+ * x, y are used for all the possible type of elements
563
+ * rotCx, rotCy, rotDeg and scale will only be used by Symbol.
564
+ * Block could be moved by x/y, scale, and rotated
565
+ * Array and Layer will not accepted any transform
566
+ */
567
+ transform?: IHuatuTransform;
568
+ /**
569
+ * This switch will be only used for Symbol and Symbol Array.
570
+ * Since there is some case that one Symbol needs to be located/aligned
571
+ * at the top-left corner or center of the symbol.
572
+ * So here provide a switch, if the chart designer wants to specify this.
573
+ */
574
+ alignCenter?: boolean;
575
+ /** The Element going to draw */
576
+ element?: IHuatuDrawingElement;
577
+ }
578
+ interface IHuatuDrawingElement {
579
+ getBBox(style?: IHuatuStyle): ISvgBBox;
580
+ buildHtml(buildType: SvgBuildType, style?: IHuatuStyle, transform?: IHuatuTransform): string;
581
+ }
582
+ interface IHuatuDefinable {
583
+ magicId: string;
584
+ buildId(): string;
585
+ buildHtmlForDef(): string;
586
+ refCount: number;
587
+ alwaysInDef: boolean;
588
+ }
589
+ interface IHuatuCss {
590
+ magicId: string;
591
+ buildCss(): string;
592
+ refCount: number;
593
+ }
594
+ /**
595
+ * The interface for the modules that could having multiple Drawings/labels
596
+ */
597
+ interface IHuatuDrawingGroup {
598
+ name: string;
599
+ desc?: string;
600
+ bbox: ISvgBBox;
601
+ elements: IHuatuFinalDraw[];
602
+ addElement(element: IHuatuFinalDraw): void;
603
+ }
604
+ /**
605
+ * A symbol defined by composing multiple paths. It will show as
606
+ */
607
+ interface IHuatuSymbol {
608
+ viewBox?: ISvgBBox;
609
+ }
610
+ interface IHuatuSymbolArray {
611
+ name: string;
612
+ symbol: IHuatuSymbol;
613
+ arrayMethod: "polar" | "line" | "2d";
614
+ startPoint?: ISvgPoint;
615
+ deltaX: number;
616
+ deltaY: number;
617
+ /**
618
+ * This count will be shared when Array specified as Polar or Line type
619
+ * If specified as 2D, then countX and countY will work.
620
+ */
621
+ count: number;
622
+ countX: number;
623
+ countY: number;
624
+ center?: ISvgPoint;
625
+ startDeg?: number;
626
+ deltaDeg?: number;
627
+ alignCenter?: boolean;
628
+ }
629
+ interface IHuatuClipPath {
630
+ name: string;
631
+ paths: ISvgPath[];
632
+ clipRule?: "evenodd" | "nonzero";
633
+ }
634
+ interface IPatternParams {
635
+ type?: string;
636
+ lineDensity?: number;
637
+ rotDeg?: number;
638
+ lineWeight?: number;
639
+ lineStyle?: string;
640
+ dashDensity?: number;
641
+ size?: number;
642
+ color?: string;
643
+ opacity?: number;
644
+ bgColor?: string;
645
+ bgOpacity?: number;
646
+ sparseK?: number;
647
+ }
648
+ interface IHuatuPattern {
649
+ name: string;
650
+ pattern: ISvgPattern;
651
+ params?: IPatternParams;
652
+ }
653
+ interface IMarkerParams {
654
+ type?: string;
655
+ size?: number;
656
+ width?: number;
657
+ height?: number;
658
+ r?: number;
659
+ rx?: number;
660
+ ry?: number;
661
+ n?: number;
662
+ direction?: string;
663
+ centerEmpty?: boolean;
664
+ rIn?: number;
665
+ rOut?: number;
666
+ degOffset?: number;
667
+ degOpen?: number;
668
+ len?: number;
669
+ k?: number;
670
+ closeArrow?: boolean;
671
+ makeSmooth?: boolean;
672
+ primaryColor?: string;
673
+ secondaryColor?: string;
674
+ fillColor?: string;
675
+ fillOpacity?: number;
676
+ strokeColor?: string;
677
+ strokeWidth?: number;
678
+ }
679
+ interface IHuatuMarker {
680
+ name: string;
681
+ marker: ISvgMarker;
682
+ params?: IMarkerParams;
683
+ }
684
+ interface IHuatuJob {
685
+ huatu: IHuatu;
686
+ name: string;
687
+ desc?: string;
688
+ viewBox?: ISvgBBox;
689
+ width?: number;
690
+ height?: number;
691
+ drawings: IHuatuFinalDraw[];
692
+ defines: IHuatuDefinable[];
693
+ styles: IHuatuCss[];
694
+ config?: IHuatuConfig;
695
+ buildSvg(buildType: SvgBuildType, withSize?: boolean, width?: number, height?: number): string;
696
+ buildSvgOfScale(buildType: SvgBuildType, scale?: number): string;
697
+ buildHtml(buildType: SvgBuildType, indent?: boolean, withSize?: boolean): string;
698
+ buildSvgStandalone(buildType: SvgBuildType, indent?: boolean, withSize?: boolean): string;
699
+ getViewBoxWithoutLabels(): ISvgBBox;
700
+ }
701
+ interface IHuatuResolvingError {
702
+ title: string;
703
+ msgs?: string[];
704
+ }
705
+ interface IHuatu {
706
+ title?: string;
707
+ desc?: string;
708
+ config?: IHuatuConfig;
709
+ width?: number;
710
+ height?: number;
711
+ viewBox?: ISvgBBox;
712
+ vars: IHuatuVar[];
713
+ clips: IHuatuClipPath[];
714
+ patterns: IHuatuPattern[];
715
+ markers: IHuatuMarker[];
716
+ styles: IHuatuStyle[];
717
+ labelStyles: IHuatuLabelStyle[];
718
+ points: IHuatuPoint[];
719
+ pointSeries: IHuatuPointSeries[];
720
+ paths: IHuatuPath[];
721
+ pathSeries: IHuatuPathSeries[];
722
+ defines: IHuatuDefinable[];
723
+ blocks: IHuatuDrawingGroup[];
724
+ symbols: IHuatuSymbol[];
725
+ arrays: IHuatuSymbolArray[];
726
+ layers: IHuatuDrawingGroup[];
727
+ compDefs: IHuatuComponentDef[];
728
+ compPlacements: IHuatuComponentPlacement[];
729
+ draw?: IHuatuJob;
730
+ jobs: IHuatuJob[];
731
+ infos: string[];
732
+ warnings: string[];
733
+ resolvingErrors: IHuatuResolvingError[];
734
+ /**
735
+ * The final printer
736
+ */
737
+ buildSvg(buildType: SvgBuildType, jobName?: string): string;
738
+ buildSvgAsHtml(buildType: SvgBuildType, jobName?: string, indent?: boolean): string;
739
+ buildSvgStandalone(buildType: SvgBuildType, jobName?: string, indent?: boolean): string;
740
+ }
741
+
742
+ interface IKeyValueOptions {
743
+ keys: string[][];
744
+ qualifiers: {
745
+ [key: string]: "int[]" | "number[]" | string[] | ((input: string) => string | undefined);
746
+ };
747
+ allowAppend: string[];
748
+ splitCharWhenAppending?: string;
749
+ booleans: string[];
750
+ ints: string[];
751
+ numbers: string[];
752
+ blindGuess: {
753
+ [key: string]: string[] | ((input: string) => string | number | boolean | undefined);
754
+ };
755
+ subKeys?: {
756
+ [subKey: string]: IKeyValueOptions;
757
+ };
758
+ }
759
+ interface IKeyValueParsingResult<T> {
760
+ body: T;
761
+ orphans: string[];
762
+ unluckyOrphans: string[];
763
+ failedPairs: {
764
+ key: string;
765
+ value: string;
766
+ }[];
767
+ subKeys?: {
768
+ [subKey: string]: IKeyValueParsingResult<any>;
769
+ };
770
+ }
771
+
772
+ interface INumberRange {
773
+ start: number;
774
+ step: number;
775
+ end: number;
776
+ numbers: number[];
777
+ count(): number;
778
+ }
779
+ declare class NumberRange implements INumberRange {
780
+ start: number;
781
+ step: number;
782
+ end: number;
783
+ numbers: number[];
784
+ constructor(start: number, step: number, end: number);
785
+ count(): number;
786
+ static build0toN(n: number): NumberRange;
787
+ }
788
+
789
+ declare class HuatuPath implements IHuatuPath, IHuatuDrawingElement, IHuatuDefinable {
790
+ name?: string;
791
+ path?: ISvgPath;
792
+ model?: IGeometryModel;
793
+ refCount: number;
794
+ alwaysInDef: boolean;
795
+ magicId: string;
796
+ constructor(path?: ISvgPath, name?: string);
797
+ setModel(model: IGeometryModel): void;
798
+ buildId(): string;
799
+ buildHtmlForDef(): string;
800
+ buildHtml(buildType: SvgBuildType, style?: IHuatuStyle, transform?: IHuatuTransform): string;
801
+ getBBox(): ISvgBBox;
802
+ moveBy(dx: number, dy: number, name?: string): HuatuPath | undefined;
803
+ rotateBy(rotDeg: number, at?: ISvgPoint, name?: string): HuatuPath | undefined;
804
+ static model2Path(model: IGeometryModel): ISvgPath | undefined;
805
+ static fromModel(model: IGeometryModel, name?: string): HuatuPath;
806
+ }
807
+
808
+ declare class HuatuPathSeries implements IHuatuPathSeries, IHuatuDrawingElement, IHuatuDefinable {
809
+ name?: string;
810
+ paths: ISvgPath[];
811
+ models: IGeometryModel[];
812
+ refCount: number;
813
+ alwaysInDef: boolean;
814
+ magicId: string;
815
+ constructor(name?: string, paths?: ISvgPath[]);
816
+ buildId(): string;
817
+ buildHtmlForDef(): string;
818
+ buildHtml(buildType: SvgBuildType, style?: IHuatuStyle | undefined, transform?: IHuatuTransform | undefined): string;
819
+ getBBox(): ISvgBBox;
820
+ static fromModels(models: IGeometryModel[], name?: string): HuatuPathSeries;
821
+ }
822
+
823
+ declare class HuatuDrawingGroup implements IHuatuDrawingGroup, IHuatuDrawingElement {
824
+ name: string;
825
+ desc?: string;
826
+ bbox: ISvgBBox;
827
+ elements: IHuatuFinalDraw[];
828
+ bboxes: ISvgBBox[];
829
+ acceptStyle: boolean;
830
+ acceptTransform: boolean;
831
+ transformForSymbol: boolean;
832
+ linkable: boolean;
833
+ constructor(name: string, desc?: string);
834
+ getLinkId(): string;
835
+ addElement(element: IHuatuFinalDraw): void;
836
+ getBBox(style?: IHuatuStyle): ISvgBBox;
837
+ buildHtml(buildType: SvgBuildType, style?: IHuatuStyle, transform?: IHuatuTransform | undefined): string;
838
+ }
839
+
840
+ declare class HuatuSymbol extends HuatuDrawingGroup implements IHuatuSymbol, IHuatuDefinable {
841
+ refCount: number;
842
+ alwaysInDef: boolean;
843
+ magicId: string;
844
+ viewBox?: ISvgBBox;
845
+ constructor(name: string, desc?: string);
846
+ getWidth(): number;
847
+ getHeight(): number;
848
+ setViewBox(viewBox: ISvgBBox): void;
849
+ getBBox(style?: IHuatuStyle): ISvgBBox;
850
+ buildId(): string;
851
+ buildHtmlForDef(): string;
852
+ buildTransformStr(transform?: IHuatuTransform, alignCenter?: boolean): string;
853
+ buildSvgOfLink(style?: IHuatuStyle, transform?: IHuatuTransform, alignCenter?: boolean): string;
854
+ }
855
+
856
+ /**
857
+ * The class implementation of SVG Point.
858
+ */
859
+
860
+ declare class SvgPattern implements ISvgPattern {
861
+ id: string;
862
+ units: SvgUnitsType;
863
+ contentUnits?: SvgUnitsType;
864
+ x: number;
865
+ y: number;
866
+ width: number;
867
+ height: number;
868
+ paths: ISvgPath[];
869
+ viewBox?: ISvgBBox | undefined;
870
+ constructor(id: string, x?: number, y?: number, width?: number, height?: number);
871
+ setUnits(units: SvgUnitsType): void;
872
+ setContentUnits(units: SvgUnitsType): void;
873
+ setViewBox(box: ISvgBBox): void;
874
+ addPaths(...paths: ISvgPath[]): void;
875
+ buildHtml(id?: string): string;
876
+ }
877
+
878
+ declare class HuatuPattern implements IHuatuPattern, IHuatuDefinable {
879
+ static TYPES: {
880
+ [key: string]: string[];
881
+ };
882
+ name: string;
883
+ pattern: ISvgPattern;
884
+ params?: IPatternParams;
885
+ refCount: number;
886
+ alwaysInDef: boolean;
887
+ magicId: string;
888
+ constructor(name: string, pattern: ISvgPattern);
889
+ buildHtmlForDef(): string;
890
+ buildId(): string;
891
+ static getAllPatternTypes(): string[];
892
+ static buildPatternFromParams(params: IPatternParams): SvgPattern | string;
893
+ }
894
+
895
+ declare class HuatuClipPath implements IHuatuClipPath, IHuatuDefinable {
896
+ name: string;
897
+ paths: ISvgPath[];
898
+ magicId: string;
899
+ refCount: number;
900
+ alwaysInDef: boolean;
901
+ clipRule?: "evenodd" | "nonzero";
902
+ constructor(name: string, paths?: ISvgPath[]);
903
+ buildHtmlForDef(): string;
904
+ buildId(): string;
905
+ }
906
+
907
+ /**
908
+ * The class implementation of SVG Line.
909
+ */
910
+
911
+ declare class SvgMarker implements ISvgMarker {
912
+ id: string;
913
+ units: "strokeWidth" | "userSpaceOnUse";
914
+ refX: number;
915
+ refY: number;
916
+ orient: number | "auto" | "auto-start-reverse";
917
+ viewBox: ISvgBBox;
918
+ preserveAspectRatio?: boolean;
919
+ stroke?: IStrokeConfig;
920
+ fill?: IFillConfig;
921
+ shape: ISvgShape;
922
+ constructor(id: string, shape: ISvgShape, orient: number | "auto" | "auto-start-reverse", refX?: number, refY?: number, stroke?: IStrokeConfig, fill?: IFillConfig);
923
+ buildMarkerSvg(id?: string, primaryColor?: string, secondaryColor?: string): string;
924
+ /** Static methods, and shortcut methods of build different markers, the only variant is the
925
+ * shape which is determined by different input parameters such as size, etc.
926
+ */
927
+ /** --- Circle --- */
928
+ static buildMarkerCircle(radius: number, fillColor?: string, fillOpacity?: number, strokeColor?: string, strokeWidth?: number): ISvgMarker;
929
+ /** --- Ellipse --- */
930
+ static buildMarkerEllipse(rx: number, ry: number, fillColor?: string, fillOpacity?: number, strokeColor?: string, strokeWidth?: number): ISvgMarker;
931
+ /** --- Rectangle --- */
932
+ static buildMarkerRect(w: number, h: number, fillColor?: string, fillOpacity?: number, strokeColor?: string, strokeWidth?: number): ISvgMarker;
933
+ /** --- Square --- */
934
+ static buildMarkerSquare(w: number, fillColor?: string, fillOpacity?: number, strokeColor?: string, strokeWidth?: number): ISvgMarker;
935
+ /** --- Cross --- */
936
+ static buildMarkerCross(w: number, strokeColor?: string, strokeWidth?: number): ISvgMarker;
937
+ /** --- Plus --- */
938
+ static buildMarkerPlus(w: number, strokeColor?: string, strokeWidth?: number): ISvgMarker;
939
+ /** --- Polygon --- */
940
+ static buildMarkerPolygon(radius: number, edgeCount: number, fillColor?: string, fillOpacity?: number, strokeColor?: string, strokeWidth?: number): ISvgMarker;
941
+ /** --- Rhombus --- */
942
+ static buildMarkerRhombus(width: number, height: number, fillColor?: string, fillOpacity?: number, strokeColor?: string, strokeWidth?: number): ISvgMarker;
943
+ /** --- Isosceles Triangle --- */
944
+ static buildMarkerIsoscelesTriangle(width: number, height: number, direction: "up" | "right" | "down" | "left", fillColor?: string, fillOpacity?: number, strokeColor?: string, strokeWidth?: number): ISvgMarker;
945
+ /** --- Star made by simple axises --- */
946
+ static buildMarkerStar(size: number, axisCount: number, strokeColor?: string, strokeWidth?: number): ISvgMarker;
947
+ /** --- Standard 5-angle star --- */
948
+ static buildMarkerStar5(size: number, centerEmpty?: boolean, fillColor?: string, fillOpacity?: number, strokeColor?: string, strokeWidth?: number): ISvgMarker;
949
+ /** --- Unified Star-Like Markers --- */
950
+ static buildMarkerStarUnified(axisCount: number, rIn: number, rOut: number, degOffset: number, fillColor?: string, fillOpacity?: number, strokeColor?: string, strokeWidth?: number, roundRadius?: number): ISvgMarker;
951
+ /** --- Heart --- */
952
+ static buildMarkerHeart(h1: number, ctrlLen1: number, deg1: number, farPointX: number, farPointY: number, deg2: number, ctrlLen2: number, ctrlLen3: number, h2: number, deg3: number, ctrlLen4: number, fillColor?: string, fillOpacity?: number, strokeColor?: string, strokeWidth?: number): ISvgMarker;
953
+ /** --- Arrow Head --- */
954
+ static buildArrowHead(type: "solid-angle" | "solid-two-angle" | "simple", length: number, openDeg: number, len2Ratio?: number, makeSmooth?: boolean, makeTriangle?: boolean, color?: string): ISvgMarker;
955
+ /** The predefined markers */
956
+ static preDefines: {
957
+ [id: string]: ISvgMarker;
958
+ };
959
+ }
960
+
961
+ declare class HuatuMarker implements IHuatuMarker, IHuatuDefinable {
962
+ static TYPES: {
963
+ [key: string]: string[];
964
+ };
965
+ name: string;
966
+ marker: ISvgMarker;
967
+ primaryColor?: string;
968
+ secondaryColor?: string;
969
+ refCount: number;
970
+ alwaysInDef: boolean;
971
+ magicId: string;
972
+ constructor(name: string, marker: ISvgMarker);
973
+ buildHtmlForDef(): string;
974
+ buildId(): string;
975
+ static getAllMarkerTypeWords(): string[];
976
+ static buildMarkerFromParams(name: string, params: IMarkerParams): SvgMarker | string;
977
+ }
978
+
979
+ interface IHuatuStyleParams {
980
+ styles?: string;
981
+ fill?: string;
982
+ fillOpacity?: number;
983
+ opaque?: number;
984
+ fillRule?: string;
985
+ fillColor?: string;
986
+ stroke?: string;
987
+ lineJoin?: string;
988
+ lineCap?: string;
989
+ strokeColor?: string;
990
+ strokeOpacity?: number;
991
+ strokeWidth?: number;
992
+ dashArray?: number[];
993
+ dashOffset?: number;
994
+ gradient?: string;
995
+ pattern?: string;
996
+ marker?: string;
997
+ clip?: string;
998
+ markerStart?: string;
999
+ markerMid?: string;
1000
+ markerEnd?: string;
1001
+ }
1002
+ declare class HuatuStyle implements IHuatuStyle, IHuatuCss {
1003
+ refStyles: HuatuStyle[];
1004
+ name?: string;
1005
+ fillColor?: string;
1006
+ fillOpacity?: number;
1007
+ fillPattern?: HuatuPattern;
1008
+ fillRule?: "nonzero" | "evenodd";
1009
+ fillGradient?: string;
1010
+ strokeColor?: string;
1011
+ strokeWidth?: number;
1012
+ strokeOpacity?: number;
1013
+ strokeLineCap?: TSvgLineCap;
1014
+ strokeLineJoin?: TSvgLineJoin;
1015
+ strokeMiterLimit?: number;
1016
+ strokeDashArray?: number[] | "none";
1017
+ strokeDashOffset?: number;
1018
+ markerStart?: HuatuMarker;
1019
+ markerMid?: HuatuMarker;
1020
+ markerEnd?: HuatuMarker;
1021
+ clipPath?: HuatuClipPath;
1022
+ refCount: number;
1023
+ magicId: string;
1024
+ constructor(name?: string);
1025
+ copyRefAttrs(): void;
1026
+ buildAttrArray(): string[][];
1027
+ buildCss(): string;
1028
+ buildSvgAttr(direct?: boolean): string;
1029
+ toPathConfigs(): IPathConfigs;
1030
+ static buildStyleClassName(style: HuatuStyle): string;
1031
+ static judgeStrokeWidth(style?: IHuatuStyle): number;
1032
+ static buildForSvg(style?: IHuatuStyle, direct?: boolean): string;
1033
+ static convertStyleToPathConfigs(style: HuatuStyle): IPathConfigs;
1034
+ static optsFill: IKeyValueOptions;
1035
+ static optsFillColorAndOpacity: IKeyValueOptions;
1036
+ static optsStroke: IKeyValueOptions;
1037
+ static optsMarker: IKeyValueOptions;
1038
+ static optsStyle: IKeyValueOptions;
1039
+ }
1040
+
1041
+ declare class HuatuSymbolArray extends HuatuDrawingGroup implements IHuatuSymbolArray {
1042
+ static METHODS: string[];
1043
+ symbol: HuatuSymbol;
1044
+ arrayMethod: "polar" | "line" | "2d";
1045
+ startPoint?: ISvgPoint;
1046
+ deltaX: number;
1047
+ deltaY: number;
1048
+ /**
1049
+ * This count will be shared when Array specified as Polar or Line type
1050
+ * If specified as 2D, then countX and countY will work.
1051
+ */
1052
+ count: number;
1053
+ countX: number;
1054
+ countY: number;
1055
+ center?: ISvgPoint;
1056
+ startDeg?: number;
1057
+ deltaDeg?: number;
1058
+ alignCenter?: boolean;
1059
+ transforms: IHuatuTransform[];
1060
+ constructor(name: string, symbol: HuatuSymbol, desc?: string);
1061
+ /**
1062
+ * Resolve the Linear generation of the Symbol Array
1063
+ * @param count The Count to place the symbol
1064
+ * @param dx Interval in X-axis
1065
+ * @param dy Interval in Y-axis
1066
+ * @param scale Scale factor of the Symbol, could be a number, or a func like Si = f(i) where i is the growing index
1067
+ */
1068
+ configLine(startPoint: ISvgPoint, count: number, dx?: number, dy?: number, scale?: number | ((n: number) => number), rotDeg?: number): void;
1069
+ /**
1070
+ * Resolve the 2D generation of the Symbol Array
1071
+ * @param countX The count in X-axis
1072
+ * @param countY The Count in Y-axis
1073
+ * @param dx Interval in X-axis
1074
+ * @param dy Interval in Y-axis
1075
+ * @param scale Scale factor of the symbol, it could be a number or a func like Sxy = f(ix, iy), where ix and iy
1076
+ * is the growing index in X- and Y-axis
1077
+ */
1078
+ config2D(startPoint: ISvgPoint, countX: number, countY: number, dx?: number, dy?: number, scale?: number | ((nx: number, ny: number) => number), rotDeg?: number): void;
1079
+ /**
1080
+ * Resolve the polar method of arraying
1081
+ * @param count How many symbols should be arrayed
1082
+ * @param center The center to make the Array, i.e. the center of rotating
1083
+ * @param radius How far should be the symbol located from the center, it could be a function of rotating of Angle,
1084
+ * e.g. R = f(theta), here, the unit of theta is Radian(not degree), to make it convenient to import
1085
+ * existing math curves which does this way
1086
+ * @param scale How large will the symbol be scaled to, it could be a function of radius
1087
+ * @param startDeg The start rotating angle, in degree
1088
+ * @param deltaDeg The Interval of the rotating angle
1089
+ * @param symbolNotRotate A switch to make sure if the symbol should stay not rotated
1090
+ */
1091
+ configPolar(count: number, center: ISvgPoint, radius: number | ((theta: number) => number), scale?: number | ((radius: number) => number), // The Scale parameter, if could be the function of Radius
1092
+ startDeg?: number, deltaDeg?: number, symbolNotRotate?: boolean): void;
1093
+ static optsSymbolArray: IKeyValueOptions;
1094
+ }
1095
+
1096
+ declare class HuatuLabelStyle implements IHuatuLabelStyle, IHuatuCss {
1097
+ static PREDEFINED_FONT_NAMES: string[];
1098
+ static DECORATION_LINES: string[];
1099
+ static TEXT_ALIGNS: string[];
1100
+ refStyles: HuatuLabelStyle[];
1101
+ name: string;
1102
+ color?: string;
1103
+ font?: string;
1104
+ fontSize?: number;
1105
+ textAlign?: string;
1106
+ bold?: boolean;
1107
+ italic?: boolean;
1108
+ addLine?: string;
1109
+ lineHeight?: number;
1110
+ refCount: number;
1111
+ magicId: string;
1112
+ constructor(name: string);
1113
+ buildAttrArray(): string[][];
1114
+ buildCss(): string;
1115
+ getStylePure(): IHuatuLabelStylePure;
1116
+ static makePureStyle(srcStyle: IHuatuLabelStylePure): IHuatuLabelStylePure;
1117
+ static copyRefStyle(sty: IHuatuLabelStylePure, srcStyle: IHuatuLabelStylePure): IHuatuLabelStylePure;
1118
+ static buildStyleClassName(style: HuatuLabelStyle): string;
1119
+ static resolveFontName(font: string): string;
1120
+ static getDecorationLine(decorLine: string): string | undefined;
1121
+ }
1122
+
1123
+ declare class HuatuLabel implements IHuatuLabel, IHuatuFinalDraw {
1124
+ static ANCHOR_POSITIONS: string[];
1125
+ static DEFAULT_WIDTH: number;
1126
+ static DEFAULT_FONT_SIZE: number;
1127
+ text: string;
1128
+ width: number;
1129
+ height: number;
1130
+ location: ISvgPoint;
1131
+ rotDeg: number;
1132
+ anchorPos: string;
1133
+ anchorX: number;
1134
+ anchorY: number;
1135
+ anchorOffset: ISvgPoint;
1136
+ compRotDeg?: number;
1137
+ compRefPoint?: ISvgPoint;
1138
+ styles: HuatuLabelStyle[];
1139
+ color?: string;
1140
+ font?: string;
1141
+ fontSize?: number;
1142
+ textAlign?: string;
1143
+ bold?: boolean;
1144
+ italic?: boolean;
1145
+ addLine?: string;
1146
+ lineHeight?: number;
1147
+ bgColor?: string;
1148
+ borderColor?: string;
1149
+ constructor(text: string, width?: number, height?: number);
1150
+ getRealLocation(): ISvgPoint;
1151
+ getBBox(): ISvgBBox;
1152
+ setAnchor(anchorPos: string): void;
1153
+ makeAnchoringMove(): ISvgPoint | undefined;
1154
+ buildEmbeddedStyle(): string;
1155
+ buildHtml(buildType: SvgBuildType): string;
1156
+ getStylePure(): IHuatuLabelStylePure;
1157
+ adjustForComponent(placement: IHuatuComponentPlacement): void;
1158
+ }
1159
+
1160
+ interface IHuatuTransformParams {
1161
+ move?: string;
1162
+ rotDeg?: string;
1163
+ at?: string;
1164
+ scale?: number;
1165
+ }
1166
+
1167
+ interface IHuatuDrawingParams extends IHuatuStyleParams, IHuatuTransformParams {
1168
+ alignCenter?: boolean;
1169
+ radius?: number[];
1170
+ }
1171
+ interface IHuatuDrawingSmoothParams {
1172
+ factor?: number;
1173
+ mode?: string;
1174
+ }
1175
+
1176
+ declare class HuatuBlock extends HuatuDrawingGroup implements IHuatuDefinable {
1177
+ alwaysInDef: boolean;
1178
+ refCount: number;
1179
+ magicId: string;
1180
+ constructor(name: string, desc?: string);
1181
+ buildId(): string;
1182
+ buildHtmlForDef(): string;
1183
+ getLinkId(): string;
1184
+ }
1185
+
1186
+ declare class HuatuLayer extends HuatuDrawingGroup {
1187
+ constructor(name: string, desc?: string);
1188
+ }
1189
+
1190
+ /**
1191
+ * The class implementation of SVG BBOX (Bounding box).
1192
+ */
1193
+
1194
+ declare class SvgBBox implements ISvgBBox {
1195
+ x: number;
1196
+ y: number;
1197
+ w: number;
1198
+ h: number;
1199
+ isDummy: boolean;
1200
+ constructor(x: number, y: number, w: number, h: number, dummy?: boolean);
1201
+ copy(): ISvgBBox;
1202
+ toMaxMins(): ISvgBBoxMaxMin;
1203
+ getAnchor(): ISvgPoint;
1204
+ getCenter(): ISvgPoint;
1205
+ buildString(): string;
1206
+ mergeAnother(box: ISvgBBox): ISvgBBox;
1207
+ /** Here this function will extend the border 2*strokeWidth far away,
1208
+ * It is not accurate, and might be not very correct since there is another
1209
+ * factor that miter limit determines. So here it is just some simple
1210
+ * and approximating method to estimate the boundary of the bbox with
1211
+ * some stroke. To precisely estimate the extended bbox, we should examine
1212
+ * every corner of the vertices of the path, and it is path dependent,
1213
+ * will cost a lot of calculating effort. Please modify and optimize this
1214
+ * if you have some better idea.
1215
+ */
1216
+ extendByStroke(strokeWidth: number): ISvgBBox;
1217
+ moveBy(dx: number, dy: number): SvgBBox;
1218
+ rotateAt(rotCenter: ISvgPoint, rotDeg: number): SvgBBox;
1219
+ scale(t: number): SvgBBox;
1220
+ buildRectSvg(withClass?: boolean): string;
1221
+ mirrorAt(mirrorX?: boolean, mirrorY?: boolean, at?: ISvgPoint): SvgBBox;
1222
+ static DUMMY: SvgBBox;
1223
+ static mergeTwo: (box1: ISvgBBoxMaxMin, box2: ISvgBBoxMaxMin) => ISvgBBoxMaxMin;
1224
+ static mergeBoxes: (boxes: ISvgBBox[]) => SvgBBox;
1225
+ static buildCornerPoints(bbox: ISvgBBox): ISvgPoint[];
1226
+ static fromMaxMins(xMin: number, xMax: number, yMin: number, yMax: number): SvgBBox;
1227
+ static fromCenterWidthHeight(center: ISvgPoint, w: number, h: number): SvgBBox;
1228
+ static rotateAt(bbox: ISvgBBox, rotCenter: ISvgPoint, rotDeg: number): SvgBBox;
1229
+ static moveBy(bbox: ISvgBBox, dx: number, dy: number): SvgBBox;
1230
+ static buildRectSvg(bbox: ISvgBBox, withClass?: boolean): string;
1231
+ static parseFromTwoPoints(p1: ISvgPoint, p2: ISvgPoint): SvgBBox | undefined;
1232
+ }
1233
+
1234
+ declare class HuatuJob implements IHuatuJob {
1235
+ huatu: IHuatu;
1236
+ name: string;
1237
+ desc?: string | undefined;
1238
+ drawings: IHuatuFinalDraw[];
1239
+ defines: IHuatuDefinable[];
1240
+ styles: IHuatuCss[];
1241
+ viewBox?: ISvgBBox;
1242
+ vbExplicit: boolean;
1243
+ width?: number;
1244
+ height?: number;
1245
+ config?: IHuatuConfig;
1246
+ constructor(huatu: IHuatu, name: string);
1247
+ static HUATU_HUB_KATEX_CSS: string;
1248
+ static getKatexCss: () => string;
1249
+ buildStyleDefs(): string;
1250
+ resolveDefineOfDrawingElement(element: IHuatuDrawingElement): void;
1251
+ resolveDefineOfStyle(style: IHuatuStyle): void;
1252
+ resolveDefineOfDrawing(drawing: IHuatuDrawing): void;
1253
+ resolveDefineOfLabel(label: IHuatuLabel): void;
1254
+ resolveDefineOfFinalDraw(draw: IHuatuFinalDraw): void;
1255
+ resolveDefines(): void;
1256
+ buildInnerSvg(buildType: SvgBuildType): string;
1257
+ buildSvgOnly(inner: string, extraAttrs: string[][]): string;
1258
+ buildWithEmptyMsg(): string;
1259
+ buildSvg(buildType: SvgBuildType, withSize?: boolean, width?: number, height?: number): string;
1260
+ buildSvgOfScale(buildType: SvgBuildType, scale?: number): string;
1261
+ buildHtml(buildType: SvgBuildType, indent?: boolean, withSize?: boolean): string;
1262
+ buildSvgStandalone(buildType: SvgBuildType, indent?: boolean, withSize?: boolean): string;
1263
+ calcViewBox(): SvgBBox | undefined;
1264
+ getViewBoxWithoutLabels(): ISvgBBox;
1265
+ buildHtmlForComponent(): {
1266
+ graphs: string;
1267
+ labels: string;
1268
+ };
1269
+ }
1270
+
1271
+ declare class HuatuComponentDef implements IHuatuComponentDef {
1272
+ static REGEX_INPUT_VAR_USE_MATCH: RegExp;
1273
+ name: string;
1274
+ desc?: string;
1275
+ def: IHuatuYmlObj;
1276
+ inputVars: IHuatuInputVar[];
1277
+ isValid: boolean;
1278
+ errors: IHuatuResolvingError[];
1279
+ constructor(name: string, def?: string | IHuatuYmlObj);
1280
+ defineFromString(url: string): void;
1281
+ defineFromObj(obj: IHuatuYmlObj): void;
1282
+ replaceInputVars(vars: IHuatuComponentInputVars): IHuatuYmlObj | string[];
1283
+ parseInputVars(obj: IHuatuYmlObj): IHuatuResolvingError | undefined;
1284
+ cleanDefObj(obj: IHuatuYmlObj): IHuatuYmlObj;
1285
+ }
1286
+
1287
+ declare class HuatuComponentPlacement implements IHuatuComponentPlacement {
1288
+ isValid: boolean;
1289
+ name: string;
1290
+ location: ISvgPoint;
1291
+ def: HuatuComponentDef;
1292
+ huatuDef?: IHuatuYmlObj;
1293
+ huatu?: WtHuatu;
1294
+ givenInputVars: IHuatuComponentInputVars;
1295
+ ports: IHuatuComponentPort[];
1296
+ mirror?: HuatuComponentPlacementMirrorType;
1297
+ rotDeg?: number;
1298
+ errors: IHuatuResolvingError[];
1299
+ refPointType: HuatuComponentPlacementRefPointType;
1300
+ rotateLabel?: boolean | undefined;
1301
+ portsSettled: IHuatuComponentPortSettled[];
1302
+ constructor(name: string, location: ISvgPoint, def: HuatuComponentDef, inputVars?: IHuatuComponentInputVars, mirror?: HuatuComponentPlacementMirrorType, rotateDeg?: number, refPointType?: HuatuComponentPlacementRefPointType, rotateLabel?: boolean);
1303
+ setMirror(mirrorType: HuatuComponentPlacementMirrorType): void;
1304
+ rotate(deg: number): void;
1305
+ getRefPoint(): ISvgPoint;
1306
+ adjustLabels(): void;
1307
+ settlePorts(): void;
1308
+ static REF_POINT_TYPES: string[];
1309
+ static MIRROR_TYPES: string[];
1310
+ static optsComponentPlacement: IKeyValueOptions;
1311
+ }
1312
+
1313
+ declare class HuatuComponentPort implements IHuatuComponentPort {
1314
+ anchor: ISvgPoint;
1315
+ name: string;
1316
+ idx?: number;
1317
+ rayDeg: number;
1318
+ attr?: "in" | "out" | "inout" | "unset" | "hiz" | "pu" | "pd";
1319
+ minHoldLen: number;
1320
+ constructor(name: string, anchor: ISvgPoint);
1321
+ static optsComponentPort: IKeyValueOptions;
1322
+ static isTwoPortsParallel: (p1: IHuatuComponentPortSettled, p2: IHuatuComponentPortSettled) => boolean;
1323
+ static isTwoPortsPerpendicular: (p1: IHuatuComponentPortSettled, p2: IHuatuComponentPortSettled) => boolean;
1324
+ static isTwoPortsOnSameLine: (p1: IHuatuComponentPortSettled, p2: IHuatuComponentPortSettled) => boolean;
1325
+ static isTwoPortsFacing: (p1: IHuatuComponentPortSettled, p2: IHuatuComponentPortSettled) => boolean;
1326
+ }
1327
+
1328
+ interface IHuatuNet {
1329
+ name?: string;
1330
+ magicId: string;
1331
+ addWire(wire: IHuatuWire): void;
1332
+ getWires(): IHuatuWire[];
1333
+ }
1334
+ interface IHuatuWire {
1335
+ portFrom?: IHuatuComponentPortSettled;
1336
+ pointFrom?: ISvgPoint;
1337
+ portTo?: IHuatuComponentPortSettled;
1338
+ pointTo?: ISvgPoint;
1339
+ type: "auto" | "line" | "hv" | "vh" | "hvh" | "vhv" | "hvhv" | "hvhvh" | "vhvh" | "vhvhv" | string;
1340
+ radius?: number | number[];
1341
+ turn?: number;
1342
+ turnX?: number;
1343
+ turnY?: number;
1344
+ turnAt?: ISvgPoint;
1345
+ xMin?: number;
1346
+ xMax?: number;
1347
+ yMin?: number;
1348
+ yMax?: number;
1349
+ net?: IHuatuNet;
1350
+ }
1351
+
1352
+ declare class HuatuNet implements IHuatuNet {
1353
+ name?: string;
1354
+ magicId: string;
1355
+ constructor(name?: string);
1356
+ wires: IHuatuWire[];
1357
+ addWire(wire: IHuatuWire): void;
1358
+ getWires(): IHuatuWire[];
1359
+ resolveWirePoints(): void;
1360
+ }
1361
+
1362
+ declare class WtHuatu implements IHuatu {
1363
+ title?: string;
1364
+ desc?: string;
1365
+ config?: IHuatuConfig;
1366
+ width?: number;
1367
+ height?: number;
1368
+ viewBox?: ISvgBBox;
1369
+ vars: IHuatuVar[];
1370
+ points: IHuatuPoint[];
1371
+ pointSeries: IHuatuPointSeries[];
1372
+ paths: HuatuPath[];
1373
+ pathSeries: HuatuPathSeries[];
1374
+ clips: HuatuClipPath[];
1375
+ patterns: HuatuPattern[];
1376
+ markers: HuatuMarker[];
1377
+ styles: HuatuStyle[];
1378
+ labelStyles: HuatuLabelStyle[];
1379
+ arrays: HuatuSymbolArray[];
1380
+ defines: IHuatuDefinable[];
1381
+ symbols: HuatuSymbol[];
1382
+ blocks: HuatuBlock[];
1383
+ labels: IHuatuLabel[];
1384
+ layers: HuatuLayer[];
1385
+ compDefs: HuatuComponentDef[];
1386
+ compPlacements: HuatuComponentPlacement[];
1387
+ compPorts: HuatuComponentPort[];
1388
+ solvedXPoints: ISolvedXPoints[];
1389
+ nets: HuatuNet[];
1390
+ draw?: HuatuJob;
1391
+ jobs: HuatuJob[];
1392
+ infos: string[];
1393
+ warnings: string[];
1394
+ resolvingErrors: IHuatuResolvingError[];
1395
+ varErrors: string[];
1396
+ pointErrors: string[];
1397
+ constructor();
1398
+ static REGEX_LABEL_DEF: RegExp;
1399
+ static REGEX_WIRE_DEF: RegExp;
1400
+ static REGEX_ANGLE_MARK_DEF: RegExp;
1401
+ static REGEX_DIM_MARK_DEF: RegExp;
1402
+ static REGEX_SHAPE_AND_DRAWING_DEF: RegExp;
1403
+ /**
1404
+ * The shortcut function to replace all the vars in an expression with actual values.
1405
+ * @param expr The expression to be replaced
1406
+ * @returns The result after replaced all the vars
1407
+ */
1408
+ replaceVars(expr: string): string;
1409
+ /**
1410
+ * A shortcut function to replace all the occurred point coordinates in a point composing expression
1411
+ * @param expr The point coordinate consisting of something like `pA.x`
1412
+ * @returns The expression with `pA.x` replaced with 3 and `pA.y` with 4,
1413
+ * if `pA = (3, 4)`
1414
+ */
1415
+ replaceCoors(expr: string): string;
1416
+ replaceModelParams(expr: string): string;
1417
+ /**
1418
+ * The function to resolve a user input VAR
1419
+ * @param expr The user input of a VAR
1420
+ * @returns the resolved result of the VAR
1421
+ */
1422
+ resolveVarExpr(expr: string): number | undefined;
1423
+ /**
1424
+ * Resolve the var provided, and add it into var list.
1425
+ * If some error encountered, then some error message will be returned.
1426
+ * @param name Name of the var
1427
+ * @param value Presentation of the var
1428
+ */
1429
+ resolveVar(name: string, value: string): string[];
1430
+ addPoint(point: IHuatuPoint): void;
1431
+ /**
1432
+ * The unified method to resolve/calculate the X/Y coordinate of a Point.
1433
+ * It can resolve some thing like `pA.x + sin(b) * (5 + r) + pB.y`
1434
+ * It will replace the coors of other point(s) and replace functions and vars
1435
+ * Then finally evaluate the result.
1436
+ * @param expr The expression of X/Y coordinate of a Point
1437
+ * @returns The resolved coordinate, a number
1438
+ */
1439
+ resolvePointCoorsExpr(expr: string): number | undefined;
1440
+ /**
1441
+ * Resolve a point from some PointSeries(with index) or Some Point (by name), or
1442
+ * from the definition of XY coordinates.
1443
+ * @param expr The string to query of build a point
1444
+ * @returns The identified point or undefined
1445
+ */
1446
+ resolvePointFromExpr(expr: string): ISvgPoint | undefined;
1447
+ /**
1448
+ * Resolve the point directly defined, by supplying name and definition
1449
+ * @param name name of the point
1450
+ * @param value Presented form to calculate the point
1451
+ */
1452
+ resolvePoint(name: string, value: string): string[];
1453
+ resolveSeparatedNumbers(def: string): number[];
1454
+ /**
1455
+ * This function is some unified method to resolve the (Geometry) Model of the shape defined by user.
1456
+ * This function is normally only be used under this module.
1457
+ * @param def The Definition string to build/specify one Shape, e.g. "circle;p0;5" means making some circle
1458
+ * centered at point p0 and having radius of 5
1459
+ * @returns Error Message if errored or the resolved Model of the shape
1460
+ */
1461
+ resolveShapeDef(def: string): IGeometryModel | string;
1462
+ /**
1463
+ * The sub function to resolve the input of duplication-to defines
1464
+ * @param def The definition string for the duplication
1465
+ * @param withLineJoin A switch to determine whether introducing Line Join features, this is specialized for Segged-Path
1466
+ * Because for basic types, there will be no such issue, it will always be smooth and consistent
1467
+ * @returns
1468
+ */
1469
+ tryAsPathDuplication(def: string, withLineJoin?: boolean): ISvgPath | string | undefined;
1470
+ /**
1471
+ * Resolve the shape definitions
1472
+ * @param name Name of the shape
1473
+ * @param value Presentation to define the shape
1474
+ * @returns Error message
1475
+ */
1476
+ resolveShape(name: string, value: string): string[];
1477
+ tryPointOrPointSeries(def?: string): IPoint[] | undefined;
1478
+ tryNumberSeries(def?: string): number[];
1479
+ resolveShapesFromDef(def: string): IGeometryModel[] | string;
1480
+ /**
1481
+ * Resolve the Shape Series defined
1482
+ * @param name Name of the shape series
1483
+ * @param value The definition of the series
1484
+ * @returns Error message if any
1485
+ */
1486
+ resolveShapeSeries(name: string, value: string): string[];
1487
+ getResolvedXPoints(id1: string, id2: string): ISvgPoint[] | undefined;
1488
+ makeXPoints(id1: string, id2: string): IResultResolveXPoints;
1489
+ /**
1490
+ * Resolve the Intersection point
1491
+ * @param name Name of the intersection point
1492
+ * @param value Presentation to resolve the point
1493
+ * @returns Error message
1494
+ */
1495
+ resolveXPoint(name: string, value: string): string[];
1496
+ /**
1497
+ * Resolve Calculated Point, this normally will get e.g. some point on a circle,
1498
+ * center(s) of a triangle, middle point of some line-segment, etc.
1499
+ * @param name Name of the Calculated point
1500
+ * @param value Presentation to resolve the point, the possible format of the CPoint:
1501
+ * - circle; deg deg running along the circle, e.g. 'c1;30'
1502
+ * - ellipse; deg deg running along the ellipse e.g. 'ell1; -90'
1503
+ * - line; l, l could be any value
1504
+ * - lineseg; t t in [0, 1]
1505
+ * - bezier2; t t in [0, 1]
1506
+ * - bezier3; t t in [0, 1]
1507
+ * - polygon; N; [t] t-th point on the N-th side, t has the same meaning of lineseg, if t is not present, then N is the N-th vertex
1508
+ * - polyline; N; [t] t- th point on the N-th seg, t has the same meaning of Lineseg, if t is not present, then N is the N-th point
1509
+ * - arc; t t-th point on the arc, from start angle to end ang, i.e. t=0 means start, and t=1 means end
1510
+ * - triangle; 1/2/3; [t] t-th point on the 1/2/3-th side, t has the same meaning of lineseg, is t is not present, then it means vertex
1511
+ * - triangle; cIn/cOut Center of the inner/outer circle
1512
+ * - triangle; cG Center of gravity
1513
+ * - triangle; A/B/C 1/2/3-th vertex of the triangle
1514
+ * - rectangle; nw/sw/se/ne nw/sw/se/ne vertex point of the rect
1515
+ * - rectangle; n/w/s/e; t t-th point on the N/W/S/E side, t has the same meaning of lineseg
1516
+ * - rectangle; nm/wm/sm/em middle point on N/W/S/E side, easy to see that 'nm' means 'n; 0.5'
1517
+ * @returns Error message
1518
+ */
1519
+ resolveCPoint(name: string, value: string): string[];
1520
+ /**
1521
+ * A small function to resolve the Range definition input by use
1522
+ * @param def The definition string for a range, it should be like 'start|step|end'
1523
+ * @returns The resolved range, or undefined if resolve failed
1524
+ */
1525
+ resolveRange(def?: string): NumberRange | undefined;
1526
+ /**
1527
+ * Resolve the Point Series definitions
1528
+ * @param name Name of the Point Series
1529
+ * @param value The definition string of the Point Series, e.g. "circ1; 0 | 15 | 60", which means get the points on
1530
+ * Circle "circ1", with the degrees starting from 0 to 60(not included) with interval of 15.
1531
+ * And we can the format of "0 | 15 | 60" a range
1532
+ * The possible formats that could produce point series are:
1533
+ * - p1; p2; p3; p4; ... Just simple list of defined points
1534
+ * - circle; deg[] or deg_range Discrete degs or deg range running along the circle, e.g. 'c1;0 | 5 | 50' or 'c1; 0, 23, 33, 44'
1535
+ * - ellipse; deg[] or deg_range Discrete degs or deg range running along the Ellipse, e.g. 'ell1; 20 | 5 | 180' or 'ell1; 3, 4, 8, 90'
1536
+ * - line; l[] or l_range, Discrete length collection or a range of length
1537
+ * - lineseg; t[] or t_range Discrete t's or range of t, t need to be in [0, 1];
1538
+ * - bezier2; t[] or t_range Discrete t's or range of t, t need to be in [0, 1];
1539
+ * - bezier3; t[] or t_range Discrete t's or range of t, t need to be in [0, 1];
1540
+ * - polygon; N; t[] Discrete t's or range of t, on the N-th side of Polygon
1541
+ * - polygon; n1, n2, n3,... The n-th vertex of the polygon, n1, n2, n3... need to be in [1, N]
1542
+ * - polyline; N; [t] Discrete t's or range of t, on the N-th segment of Polyline, N needs to be in [1, N-1]
1543
+ * - polyline; n1, n2, n3,... The n-th point of Polyline, n1, n2, n3... needs to be in [1, N]
1544
+ * - arc; t[] or t_range Discrete t's or range of t, t need to be in [0, 1];
1545
+ * - triangle; [1/2/3/A/B/C/cIn/cOut/cG] The 1/2/3/A/B/C/cIn/cOut/cG point of the triangle, in collection
1546
+ * - rectangle; [nw/sw/se/ne/nm/wm/sm/em/n/e/s/w] nw/sw/se/ne/nm/wm/sm/em/n/e/s/w point of the rect, in collection, same meaning as in CPoint resolving
1547
+ * - rectangle; north/west/south/east; t[] or t_range t's or range of t points on the N/W/S/E side, t is in [0, 1]
1548
+ * @returns Error Message if any
1549
+ */
1550
+ resolvePointSeries(name: string, value: string): string[];
1551
+ /**
1552
+ * A shortcut function to resolve a single segment which is one of the compound path.
1553
+ * Only the Valid segment types, i.e. LineSeg, Arc, Bezier2 and Bezier3 are accepted
1554
+ * as segments
1555
+ * @param def The input of the segment
1556
+ * @returns The resolved segmented path, or close mark
1557
+ */
1558
+ resolveSegmentedPath(def: string): ISvgPathSegment | ISvgPathSegment[] | "CLOSE_MARK" | undefined;
1559
+ tryPathTransform(def: string, name?: string): HuatuPath | undefined;
1560
+ /**
1561
+ * Resolve Path definition, the input might be a string, or string array
1562
+ * @param name Name of the Calculated point
1563
+ * @param value Presentation to resolve the path
1564
+ * @returns Error message
1565
+ */
1566
+ resolvePath(name: string, value: string | string[]): string[];
1567
+ /**
1568
+ * Check if the user has given a valid string to specify the pattern, if it is a name for "predefined"
1569
+ * pattern, then the pattern will be copied into the in-use collection with the same name. Or it
1570
+ * needs to be some pattern defined by user manually.
1571
+ * @param ptn The defined name or pre-defined name for the Pattern user wants to use
1572
+ * @returns The Pattern or undefined if not found
1573
+ */
1574
+ checkPattern(ptn: string): HuatuPattern | undefined;
1575
+ /**
1576
+ * Check if the user has given a valid string to specify the marker, if it is a name for "predefined"
1577
+ * marker, then the marker will be copied into the in-use collection with the same name. Or it
1578
+ * needs to be some marker defined by user manually.
1579
+ * @param ptn The defined name or pre-defined name for the Marker user wants to use
1580
+ * @returns The Marker or undefined if not found
1581
+ */
1582
+ checkMarker(mkr: string): HuatuMarker | undefined;
1583
+ parseStyleFromKeyValueResults(parseRes: IKeyValueParsingResult<IHuatuDrawingParams>): HuatuStyle;
1584
+ /**
1585
+ * Resolve Style definition, the input might be a string, or a style object
1586
+ * @param name Name of the style
1587
+ * @param value Presentation to resolve the style
1588
+ * @returns Error message
1589
+ */
1590
+ resolveStyle(name: string, value: string | IHuatuYmlStyle): string[];
1591
+ /**
1592
+ * The entry function to resolve a LabelStyle defined
1593
+ * @param name Name of the LabelStyle defined
1594
+ * @param value The definition string/object for the LabelStyle
1595
+ * @returns Error message if any
1596
+ */
1597
+ resolveLabelStyle(name: string, value: string | IHuatuYmlLabelStyle): string[];
1598
+ /**
1599
+ * Resolve Symbol definition, the input might be a string, or a string list
1600
+ * @param name Name of the Symbol
1601
+ * @param value Presentation to resolve the symbol
1602
+ * @returns Error message
1603
+ */
1604
+ resolveSymbol(name: string, value: string | string[]): string[];
1605
+ /**
1606
+ * A tool function to convert the user-defined radius-/scale-function into Function
1607
+ * and check if the function could produce valid result, which should be positive number.
1608
+ * @param funcDef The definition of the function, e.g. 'x => (x + 2)*1.5
1609
+ * @param paramCount How many inputs the function will take, normally, 1 or 2
1610
+ * @returns The function or undefined
1611
+ */
1612
+ testUserFunc(funcDef: string, paramCount: number): Function | undefined;
1613
+ /**
1614
+ * Resolve Array definition, the input might be a string, or the object describing the array
1615
+ * @param name Name of the Array
1616
+ * @param value Presentation to resolve the array, shortcut string, or the object
1617
+ * @returns Error message
1618
+ */
1619
+ resolveArray(name: string, value: string | IHuatuYmlSymbolArray): string[];
1620
+ /**
1621
+ * Resolve Clip Path definition, the input might be a string, or a string list
1622
+ * @param name Name of the Clip Path
1623
+ * @param value Presentation to resolve the clip path
1624
+ * @returns Error message
1625
+ */
1626
+ resolveClip(name: string, value: string | string[]): string[];
1627
+ /**
1628
+ * Resolve Pattern definition, the input might be an object, describe how the pattern is designed
1629
+ * @param name Name of the Pattern
1630
+ * @param value Presentation to resolve the pattern
1631
+ * @returns Error message
1632
+ */
1633
+ resolvePattern(name: string, value: string | IHuatuYmlPattern): string[];
1634
+ /**
1635
+ * Resolve Marker definition, the input might be an object, describe how the marker is designed
1636
+ * @param name Name of the Marker
1637
+ * @param value Presentation to resolve the Marker
1638
+ * @returns Error message
1639
+ */
1640
+ resolveMarker(name: string, value: string | IHuatuYmlMarker): string[];
1641
+ parseLabelDef(format: string, text: string): HuatuLabel | string;
1642
+ parseStyleAndTransformString(def: string): {
1643
+ style?: IHuatuStyle;
1644
+ transform?: IHuatuTransform;
1645
+ alignCenter?: boolean;
1646
+ smooth?: IHuatuDrawingSmoothParams;
1647
+ radius?: number[];
1648
+ };
1649
+ /**
1650
+ * Resolve the "modelled" drawing by definition
1651
+ * @param def The definition of the drawing of a shape, It might have two formats:
1652
+ * - Ad-Hoc Shape definitions and style/transform settings
1653
+ * - Referring a defined (named) module, and specifying style/transform
1654
+ * @param allowedTypes The allowed sets of module that this function call will search, it is designed in the way that
1655
+ * Different Drawing Group will accept different types of modules *
1656
+ * @returns The resolved Drawing or error message
1657
+ */
1658
+ resolveDrawingOfShapes(def: string, allowedTypes: string[]): IHuatuFinalDraw | string;
1659
+ resolveWireTerminal(def?: string): IHuatuComponentPortSettled | IHuatuPoint | ISvgPoint | undefined;
1660
+ parseWireDef(def: string): IHuatuFinalDraw | string;
1661
+ parseAngleMarkDef(def: string): IHuatuFinalDraw | string;
1662
+ parseDimMarkDef(def: string): IHuatuFinalDraw | string;
1663
+ /**
1664
+ * Unified function to resolve drawing definition
1665
+ * @param def The unified definition of a "drawing", including a label, or named modules
1666
+ * @param allowedTypes See the explanation in function `resolveDrawingOfShapes`
1667
+ * @returns The final draw or error message
1668
+ */
1669
+ resolveAsDrawingItem(def: string, allowedTypes: string[]): IHuatuFinalDraw | string;
1670
+ isDrawingNameValid(name: string, level: "Symbol" | "Block" | "Layer"): string | undefined;
1671
+ /**
1672
+ * Resolve Block definition, the input might be a string, or a string list
1673
+ * @param name Name of the Block
1674
+ * @param value Presentation to resolve the Block
1675
+ * @returns Error message
1676
+ */
1677
+ resolveBlock(name: string, value: string | string[]): string[];
1678
+ /**
1679
+ * Resolve Layer definition, the input might be a string, or a string list
1680
+ * @param name Name of the Layer
1681
+ * @param value Presentation to resolve the Layer
1682
+ * @returns Error message
1683
+ */
1684
+ resolveLayer(name: string, value: string | string[]): string[];
1685
+ resolveViewBoxFromDef(def: string): ISvgBBox | string | undefined;
1686
+ tryViewBox(def: string): ISvgBBox | string | undefined;
1687
+ trySize(def: string): ISvgPoint | string | undefined;
1688
+ resolveJobDrawingItem(draw: string, allowedTypes: string[]): IHuatuFinalDraw | ISvgBBox | ISvgPoint | string | undefined;
1689
+ /**
1690
+ * Resolve the defined job(s) from YML design file, 'draw' is one of the jobs
1691
+ * @param jobName Name of the job, if it is 'draw', then the default global draw
1692
+ * @param def The drawing design string to compose the final draw/job
1693
+ * @returns Errors if any
1694
+ */
1695
+ resolveJob(jobName: string, def: string | string[] | IHuatuYmlJob | undefined): string[];
1696
+ buildSvg(buildType: SvgBuildType, jobName?: string | undefined, withSize?: boolean): string;
1697
+ buildSvgAsHtml(buildType: SvgBuildType, jobName?: string, indent?: boolean | undefined, withSize?: boolean): string;
1698
+ buildSvgStandalone(buildType: SvgBuildType, jobName?: string | undefined, indent?: boolean | undefined, withSize?: boolean): string;
1699
+ /** --------------- Component part ------------------------------------------------------------------------------ */
1700
+ resolveComponentDef(name: string, def: string | IHuatuYmlObj): string[];
1701
+ resolveComponentPlacement(name: string, def: string | IHuatuYmlObj): string[];
1702
+ parseComponentPorts(obj: IHuatuYmlObj): string[];
1703
+ /** --------------- Static Methods ------------------------------------------------------------------------------ */
1704
+ static tryDesc(def: string): string | undefined;
1705
+ static resolveConfig(cfg: IHuatuConfigInYml): IHuatuConfig;
1706
+ static buildEmbeddedStyles(): string;
1707
+ static RESERVED_NAMES: string[];
1708
+ }
1709
+
1710
+ declare const renderWtHuatuYml: (yml: string) => Promise<string>;
1711
+ interface IWtHuatuComponentPreviewOptions {
1712
+ mirror?: HuatuComponentPlacementMirrorType;
1713
+ rotDeg?: number;
1714
+ rotateLabel?: boolean;
1715
+ showMarks?: boolean;
1716
+ ignoreConfig?: boolean;
1717
+ }
1718
+ interface IWtHuatuRenderOptions {
1719
+ job?: string | string[];
1720
+ scale?: number;
1721
+ outputFormat?: "html" | "svg";
1722
+ componentPreview?: IWtHuatuComponentPreviewOptions;
1723
+ }
1724
+ interface IWtHuatuResolvingResult {
1725
+ huatu?: WtHuatu;
1726
+ errors: IHuatuResolvingError[];
1727
+ warnings: string[];
1728
+ infos: string[];
1729
+ }
1730
+ interface IWtHuatuRenderedJob {
1731
+ jobName: string;
1732
+ html: string;
1733
+ width?: number;
1734
+ height?: number;
1735
+ scale?: number;
1736
+ }
1737
+ interface IWtHuatuRenderResult extends IWtHuatuResolvingResult {
1738
+ inputYml: string;
1739
+ ymlParseSucceeded: boolean;
1740
+ ymlParsedObj?: IHuatuYmlObj;
1741
+ type: "huatu" | "component" | "unknown";
1742
+ rendered: IWtHuatuRenderedJob[];
1743
+ }
1744
+ declare const renderAComponent: (compObj: IHuatuYmlObj, opts?: IWtHuatuComponentPreviewOptions) => IWtHuatuResolvingResult;
1745
+ declare const renderYmlInput: (yml: string, opts: IWtHuatuRenderOptions) => Promise<IWtHuatuRenderResult>;
1746
+
1747
+ export { type IWtHuatuComponentPreviewOptions, type IWtHuatuRenderOptions, type IWtHuatuRenderResult, type IWtHuatuRenderedJob, type IWtHuatuResolvingResult, WtHuatu, renderAComponent, renderWtHuatuYml, renderYmlInput };