@weasel-js/paint 1.17.3 → 1.18.1
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 +45 -26
- package/dist/index.js +304 -305
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -152,6 +152,14 @@ declare function patternPlacementOf(paint: PatternPaint): PatternPlacement;
|
|
|
152
152
|
/** A tile paint's description of the tile alone, its placement left behind. */
|
|
153
153
|
declare function tileSpecOf(paint: TilePaint): TilePatternSpec;
|
|
154
154
|
|
|
155
|
+
/** Which way a polar space's hue goes between two endpoints, as CSS
|
|
156
|
+
* `hue-interpolation-method`: the arc of at most 180°, or the other one. */
|
|
157
|
+
type HueInterpolation = 'shorter' | 'longer';
|
|
158
|
+
/** The hue `t` of the way from `h1` to `h2`, in degrees, along the arc `method` names, in [0, 360). Both hues are
|
|
159
|
+
* taken into [0, 360) first, and a half turn keeps the sign of `h2 - h1`, as CSS's fixup does: 180° to 0° passes
|
|
160
|
+
* 90°. Equal hues stay put under `longer`, where CSS would go a full turn. */
|
|
161
|
+
declare function lerpHueDeg(h1: number, h2: number, t: number, method?: HueInterpolation): number;
|
|
162
|
+
|
|
155
163
|
/**
|
|
156
164
|
* Convert a 0..1 float sRGB triple to OKLab — the renderer's own color space,
|
|
157
165
|
* and what a caller holding a `resolveColor` result has. Rounds into the u8
|
|
@@ -237,9 +245,6 @@ declare function srgbToHsl(r: number, g: number, b: number): [number, number, nu
|
|
|
237
245
|
* which keeps its `'rgb'` spelling and its byte-precision paths.
|
|
238
246
|
*/
|
|
239
247
|
type ColorInterpolationSpace = 'oklch' | 'oklab' | 'hsl' | 'srgb' | 'srgb-linear';
|
|
240
|
-
/** Which way a polar space's hue goes between two endpoints, as CSS
|
|
241
|
-
* `hue-interpolation-method`: the arc of at most 180°, or the other one. */
|
|
242
|
-
type HueInterpolation = 'shorter' | 'longer';
|
|
243
248
|
/**
|
|
244
249
|
* Interpolate between two sRGB colors (0..1 floats) in `space`, at `t` in 0..1.
|
|
245
250
|
* Float precision throughout, with no byte round-trip. The result is sRGB;
|
|
@@ -568,23 +573,6 @@ interface StrokeNib {
|
|
|
568
573
|
* fraction of the width moving across it. */
|
|
569
574
|
ratio: number;
|
|
570
575
|
}
|
|
571
|
-
/**
|
|
572
|
-
* Inflate (positive) or deflate (negative) a rect to honor `align` when
|
|
573
|
-
* stroking it: the returned rect's center-aligned stroke coincides with the
|
|
574
|
-
* requested inner/outer-aligned stroke of the original. `width` is the
|
|
575
|
-
* stroke width (defaults to 1 to match canvas).
|
|
576
|
-
*/
|
|
577
|
-
declare function alignedStrokeRect(rect: {
|
|
578
|
-
x: number;
|
|
579
|
-
y: number;
|
|
580
|
-
width: number;
|
|
581
|
-
height: number;
|
|
582
|
-
}, align: StrokeAlign, width?: number): {
|
|
583
|
-
x: number;
|
|
584
|
-
y: number;
|
|
585
|
-
width: number;
|
|
586
|
-
height: number;
|
|
587
|
-
};
|
|
588
576
|
/**
|
|
589
577
|
* The named line styles a `Stroke.dash` array reads as.
|
|
590
578
|
*
|
|
@@ -749,6 +737,33 @@ declare function strokeHasInk(stroke: Stroke | null | undefined): stroke is Pain
|
|
|
749
737
|
*/
|
|
750
738
|
declare function strokeKey(stroke: Stroke | null | undefined): string;
|
|
751
739
|
|
|
740
|
+
/**
|
|
741
|
+
* Whether {@link alignedStrokeRect} draws `align` on `rect`: always, but for an
|
|
742
|
+
* inner stroke at least as wide as the rect's narrower side, which covers the
|
|
743
|
+
* whole rect where the shifted rect would turn inside out and draw outside it.
|
|
744
|
+
*/
|
|
745
|
+
declare function alignedStrokeRectHolds(rect: {
|
|
746
|
+
width: number;
|
|
747
|
+
height: number;
|
|
748
|
+
}, align: StrokeAlign, width?: number): boolean;
|
|
749
|
+
/**
|
|
750
|
+
* Inflate (positive) or deflate (negative) a rect to honor `align` when
|
|
751
|
+
* stroking it: the returned rect's center-aligned stroke coincides with the
|
|
752
|
+
* requested inner/outer-aligned stroke of the original. `width` is the
|
|
753
|
+
* stroke width (defaults to 1 to match canvas).
|
|
754
|
+
*/
|
|
755
|
+
declare function alignedStrokeRect(rect: {
|
|
756
|
+
x: number;
|
|
757
|
+
y: number;
|
|
758
|
+
width: number;
|
|
759
|
+
height: number;
|
|
760
|
+
}, align: StrokeAlign, width?: number): {
|
|
761
|
+
x: number;
|
|
762
|
+
y: number;
|
|
763
|
+
width: number;
|
|
764
|
+
height: number;
|
|
765
|
+
};
|
|
766
|
+
|
|
752
767
|
type Rgba = readonly [number, number, number, number];
|
|
753
768
|
/**
|
|
754
769
|
* `color-mix(in <space>, a p%, b)` for two 0..1 sRGBA colors, `p` as 0..1. The
|
|
@@ -826,8 +841,13 @@ declare function lerpStroke(a: Stroke | null | undefined, b: Stroke | null | und
|
|
|
826
841
|
* names none). `null` for anything else, a missing `#` included.
|
|
827
842
|
*/
|
|
828
843
|
declare function parseHexBytes(input: string): [number, number, number, number] | null;
|
|
844
|
+
/** The kit's one hex color writer: a 0..255 channel as two hex digits, rounded and clamped. */
|
|
845
|
+
declare function byteHex(v: number): string;
|
|
829
846
|
/** A hex color's red, green, and blue as 0..255, its alpha dropped. Throws on anything {@link parseHexBytes} does not read. */
|
|
830
847
|
declare function hexToRgbBytes(input: string): [number, number, number];
|
|
848
|
+
/** An RGBA pixel's bytes as `#rrggbb`, or `null` where it is fully transparent: the color a
|
|
849
|
+
* sampler reports for what is drawn at a point. Alpha is dropped, not composited. */
|
|
850
|
+
declare function rgbaHex(rgba: ArrayLike<number>): string | null;
|
|
831
851
|
|
|
832
852
|
/**
|
|
833
853
|
* Parse a CSS color string into [r, g, b, a] with 0..1 components.
|
|
@@ -850,9 +870,8 @@ declare function hexToRgbBytes(input: string): [number, number, number];
|
|
|
850
870
|
* returned tuple as read-only — mutation would corrupt the cache.
|
|
851
871
|
*/
|
|
852
872
|
declare function parseColor(input: string): [number, number, number, number];
|
|
853
|
-
/**
|
|
854
|
-
* callbacks, gradient ramp builds)
|
|
855
|
-
* cleared wholesale on overflow. */
|
|
873
|
+
/** `parseColor`, typed read-only: the form for renderer hot paths (per-frame
|
|
874
|
+
* draw callbacks, gradient ramp builds), which share its cache. */
|
|
856
875
|
declare function resolveColor(input: string): readonly [number, number, number, number];
|
|
857
876
|
/** Same as `parseColor` but returns integer 0..255 components. */
|
|
858
877
|
declare function parseColorToRgba255(input: string): [number, number, number, number];
|
|
@@ -906,7 +925,7 @@ declare function resolveGradientStops(stops: readonly GradStop[]): ResolvedGradi
|
|
|
906
925
|
*
|
|
907
926
|
* `space` is a gradient's `interpolate`. Alpha is linear in every space —
|
|
908
927
|
* only the color channels travel through OKLab or OKLCh. Returns transparent
|
|
909
|
-
* black for an empty list.
|
|
928
|
+
* black for an empty list; a NaN `t` reads as the first stop.
|
|
910
929
|
*/
|
|
911
930
|
declare function sampleResolvedStops(stops: readonly ResolvedGradientStop[], t: number, space?: ColorSpace): readonly [number, number, number, number];
|
|
912
931
|
/**
|
|
@@ -914,7 +933,7 @@ declare function sampleResolvedStops(stops: readonly ResolvedGradientStop[], t:
|
|
|
914
933
|
* sampling the GL ramp texture bakes, so an editor track and the painted
|
|
915
934
|
* gradient cannot disagree.
|
|
916
935
|
*
|
|
917
|
-
* Returns transparent black for an empty list.
|
|
936
|
+
* Returns transparent black (`#00000000`) for an empty list.
|
|
918
937
|
*/
|
|
919
938
|
declare function sampleGradientStops(stops: readonly GradStop[], t: number, space?: ColorSpace): string;
|
|
920
939
|
/**
|
|
@@ -1037,5 +1056,5 @@ declare function cssColorLiteral(css: string): ColorLiteral;
|
|
|
1037
1056
|
/** `#rrggbb` or `#rrggbbaa` as an `srgb` literal; `null` for anything else. */
|
|
1038
1057
|
declare function hexToColorLiteral(hex: string): ColorLiteral | null;
|
|
1039
1058
|
|
|
1040
|
-
export { INHERIT, MAX_DASH_RUNS, STROKE_DASH_RATIOS, TILE_KINDS, alignedStrokeRect, colorLiteralToCss, colorLiteralToHex, composePatternTransform, contrastLineColor, contrastRatio, cssColorLiteral, cssColorNotation, dashForStrokeStyle, dashPattern, dashPhase, decomposePatternTransform, fillHasInk, gradientForBounds, gradientGeometry, hexToColorLiteral, hexToOklchDeg, hexToRgbBytes, hexToRgba, hslToSrgb, interpolateSrgb, isGradientPaint, isImagePatternPaint, isPatternPaint, isSolidPaint, isTileKind, isTilePaint, lerpColorArray, lerpFill, lerpOklab, lerpOklch, lerpPaint, lerpStroke, linearSrgbToOklab, linearToSrgb, luminanceContrast, mixOklab, mixRgba, mixRgbaWeighted, normalizeHex, oklabToLinearSrgb, oklabToOklch, oklabToSrgbU8, oklchDegToHex, oklchToOklab, paintKey, parseColor, parseColorToRgba255, parseHexBytes, patternPlacementOf, relativeLuminance, resolveColor, resolveFill, resolveGradientStops, resolvePaletteColor, resolvePaletteColors, resolveScreenLength, resolveStroke, rgbaToHex, sampleGradientStops, sampleResolvedStops, scaleVertexWidth, scaledDash, srgbFloatToOklab, srgbToHsl, srgbToLinear, srgbU8ToOklab, strokeDashStyleOf, strokeHasInk, strokeKey, strokeTrimKey, tileSpecOf, tryNormalizeHex, vertexHalfWidths, vertexWidthFromSides, wcagLevels, widestHalfWidth, withGradientKind };
|
|
1059
|
+
export { INHERIT, MAX_DASH_RUNS, STROKE_DASH_RATIOS, TILE_KINDS, alignedStrokeRect, alignedStrokeRectHolds, byteHex, colorLiteralToCss, colorLiteralToHex, composePatternTransform, contrastLineColor, contrastRatio, cssColorLiteral, cssColorNotation, dashForStrokeStyle, dashPattern, dashPhase, decomposePatternTransform, fillHasInk, gradientForBounds, gradientGeometry, hexToColorLiteral, hexToOklchDeg, hexToRgbBytes, hexToRgba, hslToSrgb, interpolateSrgb, isGradientPaint, isImagePatternPaint, isPatternPaint, isSolidPaint, isTileKind, isTilePaint, lerpColorArray, lerpFill, lerpHueDeg, lerpOklab, lerpOklch, lerpPaint, lerpStroke, linearSrgbToOklab, linearToSrgb, luminanceContrast, mixOklab, mixRgba, mixRgbaWeighted, normalizeHex, oklabToLinearSrgb, oklabToOklch, oklabToSrgbU8, oklchDegToHex, oklchToOklab, paintKey, parseColor, parseColorToRgba255, parseHexBytes, patternPlacementOf, relativeLuminance, resolveColor, resolveFill, resolveGradientStops, resolvePaletteColor, resolvePaletteColors, resolveScreenLength, resolveStroke, rgbaHex, rgbaToHex, sampleGradientStops, sampleResolvedStops, scaleVertexWidth, scaledDash, srgbFloatToOklab, srgbToHsl, srgbToLinear, srgbU8ToOklab, strokeDashStyleOf, strokeHasInk, strokeKey, strokeTrimKey, tileSpecOf, tryNormalizeHex, vertexHalfWidths, vertexWidthFromSides, wcagLevels, widestHalfWidth, withGradientKind };
|
|
1041
1060
|
export type { ColorFn, ColorFnContext, ColorInterpolationSpace, ColorLiteral, ColorRef, ColorSeqFn, ColorSource, ColorSpace, CommandFill, CommandPaint, CommandPaintUnits, CommandStroke, ExternalColors, Fill, GradStop, GradientKind, GradientPaint, HalfWidths, HexForm, HueInterpolation, ImagePatternPaint, InCommandUnits, Inherit, KitMarkerKey, MarkerKey, MarkerRef, OklchDeg, Paint, PaintUnits, PaintedFill, PaintedStroke, Palette, PaletteEntry, PatternPaint, PatternPlacement, PatternTransform, PatternTransformParts, PosedPaint, Region, ResolvablePatternKind, ResolvedGradientStop, ScreenLength, SolidPaint, Stroke, StrokeAlign, StrokeDashStyle, StrokeNib, StrokeTrim, TextureHandle, TexturePaint, TileExtent, TileKind, TilePaint, TilePatternSpec, TrimAt, TrimPace, VertexWidth, VertexWidthSides };
|