kicadts 0.0.2 → 0.0.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.
- package/dist/index.d.ts +4466 -0
- package/dist/index.js +14253 -0
- package/package.json +5 -2
- package/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc +0 -111
- package/.github/workflows/bun-formatcheck.yml +0 -26
- package/.github/workflows/bun-pver-release.yml +0 -70
- package/.github/workflows/bun-test.yml +0 -32
- package/.github/workflows/bun-typecheck.yml +0 -26
- package/.vscode/settings.json +0 -16
- package/AGENTS.md +0 -31
- package/TODO.md +0 -46
- package/biome.json +0 -93
- package/bunfig.toml +0 -5
- package/lib/index.ts +0 -1
- package/lib/sexpr/base-classes/SxClass.ts +0 -164
- package/lib/sexpr/base-classes/SxPrimitiveBoolean.ts +0 -35
- package/lib/sexpr/base-classes/SxPrimitiveNumber.ts +0 -26
- package/lib/sexpr/base-classes/SxPrimitiveString.ts +0 -26
- package/lib/sexpr/classes/At.ts +0 -53
- package/lib/sexpr/classes/Bus.ts +0 -103
- package/lib/sexpr/classes/BusEntry.ts +0 -169
- package/lib/sexpr/classes/Color.ts +0 -29
- package/lib/sexpr/classes/Dnp.ts +0 -8
- package/lib/sexpr/classes/EmbeddedFonts.ts +0 -68
- package/lib/sexpr/classes/ExcludeFromSim.ts +0 -8
- package/lib/sexpr/classes/FieldsAutoplaced.ts +0 -8
- package/lib/sexpr/classes/Footprint.ts +0 -849
- package/lib/sexpr/classes/FootprintAttr.ts +0 -104
- package/lib/sexpr/classes/FootprintAutoplaceCost180.ts +0 -9
- package/lib/sexpr/classes/FootprintAutoplaceCost90.ts +0 -9
- package/lib/sexpr/classes/FootprintClearance.ts +0 -9
- package/lib/sexpr/classes/FootprintDescr.ts +0 -44
- package/lib/sexpr/classes/FootprintLocked.ts +0 -32
- package/lib/sexpr/classes/FootprintModel.ts +0 -142
- package/lib/sexpr/classes/FootprintNetTiePadGroups.ts +0 -52
- package/lib/sexpr/classes/FootprintPad.ts +0 -857
- package/lib/sexpr/classes/FootprintPath.ts +0 -44
- package/lib/sexpr/classes/FootprintPlaced.ts +0 -32
- package/lib/sexpr/classes/FootprintPrivateLayers.ts +0 -56
- package/lib/sexpr/classes/FootprintSheetfile.ts +0 -44
- package/lib/sexpr/classes/FootprintSheetname.ts +0 -44
- package/lib/sexpr/classes/FootprintSolderMaskMargin.ts +0 -9
- package/lib/sexpr/classes/FootprintSolderPasteMargin.ts +0 -9
- package/lib/sexpr/classes/FootprintSolderPasteRatio.ts +0 -9
- package/lib/sexpr/classes/FootprintTags.ts +0 -44
- package/lib/sexpr/classes/FootprintTedit.ts +0 -21
- package/lib/sexpr/classes/FootprintThermalGap.ts +0 -9
- package/lib/sexpr/classes/FootprintThermalWidth.ts +0 -9
- package/lib/sexpr/classes/FootprintZoneConnect.ts +0 -9
- package/lib/sexpr/classes/FpArc.ts +0 -312
- package/lib/sexpr/classes/FpCircle.ts +0 -314
- package/lib/sexpr/classes/FpLine.ts +0 -316
- package/lib/sexpr/classes/FpPoly.ts +0 -286
- package/lib/sexpr/classes/FpPolyFill.ts +0 -48
- package/lib/sexpr/classes/FpPolyLocked.ts +0 -40
- package/lib/sexpr/classes/FpRect.ts +0 -314
- package/lib/sexpr/classes/FpText.ts +0 -375
- package/lib/sexpr/classes/FpTextBox.ts +0 -450
- package/lib/sexpr/classes/GrLine.ts +0 -264
- package/lib/sexpr/classes/GrLineAngle.ts +0 -32
- package/lib/sexpr/classes/GrLineEnd.ts +0 -61
- package/lib/sexpr/classes/GrLineLocked.ts +0 -40
- package/lib/sexpr/classes/GrLineStart.ts +0 -61
- package/lib/sexpr/classes/GrText.ts +0 -228
- package/lib/sexpr/classes/Image.ts +0 -283
- package/lib/sexpr/classes/InBom.ts +0 -8
- package/lib/sexpr/classes/Junction.ts +0 -166
- package/lib/sexpr/classes/KicadPcb.ts +0 -361
- package/lib/sexpr/classes/KicadSch.ts +0 -397
- package/lib/sexpr/classes/KicadSchGenerator.ts +0 -32
- package/lib/sexpr/classes/KicadSchGeneratorVersion.ts +0 -30
- package/lib/sexpr/classes/KicadSchVersion.ts +0 -22
- package/lib/sexpr/classes/Label.ts +0 -176
- package/lib/sexpr/classes/Layer.ts +0 -51
- package/lib/sexpr/classes/Layers.ts +0 -47
- package/lib/sexpr/classes/LibSymbols.ts +0 -61
- package/lib/sexpr/classes/NoConnect.ts +0 -90
- package/lib/sexpr/classes/OnBoard.ts +0 -8
- package/lib/sexpr/classes/PadChamfer.ts +0 -50
- package/lib/sexpr/classes/PadChamferRatio.ts +0 -9
- package/lib/sexpr/classes/PadClearance.ts +0 -9
- package/lib/sexpr/classes/PadDieLength.ts +0 -9
- package/lib/sexpr/classes/PadDrill.ts +0 -145
- package/lib/sexpr/classes/PadDrillOffset.ts +0 -54
- package/lib/sexpr/classes/PadLayers.ts +0 -71
- package/lib/sexpr/classes/PadNet.ts +0 -56
- package/lib/sexpr/classes/PadOptions.ts +0 -181
- package/lib/sexpr/classes/PadPinFunction.ts +0 -9
- package/lib/sexpr/classes/PadPinType.ts +0 -9
- package/lib/sexpr/classes/PadPrimitiveGrArc.ts +0 -272
- package/lib/sexpr/classes/PadPrimitiveGrCircle.ts +0 -298
- package/lib/sexpr/classes/PadPrimitiveGrLine.ts +0 -126
- package/lib/sexpr/classes/PadPrimitives.ts +0 -291
- package/lib/sexpr/classes/PadRectDelta.ts +0 -57
- package/lib/sexpr/classes/PadRoundrectRratio.ts +0 -9
- package/lib/sexpr/classes/PadSize.ts +0 -69
- package/lib/sexpr/classes/PadSolderMaskMargin.ts +0 -9
- package/lib/sexpr/classes/PadSolderPasteMargin.ts +0 -9
- package/lib/sexpr/classes/PadSolderPasteMarginRatio.ts +0 -9
- package/lib/sexpr/classes/PadTeardrops.ts +0 -210
- package/lib/sexpr/classes/PadThermalBridgeAngle.ts +0 -9
- package/lib/sexpr/classes/PadThermalGap.ts +0 -9
- package/lib/sexpr/classes/PadThermalWidth.ts +0 -9
- package/lib/sexpr/classes/PadZoneConnect.ts +0 -9
- package/lib/sexpr/classes/Paper.ts +0 -119
- package/lib/sexpr/classes/PcbGeneral.ts +0 -82
- package/lib/sexpr/classes/PcbGeneralLegacyTeardrops.ts +0 -44
- package/lib/sexpr/classes/PcbGeneralThickness.ts +0 -9
- package/lib/sexpr/classes/PcbGenerator.ts +0 -16
- package/lib/sexpr/classes/PcbGeneratorVersion.ts +0 -16
- package/lib/sexpr/classes/PcbLayerDefinition.ts +0 -106
- package/lib/sexpr/classes/PcbLayers.ts +0 -34
- package/lib/sexpr/classes/PcbNet.ts +0 -56
- package/lib/sexpr/classes/PcbVersion.ts +0 -9
- package/lib/sexpr/classes/Property.ts +0 -301
- package/lib/sexpr/classes/PropertyHide.ts +0 -9
- package/lib/sexpr/classes/PropertyUnlocked.ts +0 -9
- package/lib/sexpr/classes/Pts.ts +0 -67
- package/lib/sexpr/classes/RenderCache.ts +0 -221
- package/lib/sexpr/classes/SchematicText.ts +0 -171
- package/lib/sexpr/classes/Segment.ts +0 -243
- package/lib/sexpr/classes/SegmentEnd.ts +0 -59
- package/lib/sexpr/classes/SegmentLocked.ts +0 -33
- package/lib/sexpr/classes/SegmentNet.ts +0 -64
- package/lib/sexpr/classes/SegmentStart.ts +0 -59
- package/lib/sexpr/classes/Setup/PcbPlotParams.ts +0 -689
- package/lib/sexpr/classes/Setup/PcbPlotParamsBase.ts +0 -9
- package/lib/sexpr/classes/Setup/PcbPlotParamsNumericProperties.ts +0 -105
- package/lib/sexpr/classes/Setup/PcbPlotParamsStringPropertiesA.ts +0 -104
- package/lib/sexpr/classes/Setup/PcbPlotParamsStringPropertiesB.ts +0 -105
- package/lib/sexpr/classes/Setup/Setup.ts +0 -574
- package/lib/sexpr/classes/Setup/SetupPropertyTypes.ts +0 -119
- package/lib/sexpr/classes/Setup/Stackup.ts +0 -135
- package/lib/sexpr/classes/Setup/StackupLayer.ts +0 -233
- package/lib/sexpr/classes/Setup/StackupLayerProperties.ts +0 -80
- package/lib/sexpr/classes/Setup/StackupProperties.ts +0 -40
- package/lib/sexpr/classes/Setup/base.ts +0 -165
- package/lib/sexpr/classes/Setup/index.ts +0 -14
- package/lib/sexpr/classes/Setup/setupMultiValueProperties.ts +0 -53
- package/lib/sexpr/classes/Setup/setupNumericProperties.ts +0 -151
- package/lib/sexpr/classes/Setup/setupPropertyHandlers.ts +0 -90
- package/lib/sexpr/classes/Setup/setupStringProperties.ts +0 -75
- package/lib/sexpr/classes/Sheet.ts +0 -287
- package/lib/sexpr/classes/SheetFill.ts +0 -44
- package/lib/sexpr/classes/SheetInstances.ts +0 -168
- package/lib/sexpr/classes/SheetInstancesRoot.ts +0 -165
- package/lib/sexpr/classes/SheetPin.ts +0 -125
- package/lib/sexpr/classes/SheetProperty.ts +0 -115
- package/lib/sexpr/classes/SheetSize.ts +0 -44
- package/lib/sexpr/classes/Stroke.ts +0 -58
- package/lib/sexpr/classes/StrokeType.ts +0 -34
- package/lib/sexpr/classes/Symbol.ts +0 -1666
- package/lib/sexpr/classes/TextEffects.ts +0 -461
- package/lib/sexpr/classes/TitleBlock.ts +0 -369
- package/lib/sexpr/classes/Unit.ts +0 -28
- package/lib/sexpr/classes/Uuid.ts +0 -8
- package/lib/sexpr/classes/Via.ts +0 -363
- package/lib/sexpr/classes/ViaNet.ts +0 -60
- package/lib/sexpr/classes/Width.ts +0 -8
- package/lib/sexpr/classes/Wire.ts +0 -111
- package/lib/sexpr/classes/Xy.ts +0 -33
- package/lib/sexpr/classes/Zone.ts +0 -39
- package/lib/sexpr/index.ts +0 -130
- package/lib/sexpr/parseKicadSexpr.ts +0 -5
- package/lib/sexpr/parseToPrimitiveSExpr.ts +0 -245
- package/lib/sexpr/utils/indentLines.ts +0 -3
- package/lib/sexpr/utils/parseYesNo.ts +0 -12
- package/lib/sexpr/utils/quoteSExprString.ts +0 -8
- package/lib/sexpr/utils/strokeFromArgs.ts +0 -18
- package/lib/sexpr/utils/toNumberValue.ts +0 -13
- package/lib/sexpr/utils/toStringValue.ts +0 -11
- package/scripts/download-references.ts +0 -68
- package/tests/fixtures/expectEqualPrimitiveSExpr.ts +0 -199
- package/tests/fixtures/png-matcher.ts +0 -109
- package/tests/fixtures/preload.ts +0 -1
- package/tests/sexpr/KicadPcbDemos.test.ts +0 -48
- package/tests/sexpr/KicadSchDemos.test.ts +0 -49
- package/tests/sexpr/classes/Footprint.test.ts +0 -277
- package/tests/sexpr/classes/FootprintPad.test.ts +0 -78
- package/tests/sexpr/classes/FpArc.test.ts +0 -45
- package/tests/sexpr/classes/FpCircle.test.ts +0 -39
- package/tests/sexpr/classes/FpPoly.test.ts +0 -43
- package/tests/sexpr/classes/FpRect.test.ts +0 -40
- package/tests/sexpr/classes/FpTextBox.test.ts +0 -84
- package/tests/sexpr/classes/Image.test.ts +0 -58
- package/tests/sexpr/classes/KicadSch.test.ts +0 -95
- package/tests/sexpr/classes/Paper.test.ts +0 -30
- package/tests/sexpr/classes/Property.test.ts +0 -48
- package/tests/sexpr/classes/Setup.test.ts +0 -188
- package/tests/sexpr/classes/Sheet.test.ts +0 -107
- package/tests/sexpr/classes/Stroke.test.ts +0 -15
- package/tests/sexpr/classes/Symbol.test.ts +0 -96
- package/tests/sexpr/classes/TextEffects.test.ts +0 -56
- package/tests/sexpr/classes/TitleBlock.test.ts +0 -40
- package/tsconfig.json +0 -35
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
import { SxClass } from "../base-classes/SxClass"
|
|
2
|
-
import { SxPrimitiveBoolean } from "../base-classes/SxPrimitiveBoolean"
|
|
3
|
-
import type { PrimitiveSExpr } from "../parseToPrimitiveSExpr"
|
|
4
|
-
import { Width } from "./Width"
|
|
5
|
-
import { toNumberValue } from "../utils/toNumberValue"
|
|
6
|
-
|
|
7
|
-
const SUPPORTED_TOKENS = new Set(["center", "end", "width", "fill"])
|
|
8
|
-
|
|
9
|
-
export interface PadPrimitiveGrCircleConstructorParams {
|
|
10
|
-
center?: PadPrimitiveGrCircleCenter | { x: number; y: number }
|
|
11
|
-
end?: PadPrimitiveGrCircleEnd | { x: number; y: number }
|
|
12
|
-
width?: Width | number
|
|
13
|
-
fill?: PadPrimitiveGrCircleFill | boolean
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export class PadPrimitiveGrCircle extends SxClass {
|
|
17
|
-
static override token = "gr_circle"
|
|
18
|
-
static override parentToken = "primitives"
|
|
19
|
-
override token = "gr_circle"
|
|
20
|
-
|
|
21
|
-
private _sxCenter?: PadPrimitiveGrCircleCenter
|
|
22
|
-
private _sxEnd?: PadPrimitiveGrCircleEnd
|
|
23
|
-
private _sxWidth?: Width
|
|
24
|
-
private _sxFill?: PadPrimitiveGrCircleFill
|
|
25
|
-
|
|
26
|
-
constructor(params: PadPrimitiveGrCircleConstructorParams = {}) {
|
|
27
|
-
super()
|
|
28
|
-
if (params.center !== undefined) this.center = params.center
|
|
29
|
-
if (params.end !== undefined) this.end = params.end
|
|
30
|
-
if (params.width !== undefined) this.width = params.width
|
|
31
|
-
if (params.fill !== undefined) this.fill = params.fill
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
static override fromSexprPrimitives(
|
|
35
|
-
primitiveSexprs: PrimitiveSExpr[],
|
|
36
|
-
): PadPrimitiveGrCircle {
|
|
37
|
-
const circle = new PadPrimitiveGrCircle()
|
|
38
|
-
|
|
39
|
-
const { propertyMap, arrayPropertyMap } =
|
|
40
|
-
SxClass.parsePrimitivesToClassProperties(primitiveSexprs, this.token)
|
|
41
|
-
|
|
42
|
-
for (const token of Object.keys(propertyMap)) {
|
|
43
|
-
if (!SUPPORTED_TOKENS.has(token)) {
|
|
44
|
-
throw new Error(
|
|
45
|
-
`pad primitive gr_circle encountered unsupported child token "${token}"`,
|
|
46
|
-
)
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
for (const [token, entries] of Object.entries(arrayPropertyMap)) {
|
|
51
|
-
if (!SUPPORTED_TOKENS.has(token)) {
|
|
52
|
-
throw new Error(
|
|
53
|
-
`pad primitive gr_circle encountered unsupported child token "${token}"`,
|
|
54
|
-
)
|
|
55
|
-
}
|
|
56
|
-
if (entries.length > 1) {
|
|
57
|
-
throw new Error(
|
|
58
|
-
`pad primitive gr_circle does not support repeated "${token}" tokens`,
|
|
59
|
-
)
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
circle._sxCenter = propertyMap.center as
|
|
64
|
-
| PadPrimitiveGrCircleCenter
|
|
65
|
-
| undefined
|
|
66
|
-
circle._sxEnd = propertyMap.end as PadPrimitiveGrCircleEnd | undefined
|
|
67
|
-
circle._sxWidth = propertyMap.width as Width | undefined
|
|
68
|
-
circle._sxFill = propertyMap.fill as PadPrimitiveGrCircleFill | undefined
|
|
69
|
-
|
|
70
|
-
if (!circle._sxCenter) {
|
|
71
|
-
throw new Error("pad primitive gr_circle requires a center child token")
|
|
72
|
-
}
|
|
73
|
-
if (!circle._sxEnd) {
|
|
74
|
-
throw new Error("pad primitive gr_circle requires an end child token")
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return circle
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
get center(): PadPrimitiveGrCircleCenter | undefined {
|
|
81
|
-
return this._sxCenter
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
set center(value:
|
|
85
|
-
| PadPrimitiveGrCircleCenter
|
|
86
|
-
| { x: number; y: number }
|
|
87
|
-
| undefined,) {
|
|
88
|
-
this._sxCenter = normalizeCirclePoint(value, PadPrimitiveGrCircleCenter)
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
get end(): PadPrimitiveGrCircleEnd | undefined {
|
|
92
|
-
return this._sxEnd
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
set end(value:
|
|
96
|
-
| PadPrimitiveGrCircleEnd
|
|
97
|
-
| { x: number; y: number }
|
|
98
|
-
| undefined) {
|
|
99
|
-
this._sxEnd = normalizeCirclePoint(value, PadPrimitiveGrCircleEnd)
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
get width(): number | undefined {
|
|
103
|
-
return this._sxWidth?.value
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
set width(value: Width | number | undefined) {
|
|
107
|
-
if (value === undefined) {
|
|
108
|
-
this._sxWidth = undefined
|
|
109
|
-
return
|
|
110
|
-
}
|
|
111
|
-
this._sxWidth = value instanceof Width ? value : new Width(value)
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
get widthClass(): Width | undefined {
|
|
115
|
-
return this._sxWidth
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
get fill(): boolean | undefined {
|
|
119
|
-
return this._sxFill?.value
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
set fill(value: PadPrimitiveGrCircleFill | boolean | undefined) {
|
|
123
|
-
if (value === undefined) {
|
|
124
|
-
this._sxFill = undefined
|
|
125
|
-
return
|
|
126
|
-
}
|
|
127
|
-
this._sxFill =
|
|
128
|
-
value instanceof PadPrimitiveGrCircleFill
|
|
129
|
-
? value
|
|
130
|
-
: new PadPrimitiveGrCircleFill(value)
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
get fillClass(): PadPrimitiveGrCircleFill | undefined {
|
|
134
|
-
return this._sxFill
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
override getChildren(): SxClass[] {
|
|
138
|
-
const children: SxClass[] = []
|
|
139
|
-
if (this._sxCenter) children.push(this._sxCenter)
|
|
140
|
-
if (this._sxEnd) children.push(this._sxEnd)
|
|
141
|
-
if (this._sxWidth) children.push(this._sxWidth)
|
|
142
|
-
if (this._sxFill) children.push(this._sxFill)
|
|
143
|
-
return children
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
override getString(): string {
|
|
147
|
-
const lines = ["(gr_circle"]
|
|
148
|
-
if (this._sxCenter) lines.push(this._sxCenter.getStringIndented())
|
|
149
|
-
if (this._sxEnd) lines.push(this._sxEnd.getStringIndented())
|
|
150
|
-
if (this._sxWidth) lines.push(this._sxWidth.getStringIndented())
|
|
151
|
-
if (this._sxFill) lines.push(this._sxFill.getStringIndented())
|
|
152
|
-
lines.push(")")
|
|
153
|
-
return lines.join("\n")
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
SxClass.register(PadPrimitiveGrCircle)
|
|
157
|
-
|
|
158
|
-
type CirclePointConstructor<T extends PadPrimitiveGrCirclePoint> = new (
|
|
159
|
-
x: number,
|
|
160
|
-
y: number,
|
|
161
|
-
) => T
|
|
162
|
-
|
|
163
|
-
const normalizeCirclePoint = <T extends PadPrimitiveGrCirclePoint>(
|
|
164
|
-
value: T | { x: number; y: number } | undefined,
|
|
165
|
-
Constructor: CirclePointConstructor<T>,
|
|
166
|
-
): T | undefined => {
|
|
167
|
-
if (value === undefined) {
|
|
168
|
-
return undefined
|
|
169
|
-
}
|
|
170
|
-
if (value instanceof Constructor) {
|
|
171
|
-
return value
|
|
172
|
-
}
|
|
173
|
-
return new Constructor(value.x, value.y)
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
abstract class PadPrimitiveGrCirclePoint extends SxClass {
|
|
177
|
-
protected _x: number
|
|
178
|
-
protected _y: number
|
|
179
|
-
|
|
180
|
-
protected constructor(x: number, y: number) {
|
|
181
|
-
super()
|
|
182
|
-
this._x = x
|
|
183
|
-
this._y = y
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
get x(): number {
|
|
187
|
-
return this._x
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
set x(value: number) {
|
|
191
|
-
this._x = value
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
get y(): number {
|
|
195
|
-
return this._y
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
set y(value: number) {
|
|
199
|
-
this._y = value
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
override getChildren(): SxClass[] {
|
|
203
|
-
return []
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
override getString(): string {
|
|
207
|
-
return `(${this.token} ${this._x} ${this._y})`
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
class PadPrimitiveGrCircleCenter extends PadPrimitiveGrCirclePoint {
|
|
212
|
-
static override token = "center"
|
|
213
|
-
static override parentToken = "gr_circle"
|
|
214
|
-
override token = "center"
|
|
215
|
-
|
|
216
|
-
constructor(x: number, y: number) {
|
|
217
|
-
super(x, y)
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
static override fromSexprPrimitives(
|
|
221
|
-
primitiveSexprs: PrimitiveSExpr[],
|
|
222
|
-
): PadPrimitiveGrCircleCenter {
|
|
223
|
-
const [rawX, rawY] = primitiveSexprs
|
|
224
|
-
const x = toNumberValue(rawX)
|
|
225
|
-
const y = toNumberValue(rawY)
|
|
226
|
-
|
|
227
|
-
if (x === undefined || y === undefined) {
|
|
228
|
-
throw new Error(
|
|
229
|
-
"pad primitive gr_circle center expects two numeric arguments",
|
|
230
|
-
)
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
return new PadPrimitiveGrCircleCenter(x, y)
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
SxClass.register(PadPrimitiveGrCircleCenter)
|
|
237
|
-
|
|
238
|
-
class PadPrimitiveGrCircleEnd extends PadPrimitiveGrCirclePoint {
|
|
239
|
-
static override token = "end"
|
|
240
|
-
static override parentToken = "gr_circle"
|
|
241
|
-
override token = "end"
|
|
242
|
-
|
|
243
|
-
constructor(x: number, y: number) {
|
|
244
|
-
super(x, y)
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
static override fromSexprPrimitives(
|
|
248
|
-
primitiveSexprs: PrimitiveSExpr[],
|
|
249
|
-
): PadPrimitiveGrCircleEnd {
|
|
250
|
-
const [rawX, rawY] = primitiveSexprs
|
|
251
|
-
const x = toNumberValue(rawX)
|
|
252
|
-
const y = toNumberValue(rawY)
|
|
253
|
-
|
|
254
|
-
if (x === undefined || y === undefined) {
|
|
255
|
-
throw new Error(
|
|
256
|
-
"pad primitive gr_circle end expects two numeric arguments",
|
|
257
|
-
)
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
return new PadPrimitiveGrCircleEnd(x, y)
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
SxClass.register(PadPrimitiveGrCircleEnd)
|
|
264
|
-
|
|
265
|
-
class PadPrimitiveGrCircleFill extends SxPrimitiveBoolean {
|
|
266
|
-
static override token = "fill"
|
|
267
|
-
static override parentToken = "gr_circle"
|
|
268
|
-
override token = "fill"
|
|
269
|
-
|
|
270
|
-
constructor(value?: boolean) {
|
|
271
|
-
super(value ?? false)
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
static override fromSexprPrimitives(
|
|
275
|
-
primitiveSexprs: PrimitiveSExpr[],
|
|
276
|
-
): PadPrimitiveGrCircleFill {
|
|
277
|
-
const [raw] = primitiveSexprs
|
|
278
|
-
if (raw === undefined) {
|
|
279
|
-
return new PadPrimitiveGrCircleFill(false)
|
|
280
|
-
}
|
|
281
|
-
if (typeof raw === "boolean") {
|
|
282
|
-
return new PadPrimitiveGrCircleFill(raw)
|
|
283
|
-
}
|
|
284
|
-
if (typeof raw === "string") {
|
|
285
|
-
const normalized = raw.toLowerCase()
|
|
286
|
-
if (normalized === "yes" || normalized === "true") {
|
|
287
|
-
return new PadPrimitiveGrCircleFill(true)
|
|
288
|
-
}
|
|
289
|
-
if (normalized === "no" || normalized === "false") {
|
|
290
|
-
return new PadPrimitiveGrCircleFill(false)
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
throw new Error(
|
|
294
|
-
`pad primitive gr_circle fill expects yes/no or boolean, received ${JSON.stringify(raw)}`,
|
|
295
|
-
)
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
SxClass.register(PadPrimitiveGrCircleFill)
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { SxClass } from "../base-classes/SxClass"
|
|
2
|
-
import type { PrimitiveSExpr } from "../parseToPrimitiveSExpr"
|
|
3
|
-
import { GrLineEnd } from "./GrLineEnd"
|
|
4
|
-
import { GrLineStart } from "./GrLineStart"
|
|
5
|
-
import { Width } from "./Width"
|
|
6
|
-
|
|
7
|
-
const SUPPORTED_TOKENS = new Set(["start", "end", "width"])
|
|
8
|
-
|
|
9
|
-
export class PadPrimitiveGrLine extends SxClass {
|
|
10
|
-
static override token = "gr_line"
|
|
11
|
-
static override parentToken = "primitives"
|
|
12
|
-
override token = "gr_line"
|
|
13
|
-
|
|
14
|
-
private _sxStart?: GrLineStart
|
|
15
|
-
private _sxEnd?: GrLineEnd
|
|
16
|
-
private _sxWidth?: Width
|
|
17
|
-
|
|
18
|
-
static override fromSexprPrimitives(
|
|
19
|
-
primitiveSexprs: PrimitiveSExpr[],
|
|
20
|
-
): PadPrimitiveGrLine {
|
|
21
|
-
const line = new PadPrimitiveGrLine()
|
|
22
|
-
|
|
23
|
-
const { propertyMap, arrayPropertyMap } =
|
|
24
|
-
SxClass.parsePrimitivesToClassProperties(primitiveSexprs, this.token)
|
|
25
|
-
|
|
26
|
-
for (const token of Object.keys(propertyMap)) {
|
|
27
|
-
if (!SUPPORTED_TOKENS.has(token)) {
|
|
28
|
-
throw new Error(
|
|
29
|
-
`pad primitive gr_line encountered unsupported child token "${token}"`,
|
|
30
|
-
)
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
for (const [token, entries] of Object.entries(arrayPropertyMap)) {
|
|
35
|
-
if (!SUPPORTED_TOKENS.has(token)) {
|
|
36
|
-
throw new Error(
|
|
37
|
-
`pad primitive gr_line encountered unsupported child token "${token}"`,
|
|
38
|
-
)
|
|
39
|
-
}
|
|
40
|
-
if (entries.length > 1) {
|
|
41
|
-
throw new Error(
|
|
42
|
-
`pad primitive gr_line does not support repeated "${token}" tokens`,
|
|
43
|
-
)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
line._sxStart = propertyMap.start as GrLineStart | undefined
|
|
48
|
-
line._sxEnd = propertyMap.end as GrLineEnd | undefined
|
|
49
|
-
line._sxWidth = propertyMap.width as Width | undefined
|
|
50
|
-
|
|
51
|
-
if (!line._sxStart) {
|
|
52
|
-
throw new Error("pad primitive gr_line requires a start child token")
|
|
53
|
-
}
|
|
54
|
-
if (!line._sxEnd) {
|
|
55
|
-
throw new Error("pad primitive gr_line requires an end child token")
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return line
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
get start(): GrLineStart | undefined {
|
|
62
|
-
return this._sxStart
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
set start(value: GrLineStart | { x: number; y: number } | undefined) {
|
|
66
|
-
if (value === undefined) {
|
|
67
|
-
this._sxStart = undefined
|
|
68
|
-
return
|
|
69
|
-
}
|
|
70
|
-
if (value instanceof GrLineStart) {
|
|
71
|
-
this._sxStart = value
|
|
72
|
-
return
|
|
73
|
-
}
|
|
74
|
-
this._sxStart = new GrLineStart(value.x, value.y)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
get end(): GrLineEnd | undefined {
|
|
78
|
-
return this._sxEnd
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
set end(value: GrLineEnd | { x: number; y: number } | undefined) {
|
|
82
|
-
if (value === undefined) {
|
|
83
|
-
this._sxEnd = undefined
|
|
84
|
-
return
|
|
85
|
-
}
|
|
86
|
-
if (value instanceof GrLineEnd) {
|
|
87
|
-
this._sxEnd = value
|
|
88
|
-
return
|
|
89
|
-
}
|
|
90
|
-
this._sxEnd = new GrLineEnd(value.x, value.y)
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
get width(): number | undefined {
|
|
94
|
-
return this._sxWidth?.value
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
set width(value: Width | number | undefined) {
|
|
98
|
-
if (value === undefined) {
|
|
99
|
-
this._sxWidth = undefined
|
|
100
|
-
return
|
|
101
|
-
}
|
|
102
|
-
this._sxWidth = value instanceof Width ? value : new Width(value)
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
get widthClass(): Width | undefined {
|
|
106
|
-
return this._sxWidth
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
override getChildren(): SxClass[] {
|
|
110
|
-
const children: SxClass[] = []
|
|
111
|
-
if (this._sxStart) children.push(this._sxStart)
|
|
112
|
-
if (this._sxEnd) children.push(this._sxEnd)
|
|
113
|
-
if (this._sxWidth) children.push(this._sxWidth)
|
|
114
|
-
return children
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
override getString(): string {
|
|
118
|
-
const lines = ["(gr_line"]
|
|
119
|
-
if (this._sxStart) lines.push(this._sxStart.getStringIndented())
|
|
120
|
-
if (this._sxEnd) lines.push(this._sxEnd.getStringIndented())
|
|
121
|
-
if (this._sxWidth) lines.push(this._sxWidth.getStringIndented())
|
|
122
|
-
lines.push(")")
|
|
123
|
-
return lines.join("\n")
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
SxClass.register(PadPrimitiveGrLine)
|
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
import { SxClass } from "../base-classes/SxClass"
|
|
2
|
-
import { SxPrimitiveBoolean } from "../base-classes/SxPrimitiveBoolean"
|
|
3
|
-
import type { PrimitiveSExpr } from "../parseToPrimitiveSExpr"
|
|
4
|
-
import { Pts } from "./Pts"
|
|
5
|
-
import { Width } from "./Width"
|
|
6
|
-
import { PadPrimitiveGrLine } from "./PadPrimitiveGrLine"
|
|
7
|
-
import { PadPrimitiveGrArc } from "./PadPrimitiveGrArc"
|
|
8
|
-
import { PadPrimitiveGrCircle } from "./PadPrimitiveGrCircle"
|
|
9
|
-
|
|
10
|
-
type PadPrimitiveGraphic =
|
|
11
|
-
| PadPrimitiveGrPoly
|
|
12
|
-
| PadPrimitiveGrLine
|
|
13
|
-
| PadPrimitiveGrArc
|
|
14
|
-
| PadPrimitiveGrCircle
|
|
15
|
-
|
|
16
|
-
export class PadPrimitives extends SxClass {
|
|
17
|
-
static override token = "primitives"
|
|
18
|
-
static override parentToken = "pad"
|
|
19
|
-
override token = "primitives"
|
|
20
|
-
|
|
21
|
-
private _graphics: PadPrimitiveGraphic[] = []
|
|
22
|
-
private _sxWidth?: Width
|
|
23
|
-
private _sxFill?: PadPrimitivesFill
|
|
24
|
-
|
|
25
|
-
static override fromSexprPrimitives(
|
|
26
|
-
primitiveSexprs: PrimitiveSExpr[],
|
|
27
|
-
): PadPrimitives {
|
|
28
|
-
const primitives = new PadPrimitives()
|
|
29
|
-
|
|
30
|
-
for (const primitive of primitiveSexprs) {
|
|
31
|
-
if (!Array.isArray(primitive) || primitive.length === 0) {
|
|
32
|
-
throw new Error(
|
|
33
|
-
`pad primitives encountered invalid child expression: ${JSON.stringify(primitive)}`,
|
|
34
|
-
)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const parsed = SxClass.parsePrimitiveSexpr(primitive, {
|
|
38
|
-
parentToken: this.token,
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
if (!(parsed instanceof SxClass)) {
|
|
42
|
-
throw new Error(
|
|
43
|
-
`pad primitives child did not resolve to an SxClass: ${JSON.stringify(primitive)}`,
|
|
44
|
-
)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (parsed instanceof Width) {
|
|
48
|
-
if (primitives._sxWidth) {
|
|
49
|
-
throw new Error("pad primitives encountered duplicate width tokens")
|
|
50
|
-
}
|
|
51
|
-
primitives._sxWidth = parsed
|
|
52
|
-
continue
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (parsed instanceof PadPrimitivesFill) {
|
|
56
|
-
if (primitives._sxFill) {
|
|
57
|
-
throw new Error("pad primitives encountered duplicate fill tokens")
|
|
58
|
-
}
|
|
59
|
-
primitives._sxFill = parsed
|
|
60
|
-
continue
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (parsed instanceof PadPrimitiveGrPoly) {
|
|
64
|
-
primitives._graphics.push(parsed)
|
|
65
|
-
continue
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (parsed instanceof PadPrimitiveGrLine) {
|
|
69
|
-
primitives._graphics.push(parsed)
|
|
70
|
-
continue
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (parsed instanceof PadPrimitiveGrArc) {
|
|
74
|
-
primitives._graphics.push(parsed)
|
|
75
|
-
continue
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (parsed instanceof PadPrimitiveGrCircle) {
|
|
79
|
-
primitives._graphics.push(parsed)
|
|
80
|
-
continue
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
throw new Error(
|
|
84
|
-
`pad primitives encountered unsupported token "${parsed.token}"`,
|
|
85
|
-
)
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return primitives
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
get graphics(): PadPrimitiveGraphic[] {
|
|
92
|
-
return [...this._graphics]
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
set graphics(value: PadPrimitiveGraphic[]) {
|
|
96
|
-
this._graphics = [...value]
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
addGraphic(graphic: PadPrimitiveGraphic) {
|
|
100
|
-
this._graphics.push(graphic)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
get width(): number | undefined {
|
|
104
|
-
return this._sxWidth?.value
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
set width(value: number | undefined) {
|
|
108
|
-
this._sxWidth = value === undefined ? undefined : new Width(value)
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
get fill(): boolean | undefined {
|
|
112
|
-
return this._sxFill?.value
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
set fill(value: boolean | undefined) {
|
|
116
|
-
this._sxFill =
|
|
117
|
-
value === undefined ? undefined : new PadPrimitivesFill({ value })
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
override getChildren(): SxClass[] {
|
|
121
|
-
const children: SxClass[] = []
|
|
122
|
-
children.push(...this._graphics)
|
|
123
|
-
if (this._sxWidth) children.push(this._sxWidth)
|
|
124
|
-
if (this._sxFill) children.push(this._sxFill)
|
|
125
|
-
return children
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
SxClass.register(PadPrimitives)
|
|
129
|
-
|
|
130
|
-
class PadPrimitivesFill extends SxPrimitiveBoolean {
|
|
131
|
-
static override token = "fill"
|
|
132
|
-
static override parentToken = "primitives"
|
|
133
|
-
override token = "fill"
|
|
134
|
-
|
|
135
|
-
constructor(options: { value?: boolean } = {}) {
|
|
136
|
-
super(options.value ?? false)
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
static override fromSexprPrimitives(
|
|
140
|
-
primitiveSexprs: PrimitiveSExpr[],
|
|
141
|
-
): PadPrimitivesFill {
|
|
142
|
-
const [raw] = primitiveSexprs
|
|
143
|
-
const normalized = typeof raw === "string" ? raw.toLowerCase() : raw
|
|
144
|
-
if (normalized === undefined) {
|
|
145
|
-
return new PadPrimitivesFill({ value: false })
|
|
146
|
-
}
|
|
147
|
-
if (normalized === "yes") {
|
|
148
|
-
return new PadPrimitivesFill({ value: true })
|
|
149
|
-
}
|
|
150
|
-
if (normalized === "no") {
|
|
151
|
-
return new PadPrimitivesFill({ value: false })
|
|
152
|
-
}
|
|
153
|
-
if (typeof normalized === "boolean") {
|
|
154
|
-
return new PadPrimitivesFill({ value: normalized })
|
|
155
|
-
}
|
|
156
|
-
throw new Error(
|
|
157
|
-
`pad primitives fill expects yes/no or boolean, received ${JSON.stringify(raw)}`,
|
|
158
|
-
)
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
SxClass.register(PadPrimitivesFill)
|
|
162
|
-
|
|
163
|
-
export class PadPrimitiveGrPoly extends SxClass {
|
|
164
|
-
static override token = "gr_poly"
|
|
165
|
-
static override parentToken = "primitives"
|
|
166
|
-
override token = "gr_poly"
|
|
167
|
-
|
|
168
|
-
private _contours: Pts[] = []
|
|
169
|
-
private _sxWidth?: Width
|
|
170
|
-
private _sxFill?: PadPrimitiveFill
|
|
171
|
-
|
|
172
|
-
static override fromSexprPrimitives(
|
|
173
|
-
primitiveSexprs: PrimitiveSExpr[],
|
|
174
|
-
): PadPrimitiveGrPoly {
|
|
175
|
-
const polygon = new PadPrimitiveGrPoly()
|
|
176
|
-
|
|
177
|
-
for (const primitive of primitiveSexprs) {
|
|
178
|
-
if (!Array.isArray(primitive) || primitive.length === 0) {
|
|
179
|
-
throw new Error(
|
|
180
|
-
`gr_poly primitive encountered invalid child: ${JSON.stringify(primitive)}`,
|
|
181
|
-
)
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
const parsed = SxClass.parsePrimitiveSexpr(primitive, {
|
|
185
|
-
parentToken: this.token,
|
|
186
|
-
})
|
|
187
|
-
|
|
188
|
-
if (!(parsed instanceof SxClass)) {
|
|
189
|
-
throw new Error(
|
|
190
|
-
`gr_poly primitive child did not resolve to an SxClass: ${JSON.stringify(primitive)}`,
|
|
191
|
-
)
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
if (parsed instanceof Pts) {
|
|
195
|
-
polygon._contours.push(parsed)
|
|
196
|
-
continue
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
if (parsed instanceof Width) {
|
|
200
|
-
if (polygon._sxWidth) {
|
|
201
|
-
throw new Error("gr_poly encountered duplicate width tokens")
|
|
202
|
-
}
|
|
203
|
-
polygon._sxWidth = parsed
|
|
204
|
-
continue
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
if (parsed instanceof PadPrimitiveFill) {
|
|
208
|
-
if (polygon._sxFill) {
|
|
209
|
-
throw new Error("gr_poly encountered duplicate fill tokens")
|
|
210
|
-
}
|
|
211
|
-
polygon._sxFill = parsed
|
|
212
|
-
continue
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
throw new Error(`gr_poly encountered unsupported token "${parsed.token}"`)
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
if (polygon._contours.length === 0) {
|
|
219
|
-
throw new Error("gr_poly requires at least one pts child")
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
return polygon
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
get contours(): Pts[] {
|
|
226
|
-
return [...this._contours]
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
set contours(value: Pts[]) {
|
|
230
|
-
this._contours = [...value]
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
get width(): number | undefined {
|
|
234
|
-
return this._sxWidth?.value
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
set width(value: number | undefined) {
|
|
238
|
-
this._sxWidth = value === undefined ? undefined : new Width(value)
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
get filled(): boolean | undefined {
|
|
242
|
-
return this._sxFill?.value
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
set filled(value: boolean | undefined) {
|
|
246
|
-
this._sxFill =
|
|
247
|
-
value === undefined ? undefined : new PadPrimitiveFill({ value })
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
override getChildren(): SxClass[] {
|
|
251
|
-
const children: SxClass[] = []
|
|
252
|
-
children.push(...this._contours)
|
|
253
|
-
if (this._sxWidth) children.push(this._sxWidth)
|
|
254
|
-
if (this._sxFill) children.push(this._sxFill)
|
|
255
|
-
return children
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
SxClass.register(PadPrimitiveGrPoly)
|
|
259
|
-
|
|
260
|
-
class PadPrimitiveFill extends SxPrimitiveBoolean {
|
|
261
|
-
static override token = "fill"
|
|
262
|
-
static override parentToken = "gr_poly"
|
|
263
|
-
override token = "fill"
|
|
264
|
-
|
|
265
|
-
constructor(options: { value?: boolean } = {}) {
|
|
266
|
-
super(options.value ?? false)
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
static override fromSexprPrimitives(
|
|
270
|
-
primitiveSexprs: PrimitiveSExpr[],
|
|
271
|
-
): PadPrimitiveFill {
|
|
272
|
-
const [raw] = primitiveSexprs
|
|
273
|
-
if (raw === undefined) {
|
|
274
|
-
return new PadPrimitiveFill({ value: false })
|
|
275
|
-
}
|
|
276
|
-
if (typeof raw === "boolean") {
|
|
277
|
-
return new PadPrimitiveFill({ value: raw })
|
|
278
|
-
}
|
|
279
|
-
if (typeof raw === "string") {
|
|
280
|
-
return new PadPrimitiveFill({ value: raw.toLowerCase() === "yes" })
|
|
281
|
-
}
|
|
282
|
-
throw new Error(
|
|
283
|
-
`gr_poly fill expects yes/no or boolean, received ${JSON.stringify(raw)}`,
|
|
284
|
-
)
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
override getString(): string {
|
|
288
|
-
return `(fill ${this.value ? "yes" : "no"})`
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
SxClass.register(PadPrimitiveFill)
|