@fxi/zartigl 0.9.2 → 0.10.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/dist/engine.d.ts CHANGED
@@ -1,3 +1,19 @@
1
+ /**
2
+ * Transparent ends of a ramp, as fractions of the ramp from each end: `low`
3
+ * fades the lowest values in from transparent, `high` fades the highest out.
4
+ */
5
+ export declare interface AlphaFade {
6
+ low?: number;
7
+ high?: number;
8
+ curve?: AlphaFadeCurve;
9
+ }
10
+
11
+ /** Alpha factor at ramp position `t` in [0, 1]; the stricter end wins. */
12
+ export declare function alphaFadeAt(t: number, fade: AlphaFade): number;
13
+
14
+ /** Shape of an alpha fade inside its zone; the same curves as `logScale`. */
15
+ export declare type AlphaFadeCurve = "linear" | "log" | "exp";
16
+
1
17
  /** Throws unless the index was written for this catalog entry and source. */
2
18
  export declare function assertGeoVideoIndexIdentity(source: CatalogGeoVideoArchiveSource, index: GeoVideoIndex, entry: CatalogEntry): void;
3
19
 
@@ -157,7 +173,10 @@ declare interface CoordArrays {
157
173
  longitude: Float32Array;
158
174
  }
159
175
 
160
- export declare function createColorRampTexture(gl: WebGL2RenderingContext, ramp?: ColorRampInput): WebGLTexture;
176
+ export declare function createColorRampTexture(gl: WebGL2RenderingContext, ramp?: ColorRampInput, options?: {
177
+ reverse?: boolean;
178
+ alphaFade?: AlphaFade;
179
+ }): WebGLTexture;
161
180
 
162
181
  /** The frame source decoding `manifest`: scalar or vector by its encoding. */
