@bitbybit-dev/base 1.3.2 → 1.4.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/README.md +1 -1
- package/lib/api/GlobalCDNProvider.js +1 -1
- package/lib/api/index.d.ts +2 -0
- package/lib/api/index.js +2 -0
- package/lib/api/inputs/base-inputs.d.ts +10 -4
- package/lib/api/inputs/color-inputs.d.ts +24 -23
- package/lib/api/inputs/color-inputs.js +1 -0
- package/lib/api/inputs/dates-inputs.d.ts +16 -16
- package/lib/api/inputs/frame-inputs.d.ts +515 -0
- package/lib/api/inputs/frame-inputs.js +617 -0
- package/lib/api/inputs/index.d.ts +1 -0
- package/lib/api/inputs/index.js +1 -0
- package/lib/api/inputs/io-inputs.d.ts +3 -3
- package/lib/api/inputs/io-inputs.js +1 -1
- package/lib/api/inputs/lists-inputs.d.ts +23 -23
- package/lib/api/inputs/logic-inputs.d.ts +11 -11
- package/lib/api/inputs/math-inputs.d.ts +49 -49
- package/lib/api/inputs/math-inputs.js +4 -4
- package/lib/api/inputs/mesh-inputs.d.ts +3 -3
- package/lib/api/inputs/mesh-inputs.js +3 -3
- package/lib/api/inputs/point-inputs.d.ts +39 -38
- package/lib/api/inputs/point-inputs.js +6 -5
- package/lib/api/inputs/polyline-inputs.d.ts +5 -4
- package/lib/api/inputs/polyline-inputs.js +3 -3
- package/lib/api/inputs/text-inputs.d.ts +34 -33
- package/lib/api/inputs/text-inputs.js +15 -12
- package/lib/api/inputs/transforms-inputs.d.ts +16 -16
- package/lib/api/inputs/vector-inputs.d.ts +26 -25
- package/lib/api/inputs/vector-inputs.js +2 -1
- package/lib/api/kernel-calls/call-by-path.d.ts +12 -0
- package/lib/api/kernel-calls/call-by-path.js +36 -0
- package/lib/api/kernel-calls/constraints.d.ts +53 -0
- package/lib/api/kernel-calls/constraints.js +21 -0
- package/lib/api/kernel-calls/describe-failure.d.ts +32 -0
- package/lib/api/kernel-calls/describe-failure.js +164 -0
- package/lib/api/kernel-calls/errors.d.ts +55 -0
- package/lib/api/kernel-calls/errors.js +42 -0
- package/lib/api/kernel-calls/failure-message.d.ts +18 -0
- package/lib/api/kernel-calls/failure-message.js +36 -0
- package/lib/api/kernel-calls/index.d.ts +10 -0
- package/lib/api/kernel-calls/index.js +10 -0
- package/lib/api/kernel-calls/input-rules.d.ts +67 -0
- package/lib/api/kernel-calls/input-rules.js +135 -0
- package/lib/api/kernel-calls/input-validation.d.ts +130 -0
- package/lib/api/kernel-calls/input-validation.js +221 -0
- package/lib/api/kernel-calls/rehydrate.d.ts +16 -0
- package/lib/api/kernel-calls/rehydrate.js +38 -0
- package/lib/api/kernel-calls/resolve-dto.d.ts +59 -0
- package/lib/api/kernel-calls/resolve-dto.js +61 -0
- package/lib/api/kernel-calls/with-defaults.d.ts +16 -0
- package/lib/api/kernel-calls/with-defaults.js +53 -0
- package/lib/api/resolved-inputs/index.d.ts +304 -0
- package/lib/api/resolved-inputs/index.js +1 -0
- package/lib/api/services/color.js +43 -26
- package/lib/api/services/dates.js +53 -33
- package/lib/api/services/frame.d.ts +670 -0
- package/lib/api/services/frame.js +1040 -0
- package/lib/api/services/helpers/dxf/dxf-generator.d.ts +2 -3
- package/lib/api/services/helpers/dxf/dxf-generator.js +27 -37
- package/lib/api/services/helpers/dxf/dxf.js +10 -4
- package/lib/api/services/helpers/frame-axes.d.ts +36 -0
- package/lib/api/services/helpers/frame-axes.js +57 -0
- package/lib/api/services/helpers/matrices.d.ts +17 -0
- package/lib/api/services/helpers/matrices.js +51 -0
- package/lib/api/services/index.d.ts +1 -0
- package/lib/api/services/index.js +1 -0
- package/lib/api/services/line.js +15 -12
- package/lib/api/services/lists.js +174 -136
- package/lib/api/services/logic.js +44 -34
- package/lib/api/services/math.js +127 -82
- package/lib/api/services/mesh.js +20 -13
- package/lib/api/services/point.js +62 -46
- package/lib/api/services/polyline.js +22 -18
- package/lib/api/services/text.js +81 -46
- package/lib/api/services/transforms.js +38 -25
- package/lib/api/services/vector.js +37 -22
- package/package.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DtoRegistry } from "./resolve-dto";
|
|
2
|
+
/**
|
|
3
|
+
* A kernel used in the same thread, whose operations lay a caller's inputs over the defaults of the
|
|
4
|
+
* DTO each takes - what a worker does for a call that crossed to it. `occt.shapes.solid.createBox({
|
|
5
|
+
* width: 2 })` then builds the box the DTO's other defaults describe, where the kernel on its own
|
|
6
|
+
* would read the missing properties as undefined.
|
|
7
|
+
*
|
|
8
|
+
* Only the objects on the way to a listed operation are wrapped, so everything else on the kernel -
|
|
9
|
+
* its helpers, the engine objects it holds - is reached as it is, and a listed operation runs with
|
|
10
|
+
* the kernel object itself as `this`. The same object is wrapped once, so a path read twice gives
|
|
11
|
+
* the same object both times.
|
|
12
|
+
* @param root - The kernel's root object
|
|
13
|
+
* @param registry - The kernel's operations by dotted path, as its package exports them
|
|
14
|
+
* @returns The kernel, applying the defaults on every listed operation
|
|
15
|
+
*/
|
|
16
|
+
export declare function withDefaults<T extends object>(root: T, registry: DtoRegistry): T;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { isRegisteredOperation, resolveInputs } from "./resolve-dto";
|
|
2
|
+
/**
|
|
3
|
+
* A kernel used in the same thread, whose operations lay a caller's inputs over the defaults of the
|
|
4
|
+
* DTO each takes - what a worker does for a call that crossed to it. `occt.shapes.solid.createBox({
|
|
5
|
+
* width: 2 })` then builds the box the DTO's other defaults describe, where the kernel on its own
|
|
6
|
+
* would read the missing properties as undefined.
|
|
7
|
+
*
|
|
8
|
+
* Only the objects on the way to a listed operation are wrapped, so everything else on the kernel -
|
|
9
|
+
* its helpers, the engine objects it holds - is reached as it is, and a listed operation runs with
|
|
10
|
+
* the kernel object itself as `this`. The same object is wrapped once, so a path read twice gives
|
|
11
|
+
* the same object both times.
|
|
12
|
+
* @param root - The kernel's root object
|
|
13
|
+
* @param registry - The kernel's operations by dotted path, as its package exports them
|
|
14
|
+
* @returns The kernel, applying the defaults on every listed operation
|
|
15
|
+
*/
|
|
16
|
+
export function withDefaults(root, registry) {
|
|
17
|
+
const prefixes = new Set([""]);
|
|
18
|
+
for (const path of Object.keys(registry)) {
|
|
19
|
+
const segments = path.split(".");
|
|
20
|
+
for (let i = 1; i < segments.length; i++) {
|
|
21
|
+
prefixes.add(segments.slice(0, i).join("."));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const wrapped = new WeakMap();
|
|
25
|
+
const wrap = (target, prefix) => {
|
|
26
|
+
const known = wrapped.get(target);
|
|
27
|
+
if (known) {
|
|
28
|
+
return known;
|
|
29
|
+
}
|
|
30
|
+
const proxy = new Proxy(target, {
|
|
31
|
+
get(object, key) {
|
|
32
|
+
const value = Reflect.get(object, key);
|
|
33
|
+
if (typeof key !== "string") {
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
const path = prefix ? `${prefix}.${key}` : key;
|
|
37
|
+
if (typeof value === "function") {
|
|
38
|
+
if (isRegisteredOperation(registry, path)) {
|
|
39
|
+
return (inputs) => value.call(object, resolveInputs(registry, path, inputs));
|
|
40
|
+
}
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
if (value !== null && typeof value === "object" && prefixes.has(path)) {
|
|
44
|
+
return wrap(value, path);
|
|
45
|
+
}
|
|
46
|
+
return value;
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
wrapped.set(target, proxy);
|
|
50
|
+
return proxy;
|
|
51
|
+
};
|
|
52
|
+
return wrap(root, "");
|
|
53
|
+
}
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import { WithDefaults } from "../kernel-calls";
|
|
2
|
+
import * as Inputs from "../inputs";
|
|
3
|
+
/**
|
|
4
|
+
* The Color inputs DTOs as their defaults leave them: every property with a default is present,
|
|
5
|
+
* the way `resolveDto` hands a DTO to the code that reads it.
|
|
6
|
+
*/
|
|
7
|
+
export declare namespace Color {
|
|
8
|
+
type HexDto = WithDefaults<Inputs.Color.HexDto, "color">;
|
|
9
|
+
type HexDtoMapped = WithDefaults<Inputs.Color.HexDtoMapped, "color" | "from" | "to">;
|
|
10
|
+
type InvertHexDto = WithDefaults<Inputs.Color.InvertHexDto, "color" | "blackAndWhite">;
|
|
11
|
+
type Rgb1Dto = WithDefaults<Inputs.Color.Rgb1Dto, "colorRgb">;
|
|
12
|
+
type Rgb255Dto = WithDefaults<Inputs.Color.Rgb255Dto, "colorRgb">;
|
|
13
|
+
type Rgba1Dto = WithDefaults<Inputs.Color.Rgba1Dto, "colorRgba">;
|
|
14
|
+
type Rgba255Dto = WithDefaults<Inputs.Color.Rgba255Dto, "colorRgba">;
|
|
15
|
+
type RgbaAttomic1Dto = WithDefaults<Inputs.Color.RgbaAttomic1Dto, "r" | "g" | "b" | "a">;
|
|
16
|
+
type RgbaAttomic255Dto = WithDefaults<Inputs.Color.RgbaAttomic255Dto, "r" | "g" | "b" | "a">;
|
|
17
|
+
type RgbAttomic1Dto = WithDefaults<Inputs.Color.RgbAttomic1Dto, "r" | "g" | "b">;
|
|
18
|
+
type RgbAttomic255Dto = WithDefaults<Inputs.Color.RgbAttomic255Dto, "r" | "g" | "b">;
|
|
19
|
+
type RGBMinMaxDto = WithDefaults<Inputs.Color.RGBMinMaxDto, "r" | "g" | "b" | "min" | "max">;
|
|
20
|
+
type RGBObjectDto = Inputs.Color.RGBObjectDto;
|
|
21
|
+
type RGBObjectMaxDto = WithDefaults<Inputs.Color.RGBObjectMaxDto, "min" | "max">;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The Dates inputs DTOs as their defaults leave them: every property with a default is present,
|
|
25
|
+
* the way `resolveDto` hands a DTO to the code that reads it.
|
|
26
|
+
*/
|
|
27
|
+
export declare namespace Dates {
|
|
28
|
+
type CreateDateDto = WithDefaults<Inputs.Dates.CreateDateDto, "year" | "month" | "day" | "hours" | "minutes" | "seconds" | "milliseconds">;
|
|
29
|
+
type CreateFromUnixTimeStampDto = WithDefaults<Inputs.Dates.CreateFromUnixTimeStampDto, "unixTimeStamp">;
|
|
30
|
+
type DateDayDto = WithDefaults<Inputs.Dates.DateDayDto, "day">;
|
|
31
|
+
type DateDto = Inputs.Dates.DateDto;
|
|
32
|
+
type DateHoursDto = WithDefaults<Inputs.Dates.DateHoursDto, "hours">;
|
|
33
|
+
type DateMillisecondsDto = WithDefaults<Inputs.Dates.DateMillisecondsDto, "milliseconds">;
|
|
34
|
+
type DateMinutesDto = WithDefaults<Inputs.Dates.DateMinutesDto, "minutes">;
|
|
35
|
+
type DateMonthDto = WithDefaults<Inputs.Dates.DateMonthDto, "month">;
|
|
36
|
+
type DateSecondsDto = WithDefaults<Inputs.Dates.DateSecondsDto, "seconds">;
|
|
37
|
+
type DateStringDto = Inputs.Dates.DateStringDto;
|
|
38
|
+
type DateTimeDto = WithDefaults<Inputs.Dates.DateTimeDto, "time">;
|
|
39
|
+
type DateYearDto = WithDefaults<Inputs.Dates.DateYearDto, "year">;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The Frame inputs DTOs as their defaults leave them: every property with a default is present,
|
|
43
|
+
* the way `resolveDto` hands a DTO to the code that reads it.
|
|
44
|
+
*/
|
|
45
|
+
export declare namespace Frame {
|
|
46
|
+
type BestFitDto = Inputs.Frame.BestFitDto;
|
|
47
|
+
type ChildFrameDto = Inputs.Frame.ChildFrameDto;
|
|
48
|
+
type ChildFramesDto = Inputs.Frame.ChildFramesDto;
|
|
49
|
+
type ChildFrameSharedDto = Inputs.Frame.ChildFrameSharedDto;
|
|
50
|
+
type CreateFrameDto = WithDefaults<Inputs.Frame.CreateFrameDto, "origin" | "normal" | "direction">;
|
|
51
|
+
type FrameDto = Inputs.Frame.FrameDto;
|
|
52
|
+
type FramePointDto = Inputs.Frame.FramePointDto;
|
|
53
|
+
type FramePointsDto = Inputs.Frame.FramePointsDto;
|
|
54
|
+
type FramesDto = Inputs.Frame.FramesDto;
|
|
55
|
+
type FrameVectorDto = Inputs.Frame.FrameVectorDto;
|
|
56
|
+
type FromToDto = Inputs.Frame.FromToDto;
|
|
57
|
+
type GridDto = WithDefaults<Inputs.Frame.GridDto, "countX" | "countY" | "spacingX" | "spacingY" | "centered">;
|
|
58
|
+
type HexGridDto = WithDefaults<Inputs.Frame.HexGridDto, "countX" | "countY" | "radius" | "centered">;
|
|
59
|
+
type OffsetDto = WithDefaults<Inputs.Frame.OffsetDto, "distance">;
|
|
60
|
+
type OffsetFramesDto = WithDefaults<Inputs.Frame.OffsetFramesDto, "distance">;
|
|
61
|
+
type OffsetSharedDto = WithDefaults<Inputs.Frame.OffsetSharedDto, "distance">;
|
|
62
|
+
type OriginDto = WithDefaults<Inputs.Frame.OriginDto, "origin">;
|
|
63
|
+
type PointAndNormalDto = WithDefaults<Inputs.Frame.PointAndNormalDto, "origin" | "normal">;
|
|
64
|
+
type PolarDto = WithDefaults<Inputs.Frame.PolarDto, "count" | "radius" | "angle" | "startAngle" | "rotate">;
|
|
65
|
+
type RotateDto = WithDefaults<Inputs.Frame.RotateDto, "axis" | "angle">;
|
|
66
|
+
type RotateFramesDto = WithDefaults<Inputs.Frame.RotateFramesDto, "axis" | "angle">;
|
|
67
|
+
type RotateSharedDto = WithDefaults<Inputs.Frame.RotateSharedDto, "axis" | "angle">;
|
|
68
|
+
type ThreePointsDto = WithDefaults<Inputs.Frame.ThreePointsDto, "origin" | "xPoint" | "planePoint">;
|
|
69
|
+
type TransformationDto = Inputs.Frame.TransformationDto;
|
|
70
|
+
type TranslateDto = WithDefaults<Inputs.Frame.TranslateDto, "translation">;
|
|
71
|
+
type TranslateFramesDto = WithDefaults<Inputs.Frame.TranslateFramesDto, "translation">;
|
|
72
|
+
type TranslateSharedDto = WithDefaults<Inputs.Frame.TranslateSharedDto, "translation">;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The IO inputs DTOs as their defaults leave them: every property with a default is present,
|
|
76
|
+
* the way `resolveDto` hands a DTO to the code that reads it.
|
|
77
|
+
*/
|
|
78
|
+
export declare namespace IO {
|
|
79
|
+
type DxfArcSegmentDto = Inputs.IO.DxfArcSegmentDto;
|
|
80
|
+
type DxfCircleSegmentDto = Inputs.IO.DxfCircleSegmentDto;
|
|
81
|
+
type DxfLineSegmentDto = Inputs.IO.DxfLineSegmentDto;
|
|
82
|
+
type DxfModelDto = WithDefaults<Inputs.IO.DxfModelDto, "colorFormat" | "acadVersion">;
|
|
83
|
+
type DxfPathDto = Inputs.IO.DxfPathDto;
|
|
84
|
+
type DxfPathsPartDto = WithDefaults<Inputs.IO.DxfPathsPartDto, "layer" | "color">;
|
|
85
|
+
type DxfPolylineSegmentDto = WithDefaults<Inputs.IO.DxfPolylineSegmentDto, "closed">;
|
|
86
|
+
type DxfSplineSegmentDto = WithDefaults<Inputs.IO.DxfSplineSegmentDto, "degree" | "closed">;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The Line inputs DTOs as their defaults leave them: every property with a default is present,
|
|
90
|
+
* the way `resolveDto` hands a DTO to the code that reads it.
|
|
91
|
+
*/
|
|
92
|
+
export declare namespace Line {
|
|
93
|
+
type DrawLineDto<T> = WithDefaults<Inputs.Line.DrawLineDto<T>, "opacity" | "colours" | "size" | "updatable">;
|
|
94
|
+
type DrawLinesDto<T> = WithDefaults<Inputs.Line.DrawLinesDto<T>, "opacity" | "colours" | "size" | "updatable">;
|
|
95
|
+
type LineDto = Inputs.Line.LineDto;
|
|
96
|
+
type LineLineIntersectionDto = WithDefaults<Inputs.Line.LineLineIntersectionDto, "checkSegmentsOnly" | "tolerance">;
|
|
97
|
+
type LinePointsDto = Inputs.Line.LinePointsDto;
|
|
98
|
+
type LinesDto = Inputs.Line.LinesDto;
|
|
99
|
+
type LineStartEndPointsDto = Inputs.Line.LineStartEndPointsDto;
|
|
100
|
+
type PointOnLineDto = WithDefaults<Inputs.Line.PointOnLineDto, "param">;
|
|
101
|
+
type PointsLinesDto = Inputs.Line.PointsLinesDto;
|
|
102
|
+
type SegmentDto = Inputs.Line.SegmentDto;
|
|
103
|
+
type SegmentsDto = Inputs.Line.SegmentsDto;
|
|
104
|
+
type TransformLineDto = Inputs.Line.TransformLineDto;
|
|
105
|
+
type TransformLinesDto = Inputs.Line.TransformLinesDto;
|
|
106
|
+
type TransformsLinesDto = Inputs.Line.TransformsLinesDto;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* The Lists inputs DTOs as their defaults leave them: every property with a default is present,
|
|
110
|
+
* the way `resolveDto` hands a DTO to the code that reads it.
|
|
111
|
+
*/
|
|
112
|
+
export declare namespace Lists {
|
|
113
|
+
type AddItemAtIndexDto<T> = WithDefaults<Inputs.Lists.AddItemAtIndexDto<T>, "index" | "clone">;
|
|
114
|
+
type AddItemAtIndexesDto<T> = WithDefaults<Inputs.Lists.AddItemAtIndexesDto<T>, "indexes" | "clone">;
|
|
115
|
+
type AddItemDto<T> = WithDefaults<Inputs.Lists.AddItemDto<T>, "clone">;
|
|
116
|
+
type AddItemFirstLastDto<T> = WithDefaults<Inputs.Lists.AddItemFirstLastDto<T>, "position" | "clone">;
|
|
117
|
+
type AddItemsAtIndexesDto<T> = WithDefaults<Inputs.Lists.AddItemsAtIndexesDto<T>, "indexes" | "clone">;
|
|
118
|
+
type ConcatenateDto<T> = WithDefaults<Inputs.Lists.ConcatenateDto<T>, "clone">;
|
|
119
|
+
type GetByPatternDto<T> = WithDefaults<Inputs.Lists.GetByPatternDto<T>, "pattern">;
|
|
120
|
+
type GetLongestListLength<T> = Inputs.Lists.GetLongestListLength<T>;
|
|
121
|
+
type GetNthItemDto<T> = WithDefaults<Inputs.Lists.GetNthItemDto<T>, "nth" | "offset" | "clone">;
|
|
122
|
+
type GroupListDto<T> = WithDefaults<Inputs.Lists.GroupListDto<T>, "nrElements" | "keepRemainder">;
|
|
123
|
+
type IncludesDto<T> = Inputs.Lists.IncludesDto<T>;
|
|
124
|
+
type InterleaveDto<T> = WithDefaults<Inputs.Lists.InterleaveDto<T>, "clone">;
|
|
125
|
+
type ListCloneDto<T> = WithDefaults<Inputs.Lists.ListCloneDto<T>, "clone">;
|
|
126
|
+
type ListDto<T> = Inputs.Lists.ListDto<T>;
|
|
127
|
+
type ListItemDto<T> = WithDefaults<Inputs.Lists.ListItemDto<T>, "index" | "clone">;
|
|
128
|
+
type MergeElementsOfLists<T> = WithDefaults<Inputs.Lists.MergeElementsOfLists<T>, "level">;
|
|
129
|
+
type MultiplyItemDto<T> = WithDefaults<Inputs.Lists.MultiplyItemDto<T>, "times">;
|
|
130
|
+
type RandomThresholdDto<T> = WithDefaults<Inputs.Lists.RandomThresholdDto<T>, "threshold" | "clone">;
|
|
131
|
+
type RemoveDuplicatesDto<T> = WithDefaults<Inputs.Lists.RemoveDuplicatesDto<T>, "clone">;
|
|
132
|
+
type RemoveDuplicatesToleranceDto<T> = WithDefaults<Inputs.Lists.RemoveDuplicatesToleranceDto<T>, "tolerance" | "clone">;
|
|
133
|
+
type RemoveItemAtIndexDto<T> = WithDefaults<Inputs.Lists.RemoveItemAtIndexDto<T>, "index" | "clone">;
|
|
134
|
+
type RemoveItemsAtIndexesDto<T> = WithDefaults<Inputs.Lists.RemoveItemsAtIndexesDto<T>, "clone">;
|
|
135
|
+
type RemoveNthItemDto<T> = WithDefaults<Inputs.Lists.RemoveNthItemDto<T>, "nth" | "offset" | "clone">;
|
|
136
|
+
type RepeatInPatternDto<T> = WithDefaults<Inputs.Lists.RepeatInPatternDto<T>, "clone" | "lengthLimit">;
|
|
137
|
+
type SortDto<T> = WithDefaults<Inputs.Lists.SortDto<T>, "clone" | "orderAsc">;
|
|
138
|
+
type SortJsonDto<T> = WithDefaults<Inputs.Lists.SortJsonDto<T>, "clone" | "orderAsc" | "property">;
|
|
139
|
+
type SubListDto<T> = WithDefaults<Inputs.Lists.SubListDto<T>, "indexStart" | "indexEnd" | "clone">;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* The Logic inputs DTOs as their defaults leave them: every property with a default is present,
|
|
143
|
+
* the way `resolveDto` hands a DTO to the code that reads it.
|
|
144
|
+
*/
|
|
145
|
+
export declare namespace Logic {
|
|
146
|
+
type BooleanDto = WithDefaults<Inputs.Logic.BooleanDto, "boolean">;
|
|
147
|
+
type BooleanListDto = Inputs.Logic.BooleanListDto;
|
|
148
|
+
type ComparisonDto<T> = WithDefaults<Inputs.Logic.ComparisonDto<T>, "operator">;
|
|
149
|
+
type RandomBooleansDto = WithDefaults<Inputs.Logic.RandomBooleansDto, "length" | "trueThreshold">;
|
|
150
|
+
type ThresholdBooleanListDto = WithDefaults<Inputs.Logic.ThresholdBooleanListDto, "threshold" | "inverse">;
|
|
151
|
+
type ThresholdGapsBooleanListDto = WithDefaults<Inputs.Logic.ThresholdGapsBooleanListDto, "inverse">;
|
|
152
|
+
type TwoThresholdRandomGradientDto = WithDefaults<Inputs.Logic.TwoThresholdRandomGradientDto, "thresholdTotalTrue" | "thresholdTotalFalse" | "nrLevels">;
|
|
153
|
+
type TwoValueGateDto<T, U> = Inputs.Logic.TwoValueGateDto<T, U>;
|
|
154
|
+
type ValueGateDto<T> = WithDefaults<Inputs.Logic.ValueGateDto<T>, "boolean">;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* The Math inputs DTOs as their defaults leave them: every property with a default is present,
|
|
158
|
+
* the way `resolveDto` hands a DTO to the code that reads it.
|
|
159
|
+
*/
|
|
160
|
+
export declare namespace Math {
|
|
161
|
+
type ActionOnOneNumberDto = WithDefaults<Inputs.Math.ActionOnOneNumberDto, "number" | "operation">;
|
|
162
|
+
type ActionOnTwoNumbersDto = WithDefaults<Inputs.Math.ActionOnTwoNumbersDto, "first" | "second" | "operation">;
|
|
163
|
+
type ClampDto = WithDefaults<Inputs.Math.ClampDto, "number" | "min" | "max">;
|
|
164
|
+
type EaseDto = WithDefaults<Inputs.Math.EaseDto, "x" | "min" | "max" | "ease">;
|
|
165
|
+
type EvalArithmeticDto = WithDefaults<Inputs.Math.EvalArithmeticDto, "expression">;
|
|
166
|
+
type InverseLerpDto = WithDefaults<Inputs.Math.InverseLerpDto, "start" | "end" | "value">;
|
|
167
|
+
type LerpDto = WithDefaults<Inputs.Math.LerpDto, "start" | "end" | "t">;
|
|
168
|
+
type ModulusDto = WithDefaults<Inputs.Math.ModulusDto, "number" | "modulus">;
|
|
169
|
+
type MoveTowardsDto = WithDefaults<Inputs.Math.MoveTowardsDto, "current" | "target" | "maxDelta">;
|
|
170
|
+
type NumberDto = WithDefaults<Inputs.Math.NumberDto, "number">;
|
|
171
|
+
type PingPongDto = WithDefaults<Inputs.Math.PingPongDto, "t" | "length">;
|
|
172
|
+
type RandomNumberDto = WithDefaults<Inputs.Math.RandomNumberDto, "low" | "high">;
|
|
173
|
+
type RandomNumbersDto = WithDefaults<Inputs.Math.RandomNumbersDto, "low" | "high" | "count">;
|
|
174
|
+
type RemapNumberDto = WithDefaults<Inputs.Math.RemapNumberDto, "number" | "fromLow" | "fromHigh" | "toLow" | "toHigh">;
|
|
175
|
+
type RoundToDecimalsDto = WithDefaults<Inputs.Math.RoundToDecimalsDto, "number" | "decimalPlaces">;
|
|
176
|
+
type ToFixedDto = WithDefaults<Inputs.Math.ToFixedDto, "decimalPlaces">;
|
|
177
|
+
type TwoNumbersDto = WithDefaults<Inputs.Math.TwoNumbersDto, "first" | "second">;
|
|
178
|
+
type WrapDto = WithDefaults<Inputs.Math.WrapDto, "number" | "min" | "max">;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* The Mesh inputs DTOs as their defaults leave them: every property with a default is present,
|
|
182
|
+
* the way `resolveDto` hands a DTO to the code that reads it.
|
|
183
|
+
*/
|
|
184
|
+
export declare namespace Mesh {
|
|
185
|
+
type MeshMeshToleranceDto = WithDefaults<Inputs.Mesh.MeshMeshToleranceDto, "tolerance">;
|
|
186
|
+
type SignedDistanceFromPlaneToPointDto = Inputs.Mesh.SignedDistanceFromPlaneToPointDto;
|
|
187
|
+
type TriangleDto = Inputs.Mesh.TriangleDto;
|
|
188
|
+
type TriangleToleranceDto = WithDefaults<Inputs.Mesh.TriangleToleranceDto, "tolerance">;
|
|
189
|
+
type TriangleTriangleToleranceDto = WithDefaults<Inputs.Mesh.TriangleTriangleToleranceDto, "tolerance">;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* The Point inputs DTOs as their defaults leave them: every property with a default is present,
|
|
193
|
+
* the way `resolveDto` hands a DTO to the code that reads it.
|
|
194
|
+
*/
|
|
195
|
+
export declare namespace Point {
|
|
196
|
+
type ClosestPointFromPointsDto = Inputs.Point.ClosestPointFromPointsDto;
|
|
197
|
+
type DrawPointDto<T> = WithDefaults<Inputs.Point.DrawPointDto<T>, "opacity" | "size" | "colours" | "updatable">;
|
|
198
|
+
type DrawPointsDto<T> = WithDefaults<Inputs.Point.DrawPointsDto<T>, "opacity" | "size" | "colours" | "updatable">;
|
|
199
|
+
type HexGridCentersDto = WithDefaults<Inputs.Point.HexGridCentersDto, "nrHexagonsY" | "nrHexagonsX" | "radiusHexagon" | "orientOnCenter" | "pointsOnGround">;
|
|
200
|
+
type HexGridScaledToFitDto = WithDefaults<Inputs.Point.HexGridScaledToFitDto, "width" | "height" | "nrHexagonsInWidth" | "nrHexagonsInHeight" | "flatTop" | "extendTop" | "extendBottom" | "extendLeft" | "extendRight" | "centerGrid" | "pointsOnGround">;
|
|
201
|
+
type MultiplyPointDto = Inputs.Point.MultiplyPointDto;
|
|
202
|
+
type PointDto = Inputs.Point.PointDto;
|
|
203
|
+
type PointsDto = Inputs.Point.PointsDto;
|
|
204
|
+
type PointsMaxFilletsHalfLineDto = WithDefaults<Inputs.Point.PointsMaxFilletsHalfLineDto, "checkLastWithFirst" | "tolerance">;
|
|
205
|
+
type PointXYDto = WithDefaults<Inputs.Point.PointXYDto, "x" | "y">;
|
|
206
|
+
type PointXYZDto = WithDefaults<Inputs.Point.PointXYZDto, "x" | "y" | "z">;
|
|
207
|
+
type RemoveConsecutiveDuplicatesDto = WithDefaults<Inputs.Point.RemoveConsecutiveDuplicatesDto, "tolerance" | "checkFirstAndLast">;
|
|
208
|
+
type RotatePointsCenterAxisDto = WithDefaults<Inputs.Point.RotatePointsCenterAxisDto, "angle" | "axis" | "center">;
|
|
209
|
+
type ScalePointsCenterXYZDto = WithDefaults<Inputs.Point.ScalePointsCenterXYZDto, "center" | "scaleXyz">;
|
|
210
|
+
type SpiralDto = WithDefaults<Inputs.Point.SpiralDto, "phi" | "numberPoints" | "widening" | "radius" | "factor">;
|
|
211
|
+
type StartEndPointsDto = Inputs.Point.StartEndPointsDto;
|
|
212
|
+
type StartEndPointsListDto = Inputs.Point.StartEndPointsListDto;
|
|
213
|
+
type StretchPointsDirFromCenterDto = WithDefaults<Inputs.Point.StretchPointsDirFromCenterDto, "center" | "direction" | "scale">;
|
|
214
|
+
type ThreePointsNormalDto = WithDefaults<Inputs.Point.ThreePointsNormalDto, "reverseNormal">;
|
|
215
|
+
type ThreePointsToleranceDto = WithDefaults<Inputs.Point.ThreePointsToleranceDto, "tolerance">;
|
|
216
|
+
type TransformPointDto = Inputs.Point.TransformPointDto;
|
|
217
|
+
type TransformPointsDto = Inputs.Point.TransformPointsDto;
|
|
218
|
+
type TransformsForPointsDto = Inputs.Point.TransformsForPointsDto;
|
|
219
|
+
type TranslatePointsDto = Inputs.Point.TranslatePointsDto;
|
|
220
|
+
type TranslatePointsWithVectorsDto = Inputs.Point.TranslatePointsWithVectorsDto;
|
|
221
|
+
type TranslateXYZPointsDto = WithDefaults<Inputs.Point.TranslateXYZPointsDto, "x" | "y" | "z">;
|
|
222
|
+
type TwoPointsDto = Inputs.Point.TwoPointsDto;
|
|
223
|
+
type TwoPointsToleranceDto = WithDefaults<Inputs.Point.TwoPointsToleranceDto, "tolerance">;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* The Polyline inputs DTOs as their defaults leave them: every property with a default is present,
|
|
227
|
+
* the way `resolveDto` hands a DTO to the code that reads it.
|
|
228
|
+
*/
|
|
229
|
+
export declare namespace Polyline {
|
|
230
|
+
type DrawPolylineDto<T> = WithDefaults<Inputs.Polyline.DrawPolylineDto<T>, "opacity" | "colours" | "size" | "updatable">;
|
|
231
|
+
type DrawPolylinesDto<T> = WithDefaults<Inputs.Polyline.DrawPolylinesDto<T>, "opacity" | "colours" | "size" | "updatable">;
|
|
232
|
+
type PolylineCreateDto = WithDefaults<Inputs.Polyline.PolylineCreateDto, "isClosed">;
|
|
233
|
+
type PolylineDto = Inputs.Polyline.PolylineDto;
|
|
234
|
+
type PolylinePropertiesDto = WithDefaults<Inputs.Polyline.PolylinePropertiesDto, "isClosed">;
|
|
235
|
+
type PolylinesDto = Inputs.Polyline.PolylinesDto;
|
|
236
|
+
type PolylineToleranceDto = WithDefaults<Inputs.Polyline.PolylineToleranceDto, "tolerance">;
|
|
237
|
+
type SegmentsToleranceDto = WithDefaults<Inputs.Polyline.SegmentsToleranceDto, "tolerance">;
|
|
238
|
+
type TransformPolylineDto = Inputs.Polyline.TransformPolylineDto;
|
|
239
|
+
type TwoPolylinesToleranceDto = WithDefaults<Inputs.Polyline.TwoPolylinesToleranceDto, "tolerance">;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* The Text inputs DTOs as their defaults leave them: every property with a default is present,
|
|
243
|
+
* the way `resolveDto` hands a DTO to the code that reads it.
|
|
244
|
+
*/
|
|
245
|
+
export declare namespace Text {
|
|
246
|
+
type TextConcatDto = WithDefaults<Inputs.Text.TextConcatDto, "texts">;
|
|
247
|
+
type TextDto = WithDefaults<Inputs.Text.TextDto, "text">;
|
|
248
|
+
type TextFormatDto = WithDefaults<Inputs.Text.TextFormatDto, "text" | "values">;
|
|
249
|
+
type TextIndexDto = WithDefaults<Inputs.Text.TextIndexDto, "text" | "index">;
|
|
250
|
+
type TextJoinDto = WithDefaults<Inputs.Text.TextJoinDto, "separator">;
|
|
251
|
+
type TextPadDto = WithDefaults<Inputs.Text.TextPadDto, "text" | "length" | "padString">;
|
|
252
|
+
type TextRegexDto = WithDefaults<Inputs.Text.TextRegexDto, "text" | "pattern" | "flags">;
|
|
253
|
+
type TextRegexReplaceDto = WithDefaults<Inputs.Text.TextRegexReplaceDto, "text" | "pattern" | "flags" | "replaceWith">;
|
|
254
|
+
type TextRepeatDto = WithDefaults<Inputs.Text.TextRepeatDto, "text" | "count">;
|
|
255
|
+
type TextReplaceDto = WithDefaults<Inputs.Text.TextReplaceDto, "text" | "search" | "replaceWith">;
|
|
256
|
+
type TextSearchDto = WithDefaults<Inputs.Text.TextSearchDto, "text" | "search">;
|
|
257
|
+
type TextSplitDto = WithDefaults<Inputs.Text.TextSplitDto, "text" | "separator">;
|
|
258
|
+
type TextSubstringDto = WithDefaults<Inputs.Text.TextSubstringDto, "text" | "start">;
|
|
259
|
+
type ToStringDto<T> = Inputs.Text.ToStringDto<T>;
|
|
260
|
+
type ToStringEachDto<T> = Inputs.Text.ToStringEachDto<T>;
|
|
261
|
+
type VectorCharDto = WithDefaults<Inputs.Text.VectorCharDto, "char" | "xOffset" | "yOffset" | "height" | "extrudeOffset">;
|
|
262
|
+
type VectorTextDto = WithDefaults<Inputs.Text.VectorTextDto, "text" | "xOffset" | "yOffset" | "height" | "lineSpacing" | "letterSpacing" | "align" | "extrudeOffset" | "centerOnOrigin">;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* The Transforms inputs DTOs as their defaults leave them: every property with a default is present,
|
|
266
|
+
* the way `resolveDto` hands a DTO to the code that reads it.
|
|
267
|
+
*/
|
|
268
|
+
export declare namespace Transforms {
|
|
269
|
+
type RotationCenterAxisDto = WithDefaults<Inputs.Transforms.RotationCenterAxisDto, "angle" | "axis" | "center">;
|
|
270
|
+
type RotationCenterDto = WithDefaults<Inputs.Transforms.RotationCenterDto, "angle" | "center">;
|
|
271
|
+
type RotationCenterYawPitchRollDto = WithDefaults<Inputs.Transforms.RotationCenterYawPitchRollDto, "yaw" | "pitch" | "roll" | "center">;
|
|
272
|
+
type ScaleCenterXYZDto = WithDefaults<Inputs.Transforms.ScaleCenterXYZDto, "center" | "scaleXyz">;
|
|
273
|
+
type ScaleXYZDto = WithDefaults<Inputs.Transforms.ScaleXYZDto, "scaleXyz">;
|
|
274
|
+
type StretchDirCenterDto = WithDefaults<Inputs.Transforms.StretchDirCenterDto, "center" | "direction" | "scale">;
|
|
275
|
+
type TranslationsXYZDto = Inputs.Transforms.TranslationsXYZDto;
|
|
276
|
+
type TranslationXYZDto = WithDefaults<Inputs.Transforms.TranslationXYZDto, "translation">;
|
|
277
|
+
type UniformScaleDto = WithDefaults<Inputs.Transforms.UniformScaleDto, "scale">;
|
|
278
|
+
type UniformScaleFromCenterDto = WithDefaults<Inputs.Transforms.UniformScaleFromCenterDto, "scale" | "center">;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* The Vector inputs DTOs as their defaults leave them: every property with a default is present,
|
|
282
|
+
* the way `resolveDto` hands a DTO to the code that reads it.
|
|
283
|
+
*/
|
|
284
|
+
export declare namespace Vector {
|
|
285
|
+
type FractionTwoVectorsDto = WithDefaults<Inputs.Vector.FractionTwoVectorsDto, "fraction">;
|
|
286
|
+
type RangeMaxDto = WithDefaults<Inputs.Vector.RangeMaxDto, "max">;
|
|
287
|
+
type RayPointDto = WithDefaults<Inputs.Vector.RayPointDto, "distance">;
|
|
288
|
+
type RemoveAllDuplicateVectorsDto = WithDefaults<Inputs.Vector.RemoveAllDuplicateVectorsDto, "tolerance">;
|
|
289
|
+
type RemoveConsecutiveDuplicateVectorsDto = WithDefaults<Inputs.Vector.RemoveConsecutiveDuplicateVectorsDto, "checkFirstAndLast" | "tolerance">;
|
|
290
|
+
type SpanDto = WithDefaults<Inputs.Vector.SpanDto, "step" | "min" | "max">;
|
|
291
|
+
type SpanEaseItemsDto = WithDefaults<Inputs.Vector.SpanEaseItemsDto, "nrItems" | "min" | "max" | "ease" | "intervals">;
|
|
292
|
+
type SpanLinearItemsDto = WithDefaults<Inputs.Vector.SpanLinearItemsDto, "nrItems" | "min" | "max">;
|
|
293
|
+
type TwoVectorsDto = Inputs.Vector.TwoVectorsDto;
|
|
294
|
+
type TwoVectorsReferenceDto = Inputs.Vector.TwoVectorsReferenceDto;
|
|
295
|
+
type Vector3Dto = Inputs.Vector.Vector3Dto;
|
|
296
|
+
type VectorBoolDto = Inputs.Vector.VectorBoolDto;
|
|
297
|
+
type VectorDto = Inputs.Vector.VectorDto;
|
|
298
|
+
type VectorScalarDto = WithDefaults<Inputs.Vector.VectorScalarDto, "scalar">;
|
|
299
|
+
type VectorsDto = Inputs.Vector.VectorsDto;
|
|
300
|
+
type VectorsTheSameDto = WithDefaults<Inputs.Vector.VectorsTheSameDto, "tolerance">;
|
|
301
|
+
type VectorStringDto = Inputs.Vector.VectorStringDto;
|
|
302
|
+
type VectorXYDto = WithDefaults<Inputs.Vector.VectorXYDto, "x" | "y">;
|
|
303
|
+
type VectorXYZDto = WithDefaults<Inputs.Vector.VectorXYZDto, "x" | "y" | "z">;
|
|
304
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as Inputs from "../inputs";
|
|
2
|
+
import { resolveDto } from "../kernel-calls";
|
|
1
3
|
/**
|
|
2
4
|
* Colors in the two forms the library uses: a hex text such as `#ff5733`, and an object `{ r, g, b
|
|
3
5
|
* }` or `{ r, g, b, a }` whose channels run either from 0 to 255 or from 0 to 1. The methods here
|
|
@@ -19,7 +21,8 @@ export class Color {
|
|
|
19
21
|
* @drawable false
|
|
20
22
|
*/
|
|
21
23
|
hexColor(inputs) {
|
|
22
|
-
|
|
24
|
+
const resolved = resolveDto(Inputs.Color.HexDto, inputs);
|
|
25
|
+
return resolved.color;
|
|
23
26
|
}
|
|
24
27
|
/**
|
|
25
28
|
* Passes an `{ r, g, b }` color with channels from 0 to 255 through unchanged, so it can be
|
|
@@ -33,7 +36,8 @@ export class Color {
|
|
|
33
36
|
* @drawable false
|
|
34
37
|
*/
|
|
35
38
|
rgb255Color(inputs) {
|
|
36
|
-
|
|
39
|
+
const resolved = resolveDto(Inputs.Color.Rgb255Dto, inputs);
|
|
40
|
+
return resolved.colorRgb;
|
|
37
41
|
}
|
|
38
42
|
/**
|
|
39
43
|
* Passes an `{ r, g, b }` color with channels from 0 to 1 through unchanged, so it can be
|
|
@@ -47,7 +51,8 @@ export class Color {
|
|
|
47
51
|
* @drawable false
|
|
48
52
|
*/
|
|
49
53
|
rgb1Color(inputs) {
|
|
50
|
-
|
|
54
|
+
const resolved = resolveDto(Inputs.Color.Rgb1Dto, inputs);
|
|
55
|
+
return resolved.colorRgb;
|
|
51
56
|
}
|
|
52
57
|
/**
|
|
53
58
|
* Passes an `{ r, g, b, a }` color with color channels from 0 to 255 and opacity from 0 to 1
|
|
@@ -61,7 +66,8 @@ export class Color {
|
|
|
61
66
|
* @drawable false
|
|
62
67
|
*/
|
|
63
68
|
rgba255Color(inputs) {
|
|
64
|
-
|
|
69
|
+
const resolved = resolveDto(Inputs.Color.Rgba255Dto, inputs);
|
|
70
|
+
return resolved.colorRgba;
|
|
65
71
|
}
|
|
66
72
|
/**
|
|
67
73
|
* Passes an `{ r, g, b, a }` color with every channel from 0 to 1 through unchanged, so it can
|
|
@@ -75,7 +81,8 @@ export class Color {
|
|
|
75
81
|
* @drawable false
|
|
76
82
|
*/
|
|
77
83
|
rgba1Color(inputs) {
|
|
78
|
-
|
|
84
|
+
const resolved = resolveDto(Inputs.Color.Rgba1Dto, inputs);
|
|
85
|
+
return resolved.colorRgba;
|
|
79
86
|
}
|
|
80
87
|
/**
|
|
81
88
|
* Builds an `{ r, g, b }` color from three separate channel values from 0 to 255.
|
|
@@ -92,7 +99,8 @@ export class Color {
|
|
|
92
99
|
* ```
|
|
93
100
|
*/
|
|
94
101
|
rgbAtomic255Color(inputs) {
|
|
95
|
-
|
|
102
|
+
const resolved = resolveDto(Inputs.Color.RgbAttomic255Dto, inputs);
|
|
103
|
+
return Object.assign({}, resolved);
|
|
96
104
|
}
|
|
97
105
|
/**
|
|
98
106
|
* Builds an `{ r, g, b }` color from three separate channel values from 0 to 1.
|
|
@@ -109,7 +117,8 @@ export class Color {
|
|
|
109
117
|
* ```
|
|
110
118
|
*/
|
|
111
119
|
rgbAtomic1Color(inputs) {
|
|
112
|
-
|
|
120
|
+
const resolved = resolveDto(Inputs.Color.RgbAttomic1Dto, inputs);
|
|
121
|
+
return Object.assign({}, resolved);
|
|
113
122
|
}
|
|
114
123
|
/**
|
|
115
124
|
* Reads a hex color into an `{ r, g, b }` object with channels from 0 to 255.
|
|
@@ -127,9 +136,10 @@ export class Color {
|
|
|
127
136
|
* ```
|
|
128
137
|
*/
|
|
129
138
|
hexToRgb(inputs) {
|
|
130
|
-
const
|
|
139
|
+
const resolved = resolveDto(Inputs.Color.HexDto, inputs);
|
|
140
|
+
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(resolved.color);
|
|
131
141
|
if (!result) {
|
|
132
|
-
throw new Error(`Invalid hex color: ${
|
|
142
|
+
throw new Error(`Invalid hex color: ${resolved.color}`);
|
|
133
143
|
}
|
|
134
144
|
return {
|
|
135
145
|
r: parseInt(result[1], 16),
|
|
@@ -154,13 +164,14 @@ export class Color {
|
|
|
154
164
|
* ```
|
|
155
165
|
*/
|
|
156
166
|
rgbToHex(inputs) {
|
|
157
|
-
|
|
158
|
-
let
|
|
159
|
-
let
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
167
|
+
const resolved = resolveDto(Inputs.Color.RGBMinMaxDto, inputs);
|
|
168
|
+
let r = resolved.r;
|
|
169
|
+
let g = resolved.g;
|
|
170
|
+
let b = resolved.b;
|
|
171
|
+
if (resolved.max !== 255) {
|
|
172
|
+
r = Math.round(this.math.remap({ number: r, fromLow: resolved.min, fromHigh: resolved.max, toLow: 0, toHigh: 255 }));
|
|
173
|
+
g = Math.round(this.math.remap({ number: g, fromLow: resolved.min, fromHigh: resolved.max, toLow: 0, toHigh: 255 }));
|
|
174
|
+
b = Math.round(this.math.remap({ number: b, fromLow: resolved.min, fromHigh: resolved.max, toLow: 0, toHigh: 255 }));
|
|
164
175
|
}
|
|
165
176
|
const s = `#${Number(0x1000000 + r * 0x10000 + g * 0x100 + b).toString(16).substring(1, 7)}`;
|
|
166
177
|
return s;
|
|
@@ -182,7 +193,8 @@ export class Color {
|
|
|
182
193
|
* ```
|
|
183
194
|
*/
|
|
184
195
|
rgbObjToHex(inputs) {
|
|
185
|
-
|
|
196
|
+
const resolved = resolveDto(Inputs.Color.RGBObjectMaxDto, inputs);
|
|
197
|
+
return this.rgbToHex({ r: resolved.rgb.r, g: resolved.rgb.g, b: resolved.rgb.b, min: resolved.min, max: resolved.max });
|
|
186
198
|
}
|
|
187
199
|
/**
|
|
188
200
|
* Reads a hex color into an `{ r, g, b }` object with the channels remapped to a range of your
|
|
@@ -200,11 +212,12 @@ export class Color {
|
|
|
200
212
|
* ```
|
|
201
213
|
*/
|
|
202
214
|
hexToRgbMapped(inputs) {
|
|
203
|
-
const
|
|
215
|
+
const resolved = resolveDto(Inputs.Color.HexDtoMapped, inputs);
|
|
216
|
+
const rgb = this.hexToRgb(resolved);
|
|
204
217
|
return {
|
|
205
|
-
r: this.math.remap({ number: rgb.r, fromLow: 0, fromHigh: 255, toLow:
|
|
206
|
-
g: this.math.remap({ number: rgb.g, fromLow: 0, fromHigh: 255, toLow:
|
|
207
|
-
b: this.math.remap({ number: rgb.b, fromLow: 0, fromHigh: 255, toLow:
|
|
218
|
+
r: this.math.remap({ number: rgb.r, fromLow: 0, fromHigh: 255, toLow: resolved.from, toHigh: resolved.to }),
|
|
219
|
+
g: this.math.remap({ number: rgb.g, fromLow: 0, fromHigh: 255, toLow: resolved.from, toHigh: resolved.to }),
|
|
220
|
+
b: this.math.remap({ number: rgb.b, fromLow: 0, fromHigh: 255, toLow: resolved.from, toHigh: resolved.to }),
|
|
208
221
|
};
|
|
209
222
|
}
|
|
210
223
|
/**
|
|
@@ -222,7 +235,8 @@ export class Color {
|
|
|
222
235
|
* ```
|
|
223
236
|
*/
|
|
224
237
|
getRedParam(inputs) {
|
|
225
|
-
const
|
|
238
|
+
const resolved = resolveDto(Inputs.Color.HexDtoMapped, inputs);
|
|
239
|
+
const rgb = this.hexToRgbMapped(resolved);
|
|
226
240
|
return rgb.r;
|
|
227
241
|
}
|
|
228
242
|
/**
|
|
@@ -240,7 +254,8 @@ export class Color {
|
|
|
240
254
|
* ```
|
|
241
255
|
*/
|
|
242
256
|
getGreenParam(inputs) {
|
|
243
|
-
const
|
|
257
|
+
const resolved = resolveDto(Inputs.Color.HexDtoMapped, inputs);
|
|
258
|
+
const rgb = this.hexToRgbMapped(resolved);
|
|
244
259
|
return rgb.g;
|
|
245
260
|
}
|
|
246
261
|
/**
|
|
@@ -258,7 +273,8 @@ export class Color {
|
|
|
258
273
|
* ```
|
|
259
274
|
*/
|
|
260
275
|
getBlueParam(inputs) {
|
|
261
|
-
const
|
|
276
|
+
const resolved = resolveDto(Inputs.Color.HexDtoMapped, inputs);
|
|
277
|
+
const rgb = this.hexToRgbMapped(resolved);
|
|
262
278
|
return rgb.b;
|
|
263
279
|
}
|
|
264
280
|
/**
|
|
@@ -317,8 +333,9 @@ export class Color {
|
|
|
317
333
|
* ```
|
|
318
334
|
*/
|
|
319
335
|
invert(inputs) {
|
|
320
|
-
const
|
|
321
|
-
|
|
336
|
+
const resolved = resolveDto(Inputs.Color.InvertHexDto, inputs);
|
|
337
|
+
const { r, g, b } = this.hexToRgbMapped({ color: resolved.color, from: 0, to: 255 });
|
|
338
|
+
if (resolved.blackAndWhite) {
|
|
322
339
|
return (r * 0.299 + g * 0.587 + b * 0.114) > 186
|
|
323
340
|
? "#000000"
|
|
324
341
|
: "#ffffff";
|