@bitbybit-dev/base 1.6.1 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/GlobalCDNProvider.js +1 -1
- package/lib/api/inputs/base-inputs.d.ts +36 -7
- package/lib/api/inputs/base-inputs.js +10 -0
- package/lib/api/inputs/color-inputs.d.ts +54 -1
- package/lib/api/inputs/color-inputs.js +73 -1
- package/lib/api/inputs/frame-inputs.d.ts +2 -1
- package/lib/api/inputs/frame-inputs.js +2 -1
- package/lib/api/inputs/io-inputs.d.ts +527 -59
- package/lib/api/inputs/io-inputs.js +432 -40
- package/lib/api/inputs/line-inputs.d.ts +17 -0
- package/lib/api/inputs/line-inputs.js +15 -0
- package/lib/api/inputs/math-inputs.d.ts +62 -0
- package/lib/api/inputs/math-inputs.js +82 -0
- package/lib/api/inputs/mesh-inputs.d.ts +16 -0
- package/lib/api/inputs/mesh-inputs.js +14 -0
- package/lib/api/inputs/transforms-inputs.d.ts +76 -0
- package/lib/api/inputs/transforms-inputs.js +85 -0
- package/lib/api/kernel-calls/index.d.ts +1 -0
- package/lib/api/kernel-calls/index.js +1 -0
- package/lib/api/kernel-calls/settings.d.ts +82 -0
- package/lib/api/kernel-calls/settings.js +123 -0
- package/lib/api/recipes/surface-mesh.d.ts +2 -1
- package/lib/api/recipes/surface-mesh.js +5 -3
- package/lib/api/resolved-inputs/index.d.ts +32 -2
- package/lib/api/services/base-bitbybit.d.ts +12 -0
- package/lib/api/services/base-bitbybit.js +19 -3
- package/lib/api/services/color.d.ts +36 -2
- package/lib/api/services/color.js +60 -11
- package/lib/api/services/helpers/color/color-forms.constants.d.ts +10 -0
- package/lib/api/services/helpers/color/color-forms.constants.js +10 -0
- package/lib/api/services/helpers/color/color-forms.d.ts +3 -0
- package/lib/api/services/helpers/color/color-forms.js +27 -0
- package/lib/api/services/helpers/color/css-colors.constants.d.ts +9 -0
- package/lib/api/services/helpers/color/css-colors.constants.js +158 -0
- package/lib/api/services/helpers/color/css-colors.d.ts +1 -0
- package/lib/api/services/helpers/color/css-colors.js +61 -0
- package/lib/api/services/helpers/curves/bezier-pieces.constants.d.ts +5 -0
- package/lib/api/services/helpers/curves/bezier-pieces.constants.js +5 -0
- package/lib/api/services/helpers/curves/bezier-pieces.d.ts +24 -0
- package/lib/api/services/helpers/curves/bezier-pieces.js +149 -0
- package/lib/api/services/helpers/curves/conic-arcs.constants.d.ts +5 -0
- package/lib/api/services/helpers/curves/conic-arcs.constants.js +5 -0
- package/lib/api/services/helpers/curves/conic-arcs.d.ts +24 -0
- package/lib/api/services/helpers/curves/conic-arcs.js +85 -0
- package/lib/api/services/helpers/curves/nurbs-forms.d.ts +20 -0
- package/lib/api/services/helpers/curves/nurbs-forms.js +112 -0
- package/lib/api/services/helpers/curves/nurbs.d.ts +4 -0
- package/lib/api/services/helpers/curves/nurbs.js +10 -9
- package/lib/api/services/helpers/files/drawing/drawing-budget.d.ts +3 -0
- package/lib/api/services/helpers/files/drawing/drawing-budget.js +24 -0
- package/lib/api/services/helpers/files/drawing/drawing-geometry.d.ts +18 -0
- package/lib/api/services/helpers/files/drawing/drawing-geometry.js +84 -0
- package/lib/api/services/helpers/files/drawing/drawing-model.d.ts +5 -0
- package/lib/api/services/helpers/files/drawing/drawing-model.js +252 -0
- package/lib/api/services/helpers/files/drawing/drawing-types.d.ts +60 -0
- package/lib/api/services/helpers/files/drawing/drawing-types.js +1 -0
- package/lib/api/services/helpers/files/drawing/drawing.constants.d.ts +28 -0
- package/lib/api/services/helpers/files/drawing/drawing.constants.js +29 -0
- package/lib/api/services/helpers/files/dxf/dxf-colors.d.ts +5 -0
- package/lib/api/services/helpers/files/dxf/dxf-colors.js +45 -0
- package/lib/api/services/helpers/files/dxf/dxf-entities.d.ts +17 -0
- package/lib/api/services/helpers/files/dxf/dxf-entities.js +193 -0
- package/lib/api/services/helpers/files/dxf/dxf-file-text.d.ts +1 -0
- package/lib/api/services/helpers/files/dxf/dxf-file-text.js +50 -0
- package/lib/api/services/helpers/files/dxf/dxf-generator.d.ts +2 -36
- package/lib/api/services/helpers/files/dxf/dxf-generator.js +81 -523
- package/lib/api/services/helpers/files/dxf/dxf-reader-dtos.d.ts +6 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-dtos.js +81 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-geometry.d.ts +21 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-geometry.js +67 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-types.d.ts +69 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-types.js +1 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader.constants.d.ts +71 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader.constants.js +78 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader.d.ts +2 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader.js +556 -0
- package/lib/api/services/helpers/files/dxf/dxf-tables.d.ts +27 -0
- package/lib/api/services/helpers/files/dxf/dxf-tables.js +247 -0
- package/lib/api/services/helpers/files/dxf/dxf-text.d.ts +26 -0
- package/lib/api/services/helpers/files/dxf/dxf-text.js +97 -0
- package/lib/api/services/helpers/files/dxf/dxf-tokens.d.ts +9 -0
- package/lib/api/services/helpers/files/dxf/dxf-tokens.js +65 -0
- package/lib/api/services/helpers/files/dxf/dxf.constants.d.ts +32 -1
- package/lib/api/services/helpers/files/dxf/dxf.constants.js +34 -1
- package/lib/api/services/helpers/files/file-bytes.d.ts +1 -0
- package/lib/api/services/helpers/files/file-bytes.js +15 -0
- package/lib/api/services/helpers/files/ground-axes.d.ts +2 -0
- package/lib/api/services/helpers/files/ground-axes.js +4 -0
- package/lib/api/services/helpers/files/mesh-file-axes.d.ts +7 -0
- package/lib/api/services/helpers/files/mesh-file-axes.js +17 -0
- package/lib/api/services/helpers/files/stl-axes.d.ts +4 -0
- package/lib/api/services/helpers/files/stl-axes.js +22 -0
- package/lib/api/services/helpers/files/stl-types.d.ts +7 -0
- package/lib/api/services/helpers/files/stl-types.js +1 -0
- package/lib/api/services/helpers/files/stl.constants.d.ts +11 -0
- package/lib/api/services/helpers/files/stl.constants.js +11 -0
- package/lib/api/services/helpers/files/stl.d.ts +3 -0
- package/lib/api/services/helpers/files/stl.js +93 -0
- package/lib/api/services/helpers/files/svg/svg-css.d.ts +48 -0
- package/lib/api/services/helpers/files/svg/svg-css.js +444 -0
- package/lib/api/services/helpers/files/svg/svg-dash-patterns.d.ts +2 -0
- package/lib/api/services/helpers/files/svg/svg-dash-patterns.js +35 -0
- package/lib/api/services/helpers/files/svg/svg-document.d.ts +26 -0
- package/lib/api/services/helpers/files/svg/svg-document.js +89 -0
- package/lib/api/services/helpers/files/svg/svg-memo.d.ts +1 -0
- package/lib/api/services/helpers/files/svg/svg-memo.js +8 -0
- package/lib/api/services/helpers/files/svg/svg-normalizer.d.ts +6 -0
- package/lib/api/services/helpers/files/svg/svg-normalizer.js +433 -0
- package/lib/api/services/helpers/files/svg/svg-numbers.d.ts +15 -0
- package/lib/api/services/helpers/files/svg/svg-numbers.js +61 -0
- package/lib/api/services/helpers/files/svg/svg-path-data.constants.d.ts +8 -0
- package/lib/api/services/helpers/files/svg/svg-path-data.constants.js +10 -0
- package/lib/api/services/helpers/files/svg/svg-path-data.d.ts +9 -0
- package/lib/api/services/helpers/files/svg/svg-path-data.js +203 -0
- package/lib/api/services/helpers/files/svg/svg-path-types.d.ts +33 -0
- package/lib/api/services/helpers/files/svg/svg-path-types.js +1 -0
- package/lib/api/services/helpers/files/svg/svg-reader.constants.d.ts +35 -0
- package/lib/api/services/helpers/files/svg/svg-reader.constants.js +35 -0
- package/lib/api/services/helpers/files/svg/svg-reading.constants.d.ts +9 -0
- package/lib/api/services/helpers/files/svg/svg-reading.constants.js +9 -0
- package/lib/api/services/helpers/files/svg/svg-reading.d.ts +6 -0
- package/lib/api/services/helpers/files/svg/svg-reading.js +233 -0
- package/lib/api/services/helpers/files/svg/svg-scene-types.d.ts +54 -0
- package/lib/api/services/helpers/files/svg/svg-scene-types.js +1 -0
- package/lib/api/services/helpers/files/svg/svg-shapes.d.ts +6 -0
- package/lib/api/services/helpers/files/svg/svg-shapes.js +102 -0
- package/lib/api/services/helpers/files/svg/svg-strokes.d.ts +38 -0
- package/lib/api/services/helpers/files/svg/svg-strokes.js +108 -0
- package/lib/api/services/helpers/files/svg/svg-style.d.ts +26 -0
- package/lib/api/services/helpers/files/svg/svg-style.js +211 -0
- package/lib/api/services/helpers/files/svg/svg-transform.d.ts +10 -0
- package/lib/api/services/helpers/files/svg/svg-transform.js +76 -0
- package/lib/api/services/helpers/files/svg/svg-writer.d.ts +16 -0
- package/lib/api/services/helpers/files/svg/svg-writer.js +153 -0
- package/lib/api/services/helpers/files/svg/svg-xml.d.ts +11 -0
- package/lib/api/services/helpers/files/svg/svg-xml.js +322 -0
- package/lib/api/services/helpers/files/svg/svg.constants.d.ts +13 -0
- package/lib/api/services/helpers/files/svg/svg.constants.js +13 -0
- package/lib/api/services/helpers/files/work-budget.d.ts +11 -0
- package/lib/api/services/helpers/files/work-budget.js +26 -0
- package/lib/api/services/helpers/geometry/affine2.d.ts +8 -0
- package/lib/api/services/helpers/geometry/affine2.js +18 -0
- package/lib/api/services/helpers/geometry/ellipse-arcs.d.ts +14 -0
- package/lib/api/services/helpers/geometry/ellipse-arcs.js +96 -0
- package/lib/api/services/helpers/geometry/frame-axes.d.ts +3 -1
- package/lib/api/services/helpers/geometry/polygon-nesting.constants.d.ts +6 -0
- package/lib/api/services/helpers/geometry/polygon-nesting.constants.js +6 -0
- package/lib/api/services/helpers/geometry/polygon-nesting.d.ts +31 -0
- package/lib/api/services/helpers/geometry/polygon-nesting.js +251 -0
- package/lib/api/services/helpers/geometry/quaternions.constants.d.ts +3 -0
- package/lib/api/services/helpers/geometry/quaternions.constants.js +3 -0
- package/lib/api/services/helpers/geometry/quaternions.d.ts +14 -0
- package/lib/api/services/helpers/geometry/quaternions.js +71 -0
- package/lib/api/services/helpers/geometry/scalars.constants.d.ts +1 -0
- package/lib/api/services/helpers/geometry/scalars.constants.js +1 -0
- package/lib/api/services/helpers/geometry/scalars.d.ts +3 -0
- package/lib/api/services/helpers/geometry/scalars.js +29 -1
- package/lib/api/services/helpers/geometry/vectors.d.ts +1 -0
- package/lib/api/services/helpers/geometry/vectors.js +6 -0
- package/lib/api/services/helpers/mesh/mesh-proximity.constants.d.ts +1 -0
- package/lib/api/services/helpers/mesh/mesh-proximity.constants.js +1 -0
- package/lib/api/services/helpers/mesh/mesh-proximity.d.ts +1 -0
- package/lib/api/services/helpers/mesh/mesh-proximity.js +40 -40
- package/lib/api/services/io/drawing.d.ts +170 -0
- package/lib/api/services/io/drawing.js +212 -0
- package/lib/api/services/io/dxf.d.ts +134 -0
- package/lib/api/services/io/dxf.js +167 -0
- package/lib/api/services/io/index.d.ts +4 -0
- package/lib/api/services/io/index.js +4 -0
- package/lib/api/services/io/io.d.ts +14 -0
- package/lib/api/services/io/io.js +15 -0
- package/lib/api/services/io/svg.d.ts +64 -0
- package/lib/api/services/io/svg.js +102 -0
- package/lib/api/services/line.d.ts +17 -0
- package/lib/api/services/line.js +20 -1
- package/lib/api/services/math.d.ts +35 -0
- package/lib/api/services/math.js +56 -1
- package/lib/api/services/mesh.d.ts +17 -0
- package/lib/api/services/mesh.js +27 -1
- package/lib/api/services/point.d.ts +4 -1
- package/lib/api/services/point.js +9 -4
- package/lib/api/services/recipes.d.ts +3 -0
- package/lib/api/services/recipes.js +4 -1
- package/lib/api/services/text.d.ts +4 -1
- package/lib/api/services/text.js +8 -3
- package/lib/api/services/transforms.d.ts +119 -1
- package/lib/api/services/transforms.js +158 -30
- package/package.json +1 -1
- package/lib/api/services/helpers/files/dxf/dxf.d.ts +0 -87
- package/lib/api/services/helpers/files/dxf/dxf.js +0 -111
- package/lib/api/services/io.d.ts +0 -9
- package/lib/api/services/io.js +0 -10
|
@@ -6,8 +6,10 @@ import * as Inputs from "../inputs";
|
|
|
6
6
|
*/
|
|
7
7
|
export declare namespace Color {
|
|
8
8
|
type ChannelDto = WithDefaults<Inputs.Color.ChannelDto, "channel">;
|
|
9
|
+
type HexAlphaDto = WithDefaults<Inputs.Color.HexAlphaDto, "color" | "alpha">;
|
|
9
10
|
type HexDto = WithDefaults<Inputs.Color.HexDto, "color">;
|
|
10
11
|
type HexDtoMapped = WithDefaults<Inputs.Color.HexDtoMapped, "color" | "from" | "to">;
|
|
12
|
+
type HslDto = WithDefaults<Inputs.Color.HslDto, "hue" | "saturation" | "lightness">;
|
|
11
13
|
type InvertHexDto = WithDefaults<Inputs.Color.InvertHexDto, "color" | "blackAndWhite">;
|
|
12
14
|
type Rgb1Dto = WithDefaults<Inputs.Color.Rgb1Dto, "colorRgb">;
|
|
13
15
|
type Rgb255Dto = WithDefaults<Inputs.Color.Rgb255Dto, "colorRgb">;
|
|
@@ -128,14 +130,33 @@ export declare namespace Frame {
|
|
|
128
130
|
* the way `resolveDto` hands a DTO to the code that reads it.
|
|
129
131
|
*/
|
|
130
132
|
export declare namespace IO {
|
|
133
|
+
type DrawingArcSegmentDto = Inputs.IO.DrawingArcSegmentDto;
|
|
134
|
+
type DrawingCircleSegmentDto = Inputs.IO.DrawingCircleSegmentDto;
|
|
135
|
+
type DrawingEllipseSegmentDto = WithDefaults<Inputs.IO.DrawingEllipseSegmentDto, "startParameter" | "endParameter">;
|
|
136
|
+
type DrawingLineSegmentDto = Inputs.IO.DrawingLineSegmentDto;
|
|
137
|
+
type DrawingPartDto = WithDefaults<Inputs.IO.DrawingPartDto, "layer" | "color" | "lineType">;
|
|
138
|
+
type DrawingPathDto = Inputs.IO.DrawingPathDto;
|
|
139
|
+
type DrawingPolylineSegmentDto = WithDefaults<Inputs.IO.DrawingPolylineSegmentDto, "closed">;
|
|
140
|
+
type DrawingSplineSegmentDto = WithDefaults<Inputs.IO.DrawingSplineSegmentDto, "degree" | "closed">;
|
|
131
141
|
type DxfArcSegmentDto = Inputs.IO.DxfArcSegmentDto;
|
|
132
142
|
type DxfCircleSegmentDto = Inputs.IO.DxfCircleSegmentDto;
|
|
143
|
+
type DxfDrawingDto = Inputs.IO.DxfDrawingDto;
|
|
144
|
+
type DxfEllipseSegmentDto = WithDefaults<Inputs.IO.DxfEllipseSegmentDto, "startParameter" | "endParameter">;
|
|
133
145
|
type DxfLineSegmentDto = Inputs.IO.DxfLineSegmentDto;
|
|
134
|
-
type DxfModelDto = WithDefaults<Inputs.IO.DxfModelDto, "colorFormat" | "acadVersion">;
|
|
146
|
+
type DxfModelDto = WithDefaults<Inputs.IO.DxfModelDto, "colorFormat" | "acadVersion" | "curveTolerance">;
|
|
135
147
|
type DxfPathDto = Inputs.IO.DxfPathDto;
|
|
136
|
-
type DxfPathsPartDto = WithDefaults<Inputs.IO.DxfPathsPartDto, "layer" | "color">;
|
|
148
|
+
type DxfPathsPartDto = WithDefaults<Inputs.IO.DxfPathsPartDto, "layer" | "color" | "lineType">;
|
|
137
149
|
type DxfPolylineSegmentDto = WithDefaults<Inputs.IO.DxfPolylineSegmentDto, "closed">;
|
|
150
|
+
type DxfReadDto = WithDefaults<Inputs.IO.DxfReadDto, "includeHiddenLayers">;
|
|
138
151
|
type DxfSplineSegmentDto = WithDefaults<Inputs.IO.DxfSplineSegmentDto, "degree" | "closed">;
|
|
152
|
+
type DxfToSvgDto = WithDefaults<Inputs.IO.DxfToSvgDto, "includeHiddenLayers" | "tolerance">;
|
|
153
|
+
type DxfToSvgResultDto = Inputs.IO.DxfToSvgResultDto;
|
|
154
|
+
type SvgDrawingDto = Inputs.IO.SvgDrawingDto;
|
|
155
|
+
type SvgModelDto = WithDefaults<Inputs.IO.SvgModelDto, "tolerance">;
|
|
156
|
+
type SvgPathDataDto = WithDefaults<Inputs.IO.SvgPathDataDto, "flipY" | "tolerance">;
|
|
157
|
+
type SvgReadDto = WithDefaults<Inputs.IO.SvgReadDto, "includeInvisible">;
|
|
158
|
+
type SvgToDxfDto = WithDefaults<Inputs.IO.SvgToDxfDto, "includeInvisible" | "colorFormat" | "acadVersion" | "curveTolerance">;
|
|
159
|
+
type SvgToDxfResultDto = Inputs.IO.SvgToDxfResultDto;
|
|
139
160
|
}
|
|
140
161
|
/**
|
|
141
162
|
* The Line inputs DTOs as their defaults leave them: every property with a default is present,
|
|
@@ -146,6 +167,7 @@ export declare namespace Line {
|
|
|
146
167
|
type DrawLinesDto<T> = WithDefaults<Inputs.Line.DrawLinesDto<T>, "opacity" | "colours" | "size" | "updatable">;
|
|
147
168
|
type LineDto = Inputs.Line.LineDto;
|
|
148
169
|
type LineLineIntersectionDto = WithDefaults<Inputs.Line.LineLineIntersectionDto, "checkSegmentsOnly" | "tolerance">;
|
|
170
|
+
type LinePointDistanceDto = Inputs.Line.LinePointDistanceDto;
|
|
149
171
|
type LinePointsDto = Inputs.Line.LinePointsDto;
|
|
150
172
|
type LinesDto = Inputs.Line.LinesDto;
|
|
151
173
|
type LineStartEndPointsDto = Inputs.Line.LineStartEndPointsDto;
|
|
@@ -221,12 +243,14 @@ export declare namespace Math {
|
|
|
221
243
|
type LerpDto = WithDefaults<Inputs.Math.LerpDto, "start" | "end" | "t">;
|
|
222
244
|
type ModulusDto = WithDefaults<Inputs.Math.ModulusDto, "number" | "modulus">;
|
|
223
245
|
type MoveTowardsDto = WithDefaults<Inputs.Math.MoveTowardsDto, "current" | "target" | "maxDelta">;
|
|
246
|
+
type NiceStepDto = WithDefaults<Inputs.Math.NiceStepDto, "number" | "direction">;
|
|
224
247
|
type NumberDto = WithDefaults<Inputs.Math.NumberDto, "number">;
|
|
225
248
|
type PingPongDto = WithDefaults<Inputs.Math.PingPongDto, "t" | "length">;
|
|
226
249
|
type RandomNumberDto = WithDefaults<Inputs.Math.RandomNumberDto, "low" | "high">;
|
|
227
250
|
type RandomNumbersDto = WithDefaults<Inputs.Math.RandomNumbersDto, "low" | "high" | "count">;
|
|
228
251
|
type RemapNumberDto = WithDefaults<Inputs.Math.RemapNumberDto, "number" | "fromLow" | "fromHigh" | "toLow" | "toHigh">;
|
|
229
252
|
type RoundToDecimalsDto = WithDefaults<Inputs.Math.RoundToDecimalsDto, "number" | "decimalPlaces">;
|
|
253
|
+
type ShortestAngleDto = WithDefaults<Inputs.Math.ShortestAngleDto, "from" | "to" | "fullTurn">;
|
|
230
254
|
type ToFixedDto = WithDefaults<Inputs.Math.ToFixedDto, "decimalPlaces">;
|
|
231
255
|
type TwoNumbersDto = WithDefaults<Inputs.Math.TwoNumbersDto, "first" | "second">;
|
|
232
256
|
type UnitOfLengthDto = WithDefaults<Inputs.Math.UnitOfLengthDto, "unit">;
|
|
@@ -246,6 +270,7 @@ export declare namespace Mesh {
|
|
|
246
270
|
type MeshMeshToleranceDto = WithDefaults<Inputs.Mesh.MeshMeshToleranceDto, "tolerance">;
|
|
247
271
|
type MeshPointDto = Inputs.Mesh.MeshPointDto;
|
|
248
272
|
type MeshToIndexedDto = WithDefaults<Inputs.Mesh.MeshToIndexedDto, "tolerance">;
|
|
273
|
+
type PointTriangleDto = Inputs.Mesh.PointTriangleDto;
|
|
249
274
|
type PolygonWithHolesDto = Inputs.Mesh.PolygonWithHolesDto;
|
|
250
275
|
type SignedDistanceFromPlaneToPointDto = Inputs.Mesh.SignedDistanceFromPlaneToPointDto;
|
|
251
276
|
type TriangleDto = Inputs.Mesh.TriangleDto;
|
|
@@ -347,6 +372,10 @@ export declare namespace Text {
|
|
|
347
372
|
* the way `resolveDto` hands a DTO to the code that reads it.
|
|
348
373
|
*/
|
|
349
374
|
export declare namespace Transforms {
|
|
375
|
+
type AxisAngleDto = WithDefaults<Inputs.Transforms.AxisAngleDto, "axis" | "angle">;
|
|
376
|
+
type EulerAnglesDto = WithDefaults<Inputs.Transforms.EulerAnglesDto, "angles">;
|
|
377
|
+
type QuaternionDto = Inputs.Transforms.QuaternionDto;
|
|
378
|
+
type QuaternionVectorDto = Inputs.Transforms.QuaternionVectorDto;
|
|
350
379
|
type RotationCenterAxisDto = WithDefaults<Inputs.Transforms.RotationCenterAxisDto, "angle" | "axis" | "center">;
|
|
351
380
|
type RotationCenterDto = WithDefaults<Inputs.Transforms.RotationCenterDto, "angle" | "center">;
|
|
352
381
|
type RotationCenterYawPitchRollDto = WithDefaults<Inputs.Transforms.RotationCenterYawPitchRollDto, "yaw" | "pitch" | "roll" | "center">;
|
|
@@ -357,6 +386,7 @@ export declare namespace Transforms {
|
|
|
357
386
|
type TransformationToleranceDto = WithDefaults<Inputs.Transforms.TransformationToleranceDto, "tolerance">;
|
|
358
387
|
type TranslationsXYZDto = Inputs.Transforms.TranslationsXYZDto;
|
|
359
388
|
type TranslationXYZDto = WithDefaults<Inputs.Transforms.TranslationXYZDto, "translation">;
|
|
389
|
+
type TwoQuaternionsDto = Inputs.Transforms.TwoQuaternionsDto;
|
|
360
390
|
type UniformScaleDto = WithDefaults<Inputs.Transforms.UniformScaleDto, "scale">;
|
|
361
391
|
type UniformScaleFromCenterDto = WithDefaults<Inputs.Transforms.UniformScaleFromCenterDto, "scale" | "center">;
|
|
362
392
|
}
|
|
@@ -3,6 +3,7 @@ import { Dates } from "./dates";
|
|
|
3
3
|
import { Engineering } from "./engineering";
|
|
4
4
|
import { Frame } from "./frame";
|
|
5
5
|
import { GeometryHelper } from "./geometry-helper";
|
|
6
|
+
import type { BitbybitSettings } from "../kernel-calls/settings";
|
|
6
7
|
import { IoBitByBit } from "./io";
|
|
7
8
|
import { Line } from "./line";
|
|
8
9
|
import { Lists } from "./lists";
|
|
@@ -38,5 +39,16 @@ export declare class BaseBitByBit {
|
|
|
38
39
|
readonly dates: Dates;
|
|
39
40
|
readonly engineering: Engineering;
|
|
40
41
|
readonly recipes: Recipes;
|
|
42
|
+
private checked;
|
|
43
|
+
/**
|
|
44
|
+
* The settings this instance works by, such as the coordinate system its numbers are in, set by
|
|
45
|
+
* whoever owns this object: the renderer for its scene, a worker when it is told them, a
|
|
46
|
+
* program in Node for itself. A setting left out keeps the behaviour from before it existed.
|
|
47
|
+
* Settings are checked as they are set: a name that is no setting, or a value its setting does
|
|
48
|
+
* not take, is refused as an `InputError` and the earlier settings stay. The settings read back
|
|
49
|
+
* are frozen, so they change only by assigning new ones.
|
|
50
|
+
*/
|
|
51
|
+
get settings(): BitbybitSettings;
|
|
52
|
+
set settings(settings: BitbybitSettings);
|
|
41
53
|
constructor();
|
|
42
54
|
}
|
|
@@ -3,6 +3,7 @@ import { Dates } from "./dates";
|
|
|
3
3
|
import { Engineering } from "./engineering";
|
|
4
4
|
import { Frame } from "./frame";
|
|
5
5
|
import { GeometryHelper } from "./geometry-helper";
|
|
6
|
+
import { checkedSettings } from "../kernel-calls/settings";
|
|
6
7
|
import { IoBitByBit } from "./io";
|
|
7
8
|
import { Line } from "./line";
|
|
8
9
|
import { Lists } from "./lists";
|
|
@@ -21,23 +22,38 @@ import { Vector } from "./vector";
|
|
|
21
22
|
* calls the same maths a user does.
|
|
22
23
|
*/
|
|
23
24
|
export class BaseBitByBit {
|
|
25
|
+
/**
|
|
26
|
+
* The settings this instance works by, such as the coordinate system its numbers are in, set by
|
|
27
|
+
* whoever owns this object: the renderer for its scene, a worker when it is told them, a
|
|
28
|
+
* program in Node for itself. A setting left out keeps the behaviour from before it existed.
|
|
29
|
+
* Settings are checked as they are set: a name that is no setting, or a value its setting does
|
|
30
|
+
* not take, is refused as an `InputError` and the earlier settings stay. The settings read back
|
|
31
|
+
* are frozen, so they change only by assigning new ones.
|
|
32
|
+
*/
|
|
33
|
+
get settings() {
|
|
34
|
+
return this.checked;
|
|
35
|
+
}
|
|
36
|
+
set settings(settings) {
|
|
37
|
+
this.checked = Object.freeze(checkedSettings(settings));
|
|
38
|
+
}
|
|
24
39
|
constructor() {
|
|
40
|
+
this.checked = Object.freeze({});
|
|
25
41
|
this.geometryHelper = new GeometryHelper();
|
|
26
42
|
this.math = new MathBitByBit();
|
|
27
43
|
this.vector = new Vector(this.math, this.geometryHelper);
|
|
28
44
|
this.transforms = new Transforms(this.vector, this.math);
|
|
29
45
|
this.lists = new Lists();
|
|
30
|
-
this.point = new Point(this.geometryHelper, this.transforms, this.vector, this.lists);
|
|
46
|
+
this.point = new Point(this.geometryHelper, this.transforms, this.vector, this.lists, () => this.settings);
|
|
31
47
|
this.line = new Line(this.vector, this.point, this.geometryHelper);
|
|
32
48
|
this.polyline = new Polyline(this.vector, this.point, this.line, this.geometryHelper);
|
|
33
49
|
this.mesh = new MeshBitByBit(this.vector, this.polyline);
|
|
34
|
-
this.textService = new TextBitByBit(this.point);
|
|
50
|
+
this.textService = new TextBitByBit(this.point, () => this.settings);
|
|
35
51
|
this.io = new IoBitByBit();
|
|
36
52
|
this.frame = new Frame(this.vector, this.math, this.geometryHelper);
|
|
37
53
|
this.color = new Color(this.math);
|
|
38
54
|
this.logic = new Logic();
|
|
39
55
|
this.dates = new Dates();
|
|
40
56
|
this.engineering = new Engineering();
|
|
41
|
-
this.recipes = new Recipes();
|
|
57
|
+
this.recipes = new Recipes(() => this.settings);
|
|
42
58
|
}
|
|
43
59
|
}
|
|
@@ -101,8 +101,9 @@ export declare class Color {
|
|
|
101
101
|
/**
|
|
102
102
|
* Reads a hex color into an `{ r, g, b }` object with channels from 0 to 255.
|
|
103
103
|
*
|
|
104
|
-
* The text
|
|
105
|
-
*
|
|
104
|
+
* The text holds six hex digits or three, each standing for a pair, with or without `#`;
|
|
105
|
+
* anything else throws an error.
|
|
106
|
+
* Example: '#FF5733' -> { r: 255, g: 87, b: 51 }, '#f53' -> { r: 255, g: 85, b: 51 }
|
|
106
107
|
* @param inputs - The hex color
|
|
107
108
|
* @returns The color object with channels from 0 to 255
|
|
108
109
|
* @group convert
|
|
@@ -114,6 +115,39 @@ export declare class Color {
|
|
|
114
115
|
* ```
|
|
115
116
|
*/
|
|
116
117
|
hexToRgb(inputs: Inputs.Color.HexDto): Inputs.Base.ColorRGB;
|
|
118
|
+
/**
|
|
119
|
+
* Writes a hex color with an opacity as a CSS `rgba()` color, for a style that needs to see
|
|
120
|
+
* through.
|
|
121
|
+
*
|
|
122
|
+
* Example: '#ff5733' with alpha 0.5 -> 'rgba(255, 87, 51, 0.5)'
|
|
123
|
+
* @param inputs - The hex color and its opacity
|
|
124
|
+
* @returns The CSS color text
|
|
125
|
+
* @group convert
|
|
126
|
+
* @shortname hex to rgba
|
|
127
|
+
* @drawable false
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* const fill = bitbybit.color.hexToRgba({ color: "#ff5733", alpha: 0.5 });
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
hexToRgba(inputs: Inputs.Color.HexAlphaDto): string;
|
|
134
|
+
/**
|
|
135
|
+
* Writes a color given by hue, saturation and lightness as a hex color: a way to pick colors
|
|
136
|
+
* that differ by hue alone, such as a palette spread round the wheel.
|
|
137
|
+
*
|
|
138
|
+
* The hue wraps round; saturation and lightness are held between 0 and 1.
|
|
139
|
+
* Example: hue 0, saturation 1, lightness 0.5 -> '#ff0000'; hue 210, 0.6, 0.5 -> '#3380cc'
|
|
140
|
+
* @param inputs - The hue in degrees, the saturation and the lightness
|
|
141
|
+
* @returns The hex color
|
|
142
|
+
* @group convert
|
|
143
|
+
* @shortname hsl to hex
|
|
144
|
+
* @drawable false
|
|
145
|
+
* @example
|
|
146
|
+
* ```typescript
|
|
147
|
+
* const blue = bitbybit.color.hslToHex({ hue: 210, saturation: 0.6, lightness: 0.5 });
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
hslToHex(inputs: Inputs.Color.HslDto): Inputs.Base.Color;
|
|
117
151
|
/**
|
|
118
152
|
* Writes three channel values as a hex color.
|
|
119
153
|
*
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as Inputs from "../inputs";
|
|
2
2
|
import { resolveDto } from "../kernel-calls";
|
|
3
3
|
import { linearToSrgb, srgbToLinear } from "./helpers/color/color-space";
|
|
4
|
-
|
|
4
|
+
import { hexChannels, hexOfChannels, hslChannels } from "./helpers/color/color-forms";
|
|
5
|
+
import { InputError } from "../kernel-calls/errors";
|
|
5
6
|
/**
|
|
6
7
|
* Colors in the two forms the library uses: a hex text such as `#ff5733`, and an object `{ r, g, b
|
|
7
8
|
* }` or `{ r, g, b, a }` whose channels run either from 0 to 255 or from 0 to 1. The methods here
|
|
@@ -125,8 +126,9 @@ export class Color {
|
|
|
125
126
|
/**
|
|
126
127
|
* Reads a hex color into an `{ r, g, b }` object with channels from 0 to 255.
|
|
127
128
|
*
|
|
128
|
-
* The text
|
|
129
|
-
*
|
|
129
|
+
* The text holds six hex digits or three, each standing for a pair, with or without `#`;
|
|
130
|
+
* anything else throws an error.
|
|
131
|
+
* Example: '#FF5733' -> { r: 255, g: 87, b: 51 }, '#f53' -> { r: 255, g: 85, b: 51 }
|
|
130
132
|
* @param inputs - The hex color
|
|
131
133
|
* @returns The color object with channels from 0 to 255
|
|
132
134
|
* @group convert
|
|
@@ -139,15 +141,62 @@ export class Color {
|
|
|
139
141
|
*/
|
|
140
142
|
hexToRgb(inputs) {
|
|
141
143
|
const resolved = resolveDto(Inputs.Color.HexDto, inputs);
|
|
142
|
-
const
|
|
143
|
-
if (!
|
|
144
|
+
const channels = hexChannels(resolved.color);
|
|
145
|
+
if (!channels) {
|
|
144
146
|
throw new Error(`Invalid hex color: ${resolved.color}`);
|
|
145
147
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
148
|
+
const [r, g, b] = channels;
|
|
149
|
+
return { r, g, b };
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Writes a hex color with an opacity as a CSS `rgba()` color, for a style that needs to see
|
|
153
|
+
* through.
|
|
154
|
+
*
|
|
155
|
+
* Example: '#ff5733' with alpha 0.5 -> 'rgba(255, 87, 51, 0.5)'
|
|
156
|
+
* @param inputs - The hex color and its opacity
|
|
157
|
+
* @returns The CSS color text
|
|
158
|
+
* @group convert
|
|
159
|
+
* @shortname hex to rgba
|
|
160
|
+
* @drawable false
|
|
161
|
+
* @example
|
|
162
|
+
* ```typescript
|
|
163
|
+
* const fill = bitbybit.color.hexToRgba({ color: "#ff5733", alpha: 0.5 });
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
hexToRgba(inputs) {
|
|
167
|
+
const resolved = resolveDto(Inputs.Color.HexAlphaDto, inputs);
|
|
168
|
+
if (!Number.isFinite(resolved.alpha)) {
|
|
169
|
+
throw new InputError(`\`alpha\` is ${String(resolved.alpha)}, not a finite number.`, "alpha");
|
|
170
|
+
}
|
|
171
|
+
const { r, g, b } = this.hexToRgb({ color: resolved.color });
|
|
172
|
+
const alpha = this.math.clamp({ number: resolved.alpha, min: 0, max: 1 });
|
|
173
|
+
return `rgba(${String(r)}, ${String(g)}, ${String(b)}, ${String(alpha)})`;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Writes a color given by hue, saturation and lightness as a hex color: a way to pick colors
|
|
177
|
+
* that differ by hue alone, such as a palette spread round the wheel.
|
|
178
|
+
*
|
|
179
|
+
* The hue wraps round; saturation and lightness are held between 0 and 1.
|
|
180
|
+
* Example: hue 0, saturation 1, lightness 0.5 -> '#ff0000'; hue 210, 0.6, 0.5 -> '#3380cc'
|
|
181
|
+
* @param inputs - The hue in degrees, the saturation and the lightness
|
|
182
|
+
* @returns The hex color
|
|
183
|
+
* @group convert
|
|
184
|
+
* @shortname hsl to hex
|
|
185
|
+
* @drawable false
|
|
186
|
+
* @example
|
|
187
|
+
* ```typescript
|
|
188
|
+
* const blue = bitbybit.color.hslToHex({ hue: 210, saturation: 0.6, lightness: 0.5 });
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
hslToHex(inputs) {
|
|
192
|
+
const resolved = resolveDto(Inputs.Color.HslDto, inputs);
|
|
193
|
+
const notFinite = ["hue", "saturation", "lightness"].find(name => !Number.isFinite(resolved[name]));
|
|
194
|
+
if (notFinite !== undefined) {
|
|
195
|
+
throw new InputError(`\`${notFinite}\` is ${String(resolved[notFinite])}, not a finite number.`, notFinite);
|
|
196
|
+
}
|
|
197
|
+
const held = (value) => this.math.clamp({ number: value, min: 0, max: 1 });
|
|
198
|
+
const [r, g, b] = hslChannels(resolved.hue, held(resolved.saturation), held(resolved.lightness));
|
|
199
|
+
return this.rgbToHex({ r, g, b, min: 0, max: 1 });
|
|
151
200
|
}
|
|
152
201
|
/**
|
|
153
202
|
* Writes three channel values as a hex color.
|
|
@@ -171,7 +220,7 @@ export class Color {
|
|
|
171
220
|
const scaled = resolved.min === 0 && resolved.max === 255 ? channel : this.math.remap({ number: channel, fromLow: resolved.min, fromHigh: resolved.max, toLow: 0, toHigh: 255 });
|
|
172
221
|
return Math.min(255, Math.max(0, Math.round(scaled)));
|
|
173
222
|
};
|
|
174
|
-
return
|
|
223
|
+
return hexOfChannels([byteOf(resolved.r), byteOf(resolved.g), byteOf(resolved.b)]);
|
|
175
224
|
}
|
|
176
225
|
/**
|
|
177
226
|
* Writes an `{ r, g, b }` color as a hex color.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const HUE_DEGREES_PER_STEP = 30;
|
|
2
|
+
export declare const HUE_STEPS = 12;
|
|
3
|
+
export declare const HUE_RISE_START = 3;
|
|
4
|
+
export declare const HUE_FALL_START = 9;
|
|
5
|
+
export declare const RED_OFFSET = 0;
|
|
6
|
+
export declare const GREEN_OFFSET = 8;
|
|
7
|
+
export declare const BLUE_OFFSET = 4;
|
|
8
|
+
export declare const HEX_LEAD = 16777216;
|
|
9
|
+
export declare const RED_PLACE = 65536;
|
|
10
|
+
export declare const GREEN_PLACE = 256;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const HUE_DEGREES_PER_STEP = 30;
|
|
2
|
+
export const HUE_STEPS = 12;
|
|
3
|
+
export const HUE_RISE_START = 3;
|
|
4
|
+
export const HUE_FALL_START = 9;
|
|
5
|
+
export const RED_OFFSET = 0;
|
|
6
|
+
export const GREEN_OFFSET = 8;
|
|
7
|
+
export const BLUE_OFFSET = 4;
|
|
8
|
+
export const HEX_LEAD = 0x1000000;
|
|
9
|
+
export const RED_PLACE = 0x10000;
|
|
10
|
+
export const GREEN_PLACE = 0x100;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function hexChannels(text: string): [number, number, number] | undefined;
|
|
2
|
+
export declare function hexOfChannels(channels: readonly [number, number, number]): string;
|
|
3
|
+
export declare function hslChannels(hue: number, saturation: number, lightness: number): [number, number, number];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BLUE_OFFSET, GREEN_OFFSET, GREEN_PLACE, HEX_LEAD, HUE_DEGREES_PER_STEP, HUE_FALL_START, HUE_RISE_START, HUE_STEPS, RED_OFFSET, RED_PLACE } from "./color-forms.constants";
|
|
2
|
+
const HEX_RADIX = 16;
|
|
3
|
+
const LONG_HEX = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i;
|
|
4
|
+
const SHORT_HEX = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
|
|
5
|
+
export function hexChannels(text) {
|
|
6
|
+
const long = LONG_HEX.exec(text);
|
|
7
|
+
if (long) {
|
|
8
|
+
return [parseInt(long[1], HEX_RADIX), parseInt(long[2], HEX_RADIX), parseInt(long[3], HEX_RADIX)];
|
|
9
|
+
}
|
|
10
|
+
const short = SHORT_HEX.exec(text);
|
|
11
|
+
if (!short) {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
const doubled = (digit) => parseInt(digit + digit, HEX_RADIX);
|
|
15
|
+
return [doubled(short[1]), doubled(short[2]), doubled(short[3])];
|
|
16
|
+
}
|
|
17
|
+
export function hexOfChannels(channels) {
|
|
18
|
+
return `#${(HEX_LEAD + channels[0] * RED_PLACE + channels[1] * GREEN_PLACE + channels[2]).toString(HEX_RADIX).substring(1)}`;
|
|
19
|
+
}
|
|
20
|
+
export function hslChannels(hue, saturation, lightness) {
|
|
21
|
+
const reach = saturation * Math.min(lightness, 1 - lightness);
|
|
22
|
+
const channel = (offset) => {
|
|
23
|
+
const step = ((offset + hue / HUE_DEGREES_PER_STEP) % HUE_STEPS + HUE_STEPS) % HUE_STEPS;
|
|
24
|
+
return lightness - reach * Math.max(-1, Math.min(step - HUE_RISE_START, HUE_FALL_START - step, 1));
|
|
25
|
+
};
|
|
26
|
+
return [channel(RED_OFFSET), channel(GREEN_OFFSET), channel(BLUE_OFFSET)];
|
|
27
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const CHANNEL_MAX = 255;
|
|
2
|
+
export declare const PERCENT = 100;
|
|
3
|
+
export declare const RGB_CHANNELS = 3;
|
|
4
|
+
export declare const RGB_WITH_ALPHA = 4;
|
|
5
|
+
export declare const SHORT_HEX_DIGITS = 3;
|
|
6
|
+
export declare const SHORT_HEX_WITH_ALPHA_DIGITS = 4;
|
|
7
|
+
export declare const LONG_HEX_DIGITS = 6;
|
|
8
|
+
export declare const LONG_HEX_WITH_ALPHA_DIGITS = 8;
|
|
9
|
+
export declare const CSS_NAMED_COLORS: ReadonlyMap<string, string>;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
export const CHANNEL_MAX = 255;
|
|
2
|
+
export const PERCENT = 100;
|
|
3
|
+
export const RGB_CHANNELS = 3;
|
|
4
|
+
export const RGB_WITH_ALPHA = 4;
|
|
5
|
+
export const SHORT_HEX_DIGITS = 3;
|
|
6
|
+
export const SHORT_HEX_WITH_ALPHA_DIGITS = 4;
|
|
7
|
+
export const LONG_HEX_DIGITS = 6;
|
|
8
|
+
export const LONG_HEX_WITH_ALPHA_DIGITS = 8;
|
|
9
|
+
export const CSS_NAMED_COLORS = new Map([
|
|
10
|
+
["aliceblue", "#f0f8ff"],
|
|
11
|
+
["antiquewhite", "#faebd7"],
|
|
12
|
+
["aqua", "#00ffff"],
|
|
13
|
+
["aquamarine", "#7fffd4"],
|
|
14
|
+
["azure", "#f0ffff"],
|
|
15
|
+
["beige", "#f5f5dc"],
|
|
16
|
+
["bisque", "#ffe4c4"],
|
|
17
|
+
["black", "#000000"],
|
|
18
|
+
["blanchedalmond", "#ffebcd"],
|
|
19
|
+
["blue", "#0000ff"],
|
|
20
|
+
["blueviolet", "#8a2be2"],
|
|
21
|
+
["brown", "#a52a2a"],
|
|
22
|
+
["burlywood", "#deb887"],
|
|
23
|
+
["cadetblue", "#5f9ea0"],
|
|
24
|
+
["chartreuse", "#7fff00"],
|
|
25
|
+
["chocolate", "#d2691e"],
|
|
26
|
+
["coral", "#ff7f50"],
|
|
27
|
+
["cornflowerblue", "#6495ed"],
|
|
28
|
+
["cornsilk", "#fff8dc"],
|
|
29
|
+
["crimson", "#dc143c"],
|
|
30
|
+
["cyan", "#00ffff"],
|
|
31
|
+
["darkblue", "#00008b"],
|
|
32
|
+
["darkcyan", "#008b8b"],
|
|
33
|
+
["darkgoldenrod", "#b8860b"],
|
|
34
|
+
["darkgray", "#a9a9a9"],
|
|
35
|
+
["darkgreen", "#006400"],
|
|
36
|
+
["darkgrey", "#a9a9a9"],
|
|
37
|
+
["darkkhaki", "#bdb76b"],
|
|
38
|
+
["darkmagenta", "#8b008b"],
|
|
39
|
+
["darkolivegreen", "#556b2f"],
|
|
40
|
+
["darkorange", "#ff8c00"],
|
|
41
|
+
["darkorchid", "#9932cc"],
|
|
42
|
+
["darkred", "#8b0000"],
|
|
43
|
+
["darksalmon", "#e9967a"],
|
|
44
|
+
["darkseagreen", "#8fbc8f"],
|
|
45
|
+
["darkslateblue", "#483d8b"],
|
|
46
|
+
["darkslategray", "#2f4f4f"],
|
|
47
|
+
["darkslategrey", "#2f4f4f"],
|
|
48
|
+
["darkturquoise", "#00ced1"],
|
|
49
|
+
["darkviolet", "#9400d3"],
|
|
50
|
+
["deeppink", "#ff1493"],
|
|
51
|
+
["deepskyblue", "#00bfff"],
|
|
52
|
+
["dimgray", "#696969"],
|
|
53
|
+
["dimgrey", "#696969"],
|
|
54
|
+
["dodgerblue", "#1e90ff"],
|
|
55
|
+
["firebrick", "#b22222"],
|
|
56
|
+
["floralwhite", "#fffaf0"],
|
|
57
|
+
["forestgreen", "#228b22"],
|
|
58
|
+
["fuchsia", "#ff00ff"],
|
|
59
|
+
["gainsboro", "#dcdcdc"],
|
|
60
|
+
["ghostwhite", "#f8f8ff"],
|
|
61
|
+
["gold", "#ffd700"],
|
|
62
|
+
["goldenrod", "#daa520"],
|
|
63
|
+
["gray", "#808080"],
|
|
64
|
+
["green", "#008000"],
|
|
65
|
+
["greenyellow", "#adff2f"],
|
|
66
|
+
["grey", "#808080"],
|
|
67
|
+
["honeydew", "#f0fff0"],
|
|
68
|
+
["hotpink", "#ff69b4"],
|
|
69
|
+
["indianred", "#cd5c5c"],
|
|
70
|
+
["indigo", "#4b0082"],
|
|
71
|
+
["ivory", "#fffff0"],
|
|
72
|
+
["khaki", "#f0e68c"],
|
|
73
|
+
["lavender", "#e6e6fa"],
|
|
74
|
+
["lavenderblush", "#fff0f5"],
|
|
75
|
+
["lawngreen", "#7cfc00"],
|
|
76
|
+
["lemonchiffon", "#fffacd"],
|
|
77
|
+
["lightblue", "#add8e6"],
|
|
78
|
+
["lightcoral", "#f08080"],
|
|
79
|
+
["lightcyan", "#e0ffff"],
|
|
80
|
+
["lightgoldenrodyellow", "#fafad2"],
|
|
81
|
+
["lightgray", "#d3d3d3"],
|
|
82
|
+
["lightgreen", "#90ee90"],
|
|
83
|
+
["lightgrey", "#d3d3d3"],
|
|
84
|
+
["lightpink", "#ffb6c1"],
|
|
85
|
+
["lightsalmon", "#ffa07a"],
|
|
86
|
+
["lightseagreen", "#20b2aa"],
|
|
87
|
+
["lightskyblue", "#87cefa"],
|
|
88
|
+
["lightslategray", "#778899"],
|
|
89
|
+
["lightslategrey", "#778899"],
|
|
90
|
+
["lightsteelblue", "#b0c4de"],
|
|
91
|
+
["lightyellow", "#ffffe0"],
|
|
92
|
+
["lime", "#00ff00"],
|
|
93
|
+
["limegreen", "#32cd32"],
|
|
94
|
+
["linen", "#faf0e6"],
|
|
95
|
+
["magenta", "#ff00ff"],
|
|
96
|
+
["maroon", "#800000"],
|
|
97
|
+
["mediumaquamarine", "#66cdaa"],
|
|
98
|
+
["mediumblue", "#0000cd"],
|
|
99
|
+
["mediumorchid", "#ba55d3"],
|
|
100
|
+
["mediumpurple", "#9370db"],
|
|
101
|
+
["mediumseagreen", "#3cb371"],
|
|
102
|
+
["mediumslateblue", "#7b68ee"],
|
|
103
|
+
["mediumspringgreen", "#00fa9a"],
|
|
104
|
+
["mediumturquoise", "#48d1cc"],
|
|
105
|
+
["mediumvioletred", "#c71585"],
|
|
106
|
+
["midnightblue", "#191970"],
|
|
107
|
+
["mintcream", "#f5fffa"],
|
|
108
|
+
["mistyrose", "#ffe4e1"],
|
|
109
|
+
["moccasin", "#ffe4b5"],
|
|
110
|
+
["navajowhite", "#ffdead"],
|
|
111
|
+
["navy", "#000080"],
|
|
112
|
+
["oldlace", "#fdf5e6"],
|
|
113
|
+
["olive", "#808000"],
|
|
114
|
+
["olivedrab", "#6b8e23"],
|
|
115
|
+
["orange", "#ffa500"],
|
|
116
|
+
["orangered", "#ff4500"],
|
|
117
|
+
["orchid", "#da70d6"],
|
|
118
|
+
["palegoldenrod", "#eee8aa"],
|
|
119
|
+
["palegreen", "#98fb98"],
|
|
120
|
+
["paleturquoise", "#afeeee"],
|
|
121
|
+
["palevioletred", "#db7093"],
|
|
122
|
+
["papayawhip", "#ffefd5"],
|
|
123
|
+
["peachpuff", "#ffdab9"],
|
|
124
|
+
["peru", "#cd853f"],
|
|
125
|
+
["pink", "#ffc0cb"],
|
|
126
|
+
["plum", "#dda0dd"],
|
|
127
|
+
["powderblue", "#b0e0e6"],
|
|
128
|
+
["purple", "#800080"],
|
|
129
|
+
["rebeccapurple", "#663399"],
|
|
130
|
+
["red", "#ff0000"],
|
|
131
|
+
["rosybrown", "#bc8f8f"],
|
|
132
|
+
["royalblue", "#4169e1"],
|
|
133
|
+
["saddlebrown", "#8b4513"],
|
|
134
|
+
["salmon", "#fa8072"],
|
|
135
|
+
["sandybrown", "#f4a460"],
|
|
136
|
+
["seagreen", "#2e8b57"],
|
|
137
|
+
["seashell", "#fff5ee"],
|
|
138
|
+
["sienna", "#a0522d"],
|
|
139
|
+
["silver", "#c0c0c0"],
|
|
140
|
+
["skyblue", "#87ceeb"],
|
|
141
|
+
["slateblue", "#6a5acd"],
|
|
142
|
+
["slategray", "#708090"],
|
|
143
|
+
["slategrey", "#708090"],
|
|
144
|
+
["snow", "#fffafa"],
|
|
145
|
+
["springgreen", "#00ff7f"],
|
|
146
|
+
["steelblue", "#4682b4"],
|
|
147
|
+
["tan", "#d2b48c"],
|
|
148
|
+
["teal", "#008080"],
|
|
149
|
+
["thistle", "#d8bfd8"],
|
|
150
|
+
["tomato", "#ff6347"],
|
|
151
|
+
["turquoise", "#40e0d0"],
|
|
152
|
+
["violet", "#ee82ee"],
|
|
153
|
+
["wheat", "#f5deb3"],
|
|
154
|
+
["white", "#ffffff"],
|
|
155
|
+
["whitesmoke", "#f5f5f5"],
|
|
156
|
+
["yellow", "#ffff00"],
|
|
157
|
+
["yellowgreen", "#9acd32"],
|
|
158
|
+
]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function cssColorHex(text: string): string | undefined;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { hexChannels, hexOfChannels } from "./color-forms";
|
|
2
|
+
import { CHANNEL_MAX, CSS_NAMED_COLORS, LONG_HEX_DIGITS, LONG_HEX_WITH_ALPHA_DIGITS, PERCENT, RGB_CHANNELS, RGB_WITH_ALPHA, SHORT_HEX_DIGITS, SHORT_HEX_WITH_ALPHA_DIGITS, } from "./css-colors.constants";
|
|
3
|
+
const HEX_COLOR = /^#([a-f\d]+)$/i;
|
|
4
|
+
const RGB_FUNCTION = /^rgba?\(([^()]*)\)$/i;
|
|
5
|
+
const CSS_NUMBER = /^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?)(%?)$/i;
|
|
6
|
+
const SPACES = /\s+/;
|
|
7
|
+
const DIGITS_WITHOUT_ALPHA = new Map([
|
|
8
|
+
[SHORT_HEX_DIGITS, SHORT_HEX_DIGITS],
|
|
9
|
+
[SHORT_HEX_WITH_ALPHA_DIGITS, SHORT_HEX_DIGITS],
|
|
10
|
+
[LONG_HEX_DIGITS, LONG_HEX_DIGITS],
|
|
11
|
+
[LONG_HEX_WITH_ALPHA_DIGITS, LONG_HEX_DIGITS],
|
|
12
|
+
]);
|
|
13
|
+
const hexOfDigits = (digits) => {
|
|
14
|
+
const kept = DIGITS_WITHOUT_ALPHA.get(digits.length);
|
|
15
|
+
const channels = kept === undefined ? undefined : hexChannels(digits.slice(0, kept));
|
|
16
|
+
return channels === undefined ? undefined : hexOfChannels(channels);
|
|
17
|
+
};
|
|
18
|
+
const cssNumberOf = (text) => {
|
|
19
|
+
const match = CSS_NUMBER.exec(text.trim());
|
|
20
|
+
if (!match) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
const value = parseFloat(match[1]);
|
|
24
|
+
return Number.isFinite(value) ? { value, percent: match[2] === "%" } : undefined;
|
|
25
|
+
};
|
|
26
|
+
const channelOf = (number) => {
|
|
27
|
+
const scaled = number.percent ? number.value / PERCENT * CHANNEL_MAX : number.value;
|
|
28
|
+
return Math.min(CHANNEL_MAX, Math.max(0, Math.round(scaled)));
|
|
29
|
+
};
|
|
30
|
+
const rgbArguments = (text) => {
|
|
31
|
+
if (text.includes(",")) {
|
|
32
|
+
const parts = text.split(",");
|
|
33
|
+
return parts.length === RGB_CHANNELS || parts.length === RGB_WITH_ALPHA ? parts : undefined;
|
|
34
|
+
}
|
|
35
|
+
const [channels, alpha, ...rest] = text.split("/");
|
|
36
|
+
const values = channels.trim().split(SPACES);
|
|
37
|
+
if (rest.length > 0 || values.length !== RGB_CHANNELS) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
return alpha === undefined ? values : values.concat(alpha);
|
|
41
|
+
};
|
|
42
|
+
const rgbHex = (text) => {
|
|
43
|
+
var _a;
|
|
44
|
+
const numbers = ((_a = rgbArguments(text)) !== null && _a !== void 0 ? _a : []).map(cssNumberOf);
|
|
45
|
+
if (numbers.length === 0 || numbers.some(number => number === undefined)) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
return hexOfChannels([channelOf(numbers[0]), channelOf(numbers[1]), channelOf(numbers[2])]);
|
|
49
|
+
};
|
|
50
|
+
export function cssColorHex(text) {
|
|
51
|
+
const trimmed = text.trim();
|
|
52
|
+
const hex = HEX_COLOR.exec(trimmed);
|
|
53
|
+
if (hex) {
|
|
54
|
+
return hexOfDigits(hex[1]);
|
|
55
|
+
}
|
|
56
|
+
const rgb = RGB_FUNCTION.exec(trimmed);
|
|
57
|
+
if (rgb) {
|
|
58
|
+
return rgbHex(rgb[1]);
|
|
59
|
+
}
|
|
60
|
+
return CSS_NAMED_COLORS.get(trimmed.toLowerCase());
|
|
61
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type * as Inputs from "../../../inputs";
|
|
2
|
+
import type { BezierPiece } from "./nurbs-forms";
|
|
3
|
+
import type { WorkBudget } from "../files/work-budget";
|
|
4
|
+
type Point3 = Inputs.Base.Point3;
|
|
5
|
+
export interface CubicPiece {
|
|
6
|
+
readonly start: Point3;
|
|
7
|
+
readonly control1: Point3;
|
|
8
|
+
readonly control2: Point3;
|
|
9
|
+
readonly end: Point3;
|
|
10
|
+
}
|
|
11
|
+
export interface PointAndTangent {
|
|
12
|
+
readonly point: Point3;
|
|
13
|
+
readonly tangent: Point3;
|
|
14
|
+
}
|
|
15
|
+
export interface PiecesBounds {
|
|
16
|
+
readonly min: Point3;
|
|
17
|
+
readonly max: Point3;
|
|
18
|
+
}
|
|
19
|
+
export declare const bezierPointAndTangent: (piece: BezierPiece, parameter: number) => PointAndTangent;
|
|
20
|
+
export declare const bezierPoint: (piece: BezierPiece, parameter: number) => Point3;
|
|
21
|
+
export declare const cubicsOfPiece: (piece: BezierPiece, tolerance: number, budget?: WorkBudget) => CubicPiece[];
|
|
22
|
+
export declare const samplesOfPiece: (piece: BezierPiece, tolerance: number, budget?: WorkBudget) => Point3[];
|
|
23
|
+
export declare const bezierPiecesBounds: (pieces: readonly BezierPiece[], tolerance: number, budget?: WorkBudget) => PiecesBounds;
|
|
24
|
+
export {};
|