163
182
  export declare function createGeoVideoFrameSource(manifest: GeoVideoManifest, options?: {
@@ -527,7 +546,7 @@ export declare interface GeoVideoScalarEncoding {
527
546
  codeMax: number;
528
547
  valueMin: number;
529
548
  valueMax: number;
530
- transfer: "linear";
549
+ transfer: "linear" | "log10-1p9";
531
550
  colorSpace: "bt709";
532
551
  colorRange: "limited" | "full";
533
552
  }
@@ -549,9 +568,11 @@ export declare class GeoVideoScalarSource extends GeoVideoFrameSource<GeoVideoSc
549
568
  }
550
569
 
551
570
  /** Uniforms of GEOVIDEO_SCALAR_GLSL for a scalar-luma encoding. */
552
- export declare function geoVideoScalarUniforms(encoding: Pick<GeoVideoScalarEncoding, "codeMin" | "codeMax" | "valueMin" | "valueMax">): {
571
+ export declare function geoVideoScalarUniforms(encoding: Pick<GeoVideoScalarEncoding, "codeMin" | "codeMax" | "valueMin" | "valueMax"> & Partial<Pick<GeoVideoScalarEncoding, "transfer">>): {
553
572
  codeRange: [number, number];
554
573
  valueRange: [number, number];
574
+ /** `u_scalar_transfer`: 0 linear, 1 "log10-1p9". */
575
+ transfer: number;
555
576
  };
556
577
 
557
578
  declare interface GeoVideoSnapshotLoopTimeline {
@@ -624,7 +645,13 @@ export declare class GeoVideoVectorSource extends GeoVideoFrameSource<GeoVideoVe
624
645
  protected capture(video: HTMLVideoElement, rows: number, mask: Uint8Array): Promise<GeoVideoVectorFrame | null>;
625
646
  }
626
647
 
627
- export declare function getPalettes(): PaletteMeta[];
648
+ /**
649
+ * Palettes to offer, without deprecated ones (still resolvable for old
650
+ * configs) unless `includeDeprecated`.
651
+ */
652
+ export declare function getPalettes(options?: {
653
+ includeDeprecated?: boolean;
654
+ }): PaletteMeta[];
628
655
 
629
656
  /** Color grade of a style `particles.grade`; an object tunes the vibrant one. */
630
657
  export declare function gradeToColorGrade(grade: ParticleGrade | undefined): ColorGrade;
@@ -649,6 +676,7 @@ export declare const isHexColor: (value: unknown) => value is string;
649
676
  /** A partial style: any key left out takes the value below it. */
650
677
  declare interface LayerStyleInput {
651
678
  palette?: string;
679
+ reversePalette?: boolean;
652
680
  renderMode?: StyleRenderMode;
653
681
  particles?: ParticleStyleInput;
654
682
  raster?: Partial<RasterStyle>;
@@ -705,6 +733,12 @@ export declare interface PaletteMeta {
705
733
  colors: string[];
706
734
  }
707
735
 
736
+ /**
737
+ * Validate a time range from a JSON config: `{ start?, end? }` as ISO dates
738
+ * with start before end, or `{ trailing }` as a positive ISO 8601 duration.
739
+ */
740
+ export declare function parseTimeRange(value: unknown, path: string): TimeRange;
741
+
708
742
  /** Particle trail color grade: a preset, or the vibrant one tuned. */
709
743
  declare type ParticleGrade = "off" | "vibrant" | GradeTuning;
710
744
 
@@ -736,6 +770,17 @@ declare interface RasterStyle {
736
770
  vibrance: number;
737
771
  /** Fixed physical-value domain; null follows the data. */
738
772
  colorDomain: [number, number] | null;
773
+ /**
774
+ * Fraction of the color range, from its low end, over which colors fade in
775
+ * from transparent, [0, 1]: a field that is mostly zero (fires, heat
776
+ * stress) shows only where something happens. Values below the domain are
777
+ * transparent too.
778
+ */
779
+ alphaFadeLow: number;
780
+ /** Fraction of the color range, from its high end, fading out, [0, 1]. */
781
+ alphaFadeHigh: number;
782
+ /** Shape of both fades: "log" rises fast, "exp" stays faint longer. */
783
+ alphaFadeCurve: AlphaFadeCurve;
739
784
  }
740
785
 
741
786
  /**
@@ -752,18 +797,43 @@ export declare function resolveBackdrop(input?: Partial<BackdropStyle>): Backdro
752
797
  */
753
798
  export declare function resolveColorGrade(input?: Partial<ColorGrade>): ColorGrade;
754
799
 
800
+ /**
801
+ * Stops of a ramp, reversed on request, then with `alphaFade` multiplied into
802
+ * the alpha of its ends. The fade follows positions, not colors: on a reversed
803
+ * ramp it still fades the low values.
804
+ */
755
805
  export declare function resolveColorRamp(input: ColorRampInput, options?: {
756
806
  reverse?: boolean;
807
+ alphaFade?: AlphaFade;
757
808
  }): Record<number, string>;
758
809
 
759
810
  export declare type ScalarColorDomain = [number, number];
760
811
 
812
+ declare type StyleRenderMode = "particles" | "raster" | "raster+particles";
813
+
814
+ /** `anchor` minus an ISO 8601 duration, calendar months and years in UTC. */
815
+ export declare function subtractIsoDuration(anchor: number, duration: string): number;
816
+
761
817
  /**
762
- * Layer style: how a layer looks, with the same keys in the catalog
763
- * `defaults`, the engines and story views. Playback (how time moves) is not
764
- * part of it, so `particles.speed` is always the particle speed.
818
+ * Time windows shared by zartigl and the renderers built on its engine: a
819
+ * fixed `start`/`end`, either side open, or the `trailing` ISO 8601 duration
820
+ * before the latest available time.
765
821
  */
766
- declare type StyleRenderMode = "particles" | "raster" | "raster+particles";
822
+ export declare type TimeRange = {
823
+ start?: Date | string | number;
824
+ end?: Date | string | number;
825
+ trailing?: never;
826
+ } | {
827
+ trailing: string;
828
+ start?: never;
829
+ end?: never;
830
+ };
831
+
832
+ /**
833
+ * Bounds of `range` inside the available `[min, max]`, epoch ms: open sides
834
+ * take the available ones, `trailing` counts back from `max`.
835
+ */
836
+ export declare function timeRangeBounds(range: TimeRange, [sourceMin, sourceMax]: readonly [number, number]): [number, number];
767
837
 
768
838
  /**
769
839
  * Camera-aware per-frame fade opacity: eases toward a short retention while
package/dist/engine.js CHANGED
@@ -1,6 +1,6 @@
1
- import { F as i, H as u, I as m, G as v, T as g, J as x, b as f, K as _, c as p, L as V, M as G, l as C, y as S, D as b, N as O, O as R, n as L, t as A, z as h, A as y, C as F, m as I, B as T, P as k, Q as D, R as E, p as B, S as w, E as M, v as N } from "./geovideo-index-CzQo6UIG.js";
2
- import { B as z, C as H, e as K, b as U, d as J, c as Q, g as j, i as q, a as W, r as X } from "./backdrop-DctkJ45Q.js";
3
- var e = `vec3 applyVibrance(vec3 c, float v) {
1
+ import { I as i, J as u, K as m, G as v, T as g, L as f, M as x, b as _, N as p, c as V, O as G, P as C, l as S, z as b, E as R, Q as O, R as A, n as L, t as h, A as F, B as I, D as T, m as y, C as D, S as k, U as B, V as E, W as w, p as M, X as N, F as P, Y as z, H as U, v as H } from "./geovideo-index-BJjE_fgO.js";
2
+ import { B as J, C as Q, e as W, b as X, d as Y, c as j, g as q, i as Z, a as $, r as aa } from "./backdrop-DctkJ45Q.js";
3
+ var a = `vec3 applyVibrance(vec3 c, float v) {
4
4
  float mx = max(c.r, max(c.g, c.b));
5
5
  float mn = min(c.r, min(c.g, c.b));
6
6
  float boost = v * (1.0 - (mx - mn));
@@ -21,12 +21,18 @@ vec3 gradeColor(vec3 c, vec4 g) {
21
21
 
22
22
  c = mix(c, c * c * (3.0 - 2.0 * c), g.y);
23
23
  return clamp(applyVibrance(c, g.z), 0.0, 1.0);
24
- }`, a = `uniform vec2 u_code_range;
25
- uniform vec2 u_value_range;
24
+ }`, e = `uniform vec2 u_code_range;
25
+ uniform vec2 u_value_range;
26
+ uniform float u_scalar_transfer;
27
+
28
+ float geoVideoScalarCode(float r) {
29
+ return clamp((r - u_code_range.x) / (u_code_range.y - u_code_range.x), 0.0, 1.0);
30
+ }
26
31
 
27
32
  float geoVideoScalarValue(float r) {
28
- float code = clamp((r - u_code_range.x) / (u_code_range.y - u_code_range.x), 0.0, 1.0);
29
- return mix(u_value_range.x, u_value_range.y, code);
33
+ float code = geoVideoScalarCode(r);
34
+ float t = mix(code, (pow(10.0, code) - 1.0) / 9.0, u_scalar_transfer);
35
+ return mix(u_value_range.x, u_value_range.y, t);
30
36
  }`, o = `uint pcg(uint v) {
31
37
  uint state = v * 747796405u + 2891336453u;
32
38
  uint word = ((state >> ((state >> 28u) + 4u)) ^ state) * 277803737u;
@@ -42,12 +48,12 @@ float random(uvec3 v) {
42
48
  float luma = dot(c, vec3(0.299, 0.587, 0.114));
43
49
  return mix(vec3(luma), c, 1.0 + boost);
44
50
  }`;
45
- const n = r, c = e, t = o, s = a;
51
+ const n = r, c = a, t = o, s = e;
46
52
  export {
47
- z as BACKDROP_OFF,
53
+ J as BACKDROP_OFF,
48
54
  c as COLOR_GRADE_GLSL,
49
- H as COLOR_GRADE_OFF,
50
- K as COLOR_GRADE_VIBRANT,
55
+ Q as COLOR_GRADE_OFF,
56
+ W as COLOR_GRADE_VIBRANT,
51
57
  s as GEOVIDEO_SCALAR_GLSL,
52
58
  i as GeoVideoArchiveSource,
53
59
  u as GeoVideoFrameSource,
@@ -56,36 +62,40 @@ export {
56
62
  t as RANDOM_GLSL,
57
63
  g as TrailFade,
58
64
  n as VIBRANCE_GLSL,
65
+ f as alphaFadeAt,
59
66
  x as assertGeoVideoIndexIdentity,
60
- U as backdropVec4,
61
- J as colorGradeToGrade,
62
- Q as colorGradeVec4,
63
- f as createColorRampTexture,
64
- _ as createGeoVideoFrameSource,
65
- p as createProgram,
66
- V as createShader,
67
- G as fadeToFrames,
68
- C as fadeToOpacity,
69
- S as formatUnit,
70
- b as geoVideoChunkSources,
67
+ X as backdropVec4,
68
+ Y as colorGradeToGrade,
69
+ j as colorGradeVec4,
70
+ _ as createColorRampTexture,
71
+ p as createGeoVideoFrameSource,
72
+ V as createProgram,
73
+ G as createShader,
74
+ C as fadeToFrames,
75
+ S as fadeToOpacity,
76
+ b as formatUnit,
77
+ R as geoVideoChunkSources,
71
78
  O as geoVideoGrid,
72
- R as geoVideoIndexChunks,
79
+ A as geoVideoIndexChunks,
73
80
  L as geoVideoScalarUniforms,
74
- A as geoVideoTimelineValues,
75
- h as getPalettes,
76
- j as gradeToColorGrade,
77
- y as isGeoVideoArchiveSource,
78
- q as isHexColor,
79
- F as loadGeoVideoIndex,
80
- I as loadGeoVideoManifest,
81
- T as nextChunk,
81
+ h as geoVideoTimelineValues,
82
+ F as getPalettes,
83
+ q as gradeToColorGrade,
84
+ I as isGeoVideoArchiveSource,
85
+ Z as isHexColor,
86
+ T as loadGeoVideoIndex,
87
+ y as loadGeoVideoManifest,
88
+ D as nextChunk,
82
89
  k as nextChunkSpan,
83
- D as pairChunk,
90
+ B as pairChunk,
84
91
  E as pairChunkSpan,
85
- W as resolveBackdrop,
86
- X as resolveColorGrade,
87
- B as resolveColorRamp,
88
- w as validateGeoVideoIndex,
89
- M as validateGeoVideoManifest,
90
- N as validateScalarColorDomain
92
+ w as parseTimeRange,
93
+ $ as resolveBackdrop,
94
+ aa as resolveColorGrade,
95
+ M as resolveColorRamp,
96
+ N as subtractIsoDuration,
97
+ P as timeRangeBounds,
98
+ z as validateGeoVideoIndex,
99
+ U as validateGeoVideoManifest,
100
+ H as validateScalarColorDomain
91
101
  };