@flare-engine/render 0.4.6 → 0.4.7

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 CHANGED
@@ -1,7 +1,6 @@
1
1
  import { Rect, Vec2 } from "@flare-engine/math";
2
2
  import { SkImageLike, SpriteFrame } from "@flare-engine/assets";
3
3
  import { ComponentDef, Query, World } from "@flare-engine/ecs";
4
- //#region src/camera2d.d.ts
5
4
  /** Camera follow smoothing options. */
6
5
  interface FollowOptions {
7
6
  /** Smoothing factor (0 = instant, lower = faster, default 0.1). */
@@ -16,7 +15,7 @@ interface FollowOptions {
16
15
  * Pure data + methods — no Skia dependency. The renderer reads camera state
17
16
  * to build the view transform.
18
17
  */
19
- declare class Camera2D {
18
+ export declare class Camera2D {
20
19
  /** Camera position (world-space center). */
21
20
  x: number;
22
21
  y: number;
@@ -86,8 +85,6 @@ declare class Camera2D {
86
85
  getBoundsInto(out: Rect): Rect;
87
86
  private _clampToBounds;
88
87
  }
89
- //#endregion
90
- //#region src/draw-order.d.ts
91
88
  /** A drawable item with a z-order for sorting. */
92
89
  interface Drawable {
93
90
  /** Z-index for draw ordering. Higher values draw on top. */
@@ -104,14 +101,12 @@ interface Drawable {
104
101
  * @param length Optional upper bound — when provided, only sorts `items[0..length)`.
105
102
  * Use this when passing a pooled array that may hold stale tail entries.
106
103
  */
107
- declare function sortByDrawOrder<T extends Drawable>(items: T[], length?: number): T[];
104
+ export declare function sortByDrawOrder<T extends Drawable>(items: T[], length?: number): T[];
108
105
  /**
109
106
  * Compare function for use with Array.sort when insertion sort isn't desired.
110
107
  * Stable relative order for equal z values (returns 0).
111
108
  */
112
- declare function drawOrderCompare(a: Drawable, b: Drawable): number;
113
- //#endregion
114
- //#region src/renderer.d.ts
109
+ export declare function drawOrderCompare(a: Drawable, b: Drawable): number;
115
110
  /** Minimal Skia Canvas-like interface for the Renderer. */
116
111
  interface CanvasLike {
117
112
  save(): number;
@@ -147,7 +142,7 @@ interface RenderStats {
147
142
  * Renderer — manages the Skia Canvas lifecycle for a frame.
148
143
  * `begin()` to start, draw your content, `end()` to finish.
149
144
  */
150
- declare class Renderer {
145
+ export declare class Renderer {
151
146
  /** Current frame stats. */
152
147
  readonly stats: RenderStats;
153
148
  private _canvas;
@@ -179,8 +174,6 @@ declare class Renderer {
179
174
  * flush run in SpriteBatch.flush. */
180
175
  recordBatch(): void;
181
176
  }
182
- //#endregion
183
- //#region src/sprite-effects.d.ts
184
177
  /** Color as RGBA (0-1 per channel). */
185
178
  interface SpriteColor {
186
179
  readonly r: number;
@@ -337,26 +330,26 @@ interface MountainHillsEffect extends SpriteEffect {
337
330
  /** Any concrete sprite effect. */
338
331
  type AnySpriteEffect = TintEffect | FlashEffect | GrayscaleEffect | OutlineEffect | CustomShaderEffect | WaterEffect | FogEffect | FireEffect | DropShadowEffect | RoofsCityEffect | ForestCanopyEffect | RiverWaveEffect | MoonCraterEffect | CaveInteriorEffect | MountainHillsEffect;
339
332
  /** Create a tint effect. */
340
- declare function tint(color: SpriteColor, amount: number): TintEffect;
333
+ export declare function tint(color: SpriteColor, amount: number): TintEffect;
341
334
  /** Create a flash effect. */
342
- declare function flash(color: SpriteColor, durationSec: number): FlashEffect;
335
+ export declare function flash(color: SpriteColor, durationSec: number): FlashEffect;
343
336
  /** Create a grayscale effect. */
344
- declare function grayscale(amount: number): GrayscaleEffect;
337
+ export declare function grayscale(amount: number): GrayscaleEffect;
345
338
  /** Create an outline effect. */
346
- declare function outline(color: SpriteColor, width: number): OutlineEffect;
339
+ export declare function outline(color: SpriteColor, width: number): OutlineEffect;
347
340
  /** Create a custom shader effect. `shader` must be pre-compiled; compiling
348
341
  * SkSL per frame is expensive. `uniforms` may be mutated externally between
349
342
  * frames to animate parameters. */
350
- declare function custom(shader: CompiledShader, uniforms: ShaderUniforms): CustomShaderEffect;
343
+ export declare function custom(shader: CompiledShader, uniforms: ShaderUniforms): CustomShaderEffect;
351
344
  /** Create a water surface effect. Time is passed to the renderer each frame
352
345
  * via `beginFrame(w, h, time)` — the effect itself is time-invariant. */
353
- declare function water(color: SpriteColor, foamColor: SpriteColor, waveSpeed: number, waveAmplitude: number): WaterEffect;
346
+ export declare function water(color: SpriteColor, foamColor: SpriteColor, waveSpeed: number, waveAmplitude: number): WaterEffect;
354
347
  /** Create a fog / volumetric haze effect. Time is passed to the renderer each
355
348
  * frame via `beginFrame(w, h, time)` — the effect itself is time-invariant. */
356
- declare function fog(color: SpriteColor, density?: number, speed?: number, scale?: number): FogEffect;
349
+ export declare function fog(color: SpriteColor, density?: number, speed?: number, scale?: number): FogEffect;
357
350
  /** Create a fire / flame effect. Time is passed to the renderer each
358
351
  * frame via `beginFrame(w, h, time)` — the effect itself is time-invariant. */
359
- declare function fire(opts: {
352
+ export declare function fire(opts: {
360
353
  color: SpriteColor;
361
354
  tipColor: SpriteColor;
362
355
  speed?: number;
@@ -364,14 +357,14 @@ declare function fire(opts: {
364
357
  }): FireEffect;
365
358
  /** Create a drop-shadow effect. Defaults to a soft shadow offset downward for
366
359
  * grounding; `color.a` is the shadow opacity. */
367
- declare function dropShadow(opts: {
360
+ export declare function dropShadow(opts: {
368
361
  color: SpriteColor;
369
362
  offsetX?: number;
370
363
  offsetY?: number;
371
364
  blur?: number;
372
365
  }): DropShadowEffect;
373
366
  /** Create a rooftop city skyline effect. */
374
- declare function roofsCity(opts: {
367
+ export declare function roofsCity(opts: {
375
368
  skyColor: SpriteColor;
376
369
  roofColor: SpriteColor;
377
370
  scrollOffsetY?: number;
@@ -380,7 +373,7 @@ declare function roofsCity(opts: {
380
373
  resolutionH?: number;
381
374
  }): RoofsCityEffect;
382
375
  /** Create a forest canopy effect. */
383
- declare function forestCanopy(opts: {
376
+ export declare function forestCanopy(opts: {
384
377
  skyColor: SpriteColor;
385
378
  leafColor: SpriteColor;
386
379
  scrollOffsetY?: number;
@@ -389,7 +382,7 @@ declare function forestCanopy(opts: {
389
382
  resolutionH?: number;
390
383
  }): ForestCanopyEffect;
391
384
  /** Create a river wave surface effect. */
392
- declare function riverWave(opts: {
385
+ export declare function riverWave(opts: {
393
386
  waterColor: SpriteColor;
394
387
  foamColor: SpriteColor;
395
388
  scrollOffsetY?: number;
@@ -398,7 +391,7 @@ declare function riverWave(opts: {
398
391
  resolutionH?: number;
399
392
  }): RiverWaveEffect;
400
393
  /** Create a moon crater surface effect. */
401
- declare function moonCrater(opts: {
394
+ export declare function moonCrater(opts: {
402
395
  moonColor: SpriteColor;
403
396
  craterColor: SpriteColor;
404
397
  scrollOffsetY?: number;
@@ -407,7 +400,7 @@ declare function moonCrater(opts: {
407
400
  resolutionH?: number;
408
401
  }): MoonCraterEffect;
409
402
  /** Create a cave interior effect. */
410
- declare function caveInterior(opts: {
403
+ export declare function caveInterior(opts: {
411
404
  caveColor: SpriteColor;
412
405
  glowColor: SpriteColor;
413
406
  scrollOffsetY?: number;
@@ -416,7 +409,7 @@ declare function caveInterior(opts: {
416
409
  resolutionH?: number;
417
410
  }): CaveInteriorEffect;
418
411
  /** Create a mountain / hill ridge effect. */
419
- declare function mountainHills(opts: {
412
+ export declare function mountainHills(opts: {
420
413
  skyColor: SpriteColor;
421
414
  hillColor: SpriteColor;
422
415
  scrollOffsetY?: number;
@@ -434,13 +427,11 @@ declare function mountainHills(opts: {
434
427
  * Effects are immutable — callers must replace their reference with the
435
428
  * returned value. Sharing an effect instance across entities is safe.
436
429
  */
437
- declare function updateEffect(effect: AnySpriteEffect, dt: number): AnySpriteEffect | null;
430
+ export declare function updateEffect(effect: AnySpriteEffect, dt: number): AnySpriteEffect | null;
438
431
  /**
439
432
  * Get the current intensity of a flash effect (1 at start, 0 at end).
440
433
  */
441
- declare function flashIntensity(effect: FlashEffect): number;
442
- //#endregion
443
- //#region src/sprite-batch.d.ts
434
+ export declare function flashIntensity(effect: FlashEffect): number;
444
435
  /**
445
436
  * Axis-aligned bounds used for viewport culling in the batch.
446
437
  * All coordinates are in the same space as the sprite destination rects.
@@ -531,7 +522,7 @@ interface SpriteDrawCommand {
531
522
  * The actual Skia Atlas draw call is delegated to a callback so this module
532
523
  * remains testable without Skia.
533
524
  */
534
- declare class SpriteBatch {
525
+ export declare class SpriteBatch {
535
526
  private _commands;
536
527
  private _pool;
537
528
  private _batches;
@@ -584,8 +575,6 @@ declare class SpriteBatch {
584
575
  clear(): void;
585
576
  private _acquire;
586
577
  }
587
- //#endregion
588
- //#region src/frame-renderer.d.ts
589
578
  /**
590
579
  * A mutable axis-aligned rect.
591
580
  *
@@ -757,9 +746,9 @@ interface FrameRenderer {
757
746
  * Both `@flare-engine/react` (passing the real RN-Skia module) and
758
747
  * `@flare-engine/render-web` (passing a CanvasKit shim) use this factory.
759
748
  */
760
- declare function createFrameRenderer(Skia: FrameRendererModule): FrameRenderer;
749
+ export declare function createFrameRenderer(Skia: FrameRendererModule): FrameRenderer;
761
750
  /** Zero both branch counters unconditionally (no __DEV__ guard). */
762
- declare function resetXformCounters(): void;
751
+ export declare function resetXformCounters(): void;
763
752
  /**
764
753
  * Cumulative `fillXforms` branch hit counts since the last reset. Both stay 0
765
754
  * when `__DEV__` is falsy or absent.
@@ -772,12 +761,10 @@ declare function resetXformCounters(): void;
772
761
  *
773
762
  * Allocates one object per call — never call it from the render loop.
774
763
  */
775
- declare function getXformCounters(): {
764
+ export declare function getXformCounters(): {
776
765
  rotated: number;
777
766
  unrotated: number;
778
767
  };
779
- //#endregion
780
- //#region src/nine-slice.d.ts
781
768
  /**
782
769
  * Draw a sprite using a 9-slice (scale-9) layout.
783
770
  *
@@ -809,9 +796,7 @@ declare function getXformCounters(): {
809
796
  * @param effect Optional sprite effect applied to every slice identically.
810
797
  * @param alpha Per-instance opacity multiplier in [0, 1]. Default 1.
811
798
  */
812
- declare function drawNineSlice(batch: SpriteBatch, image: SkImageLike, frame: SpriteFrame, x: number, y: number, w: number, h: number, inset: number, effect?: AnySpriteEffect, alpha?: number): void;
813
- //#endregion
814
- //#region src/render-system.d.ts
799
+ export declare function drawNineSlice(batch: SpriteBatch, image: SkImageLike, frame: SpriteFrame, x: number, y: number, w: number, h: number, inset: number, effect?: AnySpriteEffect, alpha?: number): void;
815
800
  /** Position component data expected by the render system. */
816
801
  interface PositionData {
817
802
  x: number;
@@ -889,22 +874,18 @@ interface SpriteData {
889
874
  * @param spriteDef ComponentDef for Sprite.
890
875
  * @param batch SpriteBatch instance to queue draws into.
891
876
  */
892
- declare function createRenderSystem(world: World, query: Query, positionDef: ComponentDef<PositionData>, spriteDef: ComponentDef<SpriteData>, batch: SpriteBatch): () => void;
877
+ export declare function createRenderSystem(world: World, query: Query, positionDef: ComponentDef<PositionData>, spriteDef: ComponentDef<SpriteData>, batch: SpriteBatch): () => void;
893
878
  /** Canonical Sprite component — queried by the render system alongside `Position`. */
894
- declare const Sprite: ComponentDef<SpriteData>;
895
- //#endregion
896
- //#region src/shaders.d.ts
897
- declare const FIRE_SKSL = "\nuniform float2 resolution;\nuniform float3 color;\nuniform float3 tipColor;\nuniform float speed;\nuniform float intensity;\nuniform float time;\n\nfloat hash(float2 p) { return fract(sin(dot(p, float2(127.1, 311.7))) * 43758.5453); }\n\nfloat vnoise(float2 p) {\n float2 i = floor(p);\n float2 f = fract(p);\n float2 u = f * f * (3.0 - 2.0 * f);\n float a = hash(i);\n float b = hash(i + float2(1.0, 0.0));\n float c = hash(i + float2(0.0, 1.0));\n float d = hash(i + float2(1.0, 1.0));\n return mix(mix(a, b, u.x), mix(c, d, u.x), u.y);\n}\n\nfloat fbm(float2 p) {\n return 0.5 * vnoise(p) + 0.25 * vnoise(p * 2.0);\n}\n\nhalf4 main(float2 coord) {\n float2 uv = coord / max(resolution, float2(1.0));\n float2 np = float2(uv.x * 4.0, uv.y * 6.0 - time * speed * 2.0);\n float n = fbm(np);\n float flameMask = smoothstep(0.0, intensity, n * (1.0 - uv.y));\n float3 fireRgb = mix(color, tipColor, uv.y);\n return half4(fireRgb.r, fireRgb.g, fireRgb.b, flameMask);\n}\n";
898
- declare const FOG_SKSL = "\nuniform float2 resolution;\nuniform float3 color;\nuniform float density;\nuniform float speed;\nuniform float scale;\nuniform float time;\n\nfloat hash(float2 p) {\n return fract(sin(dot(p, float2(127.1, 311.7))) * 43758.5453);\n}\n\nfloat valueNoise(float2 p) {\n float2 i = floor(p);\n float2 f = fract(p);\n float2 u = f * f * (3.0 - 2.0 * f);\n float a = hash(i);\n float b = hash(i + float2(1.0, 0.0));\n float c = hash(i + float2(0.0, 1.0));\n float d = hash(i + float2(1.0, 1.0));\n return mix(mix(a, b, u.x), mix(c, d, u.x), u.y);\n}\n\nfloat fbm(float2 p) {\n float value = 0.0;\n float amplitude = 0.5;\n for (int i = 0; i < 4; i++) {\n value += amplitude * valueNoise(p);\n p *= 2.0;\n amplitude *= 0.5;\n }\n return value;\n}\n\nhalf4 main(float2 coord) {\n float2 uv = coord / max(resolution, float2(1.0));\n float2 drift = float2(time * speed, 0.3 * time * speed);\n float n = clamp(fbm(uv * scale + drift), 0.0, 1.0);\n return half4(color.r, color.g, color.b, clamp(density * n, 0.0, 1.0));\n}\n";
899
- declare const WATER_SKSL = "\nuniform float2 resolution;\nuniform float3 color;\nuniform float3 foamColor;\nuniform float waveSpeed;\nuniform float waveAmplitude;\nuniform float time;\n\nhalf4 main(float2 coord) {\n float2 uv = coord / max(resolution, float2(1.0));\n float waveDeriv = cos(uv.x * 6.2832 * 3.0 + time * waveSpeed * 2.0) * waveAmplitude * 2.0\n + cos(uv.x * 6.2832 * 5.0 - time * waveSpeed * 1.3 + 1.5) * waveAmplitude;\n float foam = smoothstep(waveAmplitude * 0.6, waveAmplitude * 1.5, waveDeriv);\n half3 tinted = half3(color.r, color.g, color.b);\n half3 final = mix(tinted, half3(foamColor.r, foamColor.g, foamColor.b), half(foam));\n return half4(final, 1.0);\n}\n";
900
- declare const ROOFS_CITY_SKSL = "\nuniform float2 resolution;\nuniform float3 skyColor;\nuniform float3 roofColor;\nuniform float scrollOffsetY;\nuniform float density;\n\nfloat hash(float x) { return fract(sin(x * 127.1) * 43758.5453); }\n\nfloat buildingTop(float2 uv, float density) {\n float col = floor(uv.x * density);\n float h = 0.35 + 0.35 * hash(col);\n float w = 0.6 + 0.3 * hash(col + 7.3);\n float edge = step(abs(fract(uv.x * density) - 0.5), w * 0.5);\n return edge * step(uv.y, h);\n}\n\nhalf4 main(float2 coord) {\n float2 uv = coord / max(resolution, float2(1.0));\n uv.y = uv.y + scrollOffsetY / max(resolution.y, 1.0);\n uv.y = fract(uv.y);\n float buildings = buildingTop(uv, density);\n half3 col = mix(half3(skyColor.r, skyColor.g, skyColor.b),\n half3(roofColor.r, roofColor.g, roofColor.b),\n half(buildings));\n return half4(col, 1.0);\n}\n";
901
- declare const FOREST_CANOPY_SKSL = "\nuniform float2 resolution;\nuniform float3 skyColor;\nuniform float3 leafColor;\nuniform float scrollOffsetY;\nuniform float density;\n\nfloat hash(float2 p) { return fract(sin(dot(p, float2(127.1, 311.7))) * 43758.5453); }\n\nfloat valueNoise(float2 p) {\n float2 i = floor(p);\n float2 f = fract(p);\n float2 u = f * f * (3.0 - 2.0 * f);\n return mix(mix(hash(i), hash(i + float2(1.0, 0.0)), u.x),\n mix(hash(i + float2(0.0, 1.0)), hash(i + float2(1.0, 1.0)), u.x), u.y);\n}\n\nhalf4 main(float2 coord) {\n float2 uv = coord / max(resolution, float2(1.0));\n uv.y = uv.y + scrollOffsetY / max(resolution.y, 1.0);\n float n = valueNoise(float2(uv.x * density, uv.y * 3.0));\n float treeLine = 0.55 + 0.25 * valueNoise(float2(uv.x * density * 0.5, 0.0));\n float canopy = step(uv.y, treeLine) * smoothstep(0.3, 0.7, n);\n half3 col = mix(half3(skyColor.r, skyColor.g, skyColor.b),\n half3(leafColor.r, leafColor.g, leafColor.b),\n half(canopy));\n return half4(col, 1.0);\n}\n";
902
- declare const RIVER_WAVE_SKSL = "\nuniform float2 resolution;\nuniform float3 waterColor;\nuniform float3 foamColor;\nuniform float scrollOffsetY;\nuniform float waveScale;\n\nhalf4 main(float2 coord) {\n float2 uv = coord / max(resolution, float2(1.0));\n float scroll = scrollOffsetY / max(resolution.y, 1.0);\n float2 p = float2(uv.x, uv.y + scroll);\n float w1 = sin(p.x * 6.2832 * waveScale + p.y * 4.0) * 0.04;\n float w2 = sin(p.x * 6.2832 * waveScale * 1.7 - p.y * 2.5 + 1.2) * 0.02;\n float surface = 0.5 + w1 + w2;\n float inWater = step(uv.y, surface);\n float crest = smoothstep(surface - 0.015, surface, uv.y) * (1.0 - inWater) +\n smoothstep(surface + 0.015, surface, uv.y) * inWater;\n half3 base = mix(half3(foamColor.r, foamColor.g, foamColor.b),\n half3(waterColor.r, waterColor.g, waterColor.b),\n half(inWater));\n half3 col = mix(base, half3(foamColor.r, foamColor.g, foamColor.b), half(crest * 0.6));\n return half4(col, 1.0);\n}\n";
903
- declare const MOON_CRATER_SKSL = "\nuniform float2 resolution;\nuniform float3 moonColor;\nuniform float3 craterColor;\nuniform float scrollOffsetY;\nuniform float craterCount;\n\nfloat hash(float2 p) { return fract(sin(dot(p, float2(127.1, 311.7))) * 43758.5453); }\n\nfloat crater(float2 uv, float2 center, float r) {\n float d = length(uv - center);\n float rim = smoothstep(r, r * 0.85, d) - smoothstep(r * 0.85, r * 0.65, d);\n float floor_ = smoothstep(r * 0.65, r * 0.4, d);\n return rim * 0.6 + floor_ * 0.25;\n}\n\nhalf4 main(float2 coord) {\n float2 uv = coord / max(resolution, float2(1.0));\n uv.y = uv.y + scrollOffsetY / max(resolution.y, 1.0);\n float c = 0.0;\n for (int i = 0; i < 6; i++) {\n float fi = float(i);\n float2 center = float2(hash(float2(fi, 0.0)), hash(float2(fi, 1.0)));\n float r = 0.04 + 0.07 * hash(float2(fi, 2.0));\n c += crater(fract(uv), center, r) * step(fi, craterCount - 1.0);\n }\n c = clamp(c, 0.0, 1.0);\n half3 col = mix(half3(moonColor.r, moonColor.g, moonColor.b),\n half3(craterColor.r, craterColor.g, craterColor.b),\n half(c));\n return half4(col, 1.0);\n}\n";
904
- declare const CAVE_INTERIOR_SKSL = "\nuniform float2 resolution;\nuniform float3 caveColor;\nuniform float3 glowColor;\nuniform float scrollOffsetY;\nuniform float stalactiteCount;\n\nfloat hash(float x) { return fract(sin(x * 127.1) * 43758.5453); }\n\nfloat stalactite(float2 uv, float count) {\n float col = floor(uv.x * count);\n float tip = 0.1 + 0.2 * hash(col);\n float w = 0.3 + 0.3 * hash(col + 5.0);\n float dx = abs(fract(uv.x * count) - 0.5) / (w * 0.5);\n float shape = step(dx, 1.0) * step(uv.y, tip * (1.0 - clamp(dx, 0.0, 1.0)));\n return shape;\n}\n\nhalf4 main(float2 coord) {\n float2 uv = coord / max(resolution, float2(1.0));\n uv.y = 1.0 - uv.y;\n uv.y = uv.y + scrollOffsetY / max(resolution.y, 1.0);\n float stalac = stalactite(uv, stalactiteCount);\n float glow = smoothstep(0.8, 1.0, uv.y) * (1.0 - stalac);\n half3 col = mix(half3(caveColor.r, caveColor.g, caveColor.b),\n half3(glowColor.r, glowColor.g, glowColor.b),\n half(glow));\n col = mix(col, half3(caveColor.r, caveColor.g, caveColor.b) * half(0.3), half(stalac));\n return half4(col, 1.0);\n}\n";
905
- declare const MOUNTAIN_HILLS_SKSL = "\nuniform float2 resolution;\nuniform float3 skyColor;\nuniform float3 hillColor;\nuniform float scrollOffsetY;\nuniform float ridgeScale;\n\nfloat hash(float x) { return fract(sin(x * 127.1) * 43758.5453); }\n\nfloat heightField(float x, float scale) {\n float h = 0.0;\n float amp = 0.5;\n float freq = scale;\n for (int i = 0; i < 4; i++) {\n float ix = floor(x * freq);\n float fx = fract(x * freq);\n fx = fx * fx * (3.0 - 2.0 * fx);\n h += amp * mix(hash(ix), hash(ix + 1.0), fx);\n freq *= 2.0;\n amp *= 0.5;\n }\n return h;\n}\n\nhalf4 main(float2 coord) {\n float2 uv = coord / max(resolution, float2(1.0));\n float scroll = scrollOffsetY / max(resolution.y, 1.0);\n float horizon = 0.4 + 0.3 * heightField(uv.x + scroll * 0.3, ridgeScale);\n float mountains = step(uv.y, horizon);\n half3 col = mix(half3(skyColor.r, skyColor.g, skyColor.b),\n half3(hillColor.r, hillColor.g, hillColor.b),\n half(mountains));\n return half4(col, 1.0);\n}\n";
906
- //#endregion
907
- //#region src/sprite-font.d.ts
879
+ export declare const Sprite: ComponentDef<SpriteData>;
880
+ export declare const FIRE_SKSL = "\nuniform float2 resolution;\nuniform float3 color;\nuniform float3 tipColor;\nuniform float speed;\nuniform float intensity;\nuniform float time;\n\nfloat hash(float2 p) { return fract(sin(dot(p, float2(127.1, 311.7))) * 43758.5453); }\n\nfloat vnoise(float2 p) {\n float2 i = floor(p);\n float2 f = fract(p);\n float2 u = f * f * (3.0 - 2.0 * f);\n float a = hash(i);\n float b = hash(i + float2(1.0, 0.0));\n float c = hash(i + float2(0.0, 1.0));\n float d = hash(i + float2(1.0, 1.0));\n return mix(mix(a, b, u.x), mix(c, d, u.x), u.y);\n}\n\nfloat fbm(float2 p) {\n return 0.5 * vnoise(p) + 0.25 * vnoise(p * 2.0);\n}\n\nhalf4 main(float2 coord) {\n float2 uv = coord / max(resolution, float2(1.0));\n float2 np = float2(uv.x * 4.0, uv.y * 6.0 - time * speed * 2.0);\n float n = fbm(np);\n float flameMask = smoothstep(0.0, intensity, n * (1.0 - uv.y));\n float3 fireRgb = mix(color, tipColor, uv.y);\n return half4(fireRgb.r, fireRgb.g, fireRgb.b, flameMask);\n}\n";
881
+ export declare const FOG_SKSL = "\nuniform float2 resolution;\nuniform float3 color;\nuniform float density;\nuniform float speed;\nuniform float scale;\nuniform float time;\n\nfloat hash(float2 p) {\n return fract(sin(dot(p, float2(127.1, 311.7))) * 43758.5453);\n}\n\nfloat valueNoise(float2 p) {\n float2 i = floor(p);\n float2 f = fract(p);\n float2 u = f * f * (3.0 - 2.0 * f);\n float a = hash(i);\n float b = hash(i + float2(1.0, 0.0));\n float c = hash(i + float2(0.0, 1.0));\n float d = hash(i + float2(1.0, 1.0));\n return mix(mix(a, b, u.x), mix(c, d, u.x), u.y);\n}\n\nfloat fbm(float2 p) {\n float value = 0.0;\n float amplitude = 0.5;\n for (int i = 0; i < 4; i++) {\n value += amplitude * valueNoise(p);\n p *= 2.0;\n amplitude *= 0.5;\n }\n return value;\n}\n\nhalf4 main(float2 coord) {\n float2 uv = coord / max(resolution, float2(1.0));\n float2 drift = float2(time * speed, 0.3 * time * speed);\n float n = clamp(fbm(uv * scale + drift), 0.0, 1.0);\n return half4(color.r, color.g, color.b, clamp(density * n, 0.0, 1.0));\n}\n";
882
+ export declare const WATER_SKSL = "\nuniform float2 resolution;\nuniform float3 color;\nuniform float3 foamColor;\nuniform float waveSpeed;\nuniform float waveAmplitude;\nuniform float time;\n\nhalf4 main(float2 coord) {\n float2 uv = coord / max(resolution, float2(1.0));\n float waveDeriv = cos(uv.x * 6.2832 * 3.0 + time * waveSpeed * 2.0) * waveAmplitude * 2.0\n + cos(uv.x * 6.2832 * 5.0 - time * waveSpeed * 1.3 + 1.5) * waveAmplitude;\n float foam = smoothstep(waveAmplitude * 0.6, waveAmplitude * 1.5, waveDeriv);\n half3 tinted = half3(color.r, color.g, color.b);\n half3 final = mix(tinted, half3(foamColor.r, foamColor.g, foamColor.b), half(foam));\n return half4(final, 1.0);\n}\n";
883
+ export declare const ROOFS_CITY_SKSL = "\nuniform float2 resolution;\nuniform float3 skyColor;\nuniform float3 roofColor;\nuniform float scrollOffsetY;\nuniform float density;\n\nfloat hash(float x) { return fract(sin(x * 127.1) * 43758.5453); }\n\nfloat buildingTop(float2 uv, float density) {\n float col = floor(uv.x * density);\n float h = 0.35 + 0.35 * hash(col);\n float w = 0.6 + 0.3 * hash(col + 7.3);\n float edge = step(abs(fract(uv.x * density) - 0.5), w * 0.5);\n return edge * step(uv.y, h);\n}\n\nhalf4 main(float2 coord) {\n float2 uv = coord / max(resolution, float2(1.0));\n uv.y = uv.y + scrollOffsetY / max(resolution.y, 1.0);\n uv.y = fract(uv.y);\n float buildings = buildingTop(uv, density);\n half3 col = mix(half3(skyColor.r, skyColor.g, skyColor.b),\n half3(roofColor.r, roofColor.g, roofColor.b),\n half(buildings));\n return half4(col, 1.0);\n}\n";
884
+ export declare const FOREST_CANOPY_SKSL = "\nuniform float2 resolution;\nuniform float3 skyColor;\nuniform float3 leafColor;\nuniform float scrollOffsetY;\nuniform float density;\n\nfloat hash(float2 p) { return fract(sin(dot(p, float2(127.1, 311.7))) * 43758.5453); }\n\nfloat valueNoise(float2 p) {\n float2 i = floor(p);\n float2 f = fract(p);\n float2 u = f * f * (3.0 - 2.0 * f);\n return mix(mix(hash(i), hash(i + float2(1.0, 0.0)), u.x),\n mix(hash(i + float2(0.0, 1.0)), hash(i + float2(1.0, 1.0)), u.x), u.y);\n}\n\nhalf4 main(float2 coord) {\n float2 uv = coord / max(resolution, float2(1.0));\n uv.y = uv.y + scrollOffsetY / max(resolution.y, 1.0);\n float n = valueNoise(float2(uv.x * density, uv.y * 3.0));\n float treeLine = 0.55 + 0.25 * valueNoise(float2(uv.x * density * 0.5, 0.0));\n float canopy = step(uv.y, treeLine) * smoothstep(0.3, 0.7, n);\n half3 col = mix(half3(skyColor.r, skyColor.g, skyColor.b),\n half3(leafColor.r, leafColor.g, leafColor.b),\n half(canopy));\n return half4(col, 1.0);\n}\n";
885
+ export declare const RIVER_WAVE_SKSL = "\nuniform float2 resolution;\nuniform float3 waterColor;\nuniform float3 foamColor;\nuniform float scrollOffsetY;\nuniform float waveScale;\n\nhalf4 main(float2 coord) {\n float2 uv = coord / max(resolution, float2(1.0));\n float scroll = scrollOffsetY / max(resolution.y, 1.0);\n float2 p = float2(uv.x, uv.y + scroll);\n float w1 = sin(p.x * 6.2832 * waveScale + p.y * 4.0) * 0.04;\n float w2 = sin(p.x * 6.2832 * waveScale * 1.7 - p.y * 2.5 + 1.2) * 0.02;\n float surface = 0.5 + w1 + w2;\n float inWater = step(uv.y, surface);\n float crest = smoothstep(surface - 0.015, surface, uv.y) * (1.0 - inWater) +\n smoothstep(surface + 0.015, surface, uv.y) * inWater;\n half3 base = mix(half3(foamColor.r, foamColor.g, foamColor.b),\n half3(waterColor.r, waterColor.g, waterColor.b),\n half(inWater));\n half3 col = mix(base, half3(foamColor.r, foamColor.g, foamColor.b), half(crest * 0.6));\n return half4(col, 1.0);\n}\n";
886
+ export declare const MOON_CRATER_SKSL = "\nuniform float2 resolution;\nuniform float3 moonColor;\nuniform float3 craterColor;\nuniform float scrollOffsetY;\nuniform float craterCount;\n\nfloat hash(float2 p) { return fract(sin(dot(p, float2(127.1, 311.7))) * 43758.5453); }\n\nfloat crater(float2 uv, float2 center, float r) {\n float d = length(uv - center);\n float rim = smoothstep(r, r * 0.85, d) - smoothstep(r * 0.85, r * 0.65, d);\n float floor_ = smoothstep(r * 0.65, r * 0.4, d);\n return rim * 0.6 + floor_ * 0.25;\n}\n\nhalf4 main(float2 coord) {\n float2 uv = coord / max(resolution, float2(1.0));\n uv.y = uv.y + scrollOffsetY / max(resolution.y, 1.0);\n float c = 0.0;\n for (int i = 0; i < 6; i++) {\n float fi = float(i);\n float2 center = float2(hash(float2(fi, 0.0)), hash(float2(fi, 1.0)));\n float r = 0.04 + 0.07 * hash(float2(fi, 2.0));\n c += crater(fract(uv), center, r) * step(fi, craterCount - 1.0);\n }\n c = clamp(c, 0.0, 1.0);\n half3 col = mix(half3(moonColor.r, moonColor.g, moonColor.b),\n half3(craterColor.r, craterColor.g, craterColor.b),\n half(c));\n return half4(col, 1.0);\n}\n";
887
+ export declare const CAVE_INTERIOR_SKSL = "\nuniform float2 resolution;\nuniform float3 caveColor;\nuniform float3 glowColor;\nuniform float scrollOffsetY;\nuniform float stalactiteCount;\n\nfloat hash(float x) { return fract(sin(x * 127.1) * 43758.5453); }\n\nfloat stalactite(float2 uv, float count) {\n float col = floor(uv.x * count);\n float tip = 0.1 + 0.2 * hash(col);\n float w = 0.3 + 0.3 * hash(col + 5.0);\n float dx = abs(fract(uv.x * count) - 0.5) / (w * 0.5);\n float shape = step(dx, 1.0) * step(uv.y, tip * (1.0 - clamp(dx, 0.0, 1.0)));\n return shape;\n}\n\nhalf4 main(float2 coord) {\n float2 uv = coord / max(resolution, float2(1.0));\n uv.y = 1.0 - uv.y;\n uv.y = uv.y + scrollOffsetY / max(resolution.y, 1.0);\n float stalac = stalactite(uv, stalactiteCount);\n float glow = smoothstep(0.8, 1.0, uv.y) * (1.0 - stalac);\n half3 col = mix(half3(caveColor.r, caveColor.g, caveColor.b),\n half3(glowColor.r, glowColor.g, glowColor.b),\n half(glow));\n col = mix(col, half3(caveColor.r, caveColor.g, caveColor.b) * half(0.3), half(stalac));\n return half4(col, 1.0);\n}\n";
888
+ export declare const MOUNTAIN_HILLS_SKSL = "\nuniform float2 resolution;\nuniform float3 skyColor;\nuniform float3 hillColor;\nuniform float scrollOffsetY;\nuniform float ridgeScale;\n\nfloat hash(float x) { return fract(sin(x * 127.1) * 43758.5453); }\n\nfloat heightField(float x, float scale) {\n float h = 0.0;\n float amp = 0.5;\n float freq = scale;\n for (int i = 0; i < 4; i++) {\n float ix = floor(x * freq);\n float fx = fract(x * freq);\n fx = fx * fx * (3.0 - 2.0 * fx);\n h += amp * mix(hash(ix), hash(ix + 1.0), fx);\n freq *= 2.0;\n amp *= 0.5;\n }\n return h;\n}\n\nhalf4 main(float2 coord) {\n float2 uv = coord / max(resolution, float2(1.0));\n float scroll = scrollOffsetY / max(resolution.y, 1.0);\n float horizon = 0.4 + 0.3 * heightField(uv.x + scroll * 0.3, ridgeScale);\n float mountains = step(uv.y, horizon);\n half3 col = mix(half3(skyColor.r, skyColor.g, skyColor.b),\n half3(hillColor.r, hillColor.g, hillColor.b),\n half(mountains));\n return half4(col, 1.0);\n}\n";
908
889
  /** A single glyph in a bitmap font. */
909
890
  interface Glyph {
910
891
  /** Character code (Unicode). */
@@ -940,16 +921,15 @@ interface BitmapFont {
940
921
  /**
941
922
  * Parse BMFont JSON format (common output from tools like Hiero, BMFont, msdf-bmfont).
942
923
  */
943
- declare function parseBMFontJSON(json: unknown): BitmapFont;
924
+ export declare function parseBMFontJSON(json: unknown): BitmapFont;
944
925
  /** Get kerning between two characters. */
945
- declare function getKerning(font: BitmapFont, first: number, second: number): number;
926
+ export declare function getKerning(font: BitmapFont, first: number, second: number): number;
946
927
  /** Measure the width of a text string in pixels. */
947
- declare function measureText(font: BitmapFont, text: string): number;
928
+ export declare function measureText(font: BitmapFont, text: string): number;
948
929
  /**
949
930
  * Draw text using a SpriteBatch.
950
931
  * Characters are batched as individual sprites from the font texture.
951
932
  */
952
- declare function drawText(batch: SpriteBatch, font: BitmapFont, image: SkImageLike, text: string, x: number, y: number, scale?: number): void;
953
- //#endregion
954
- export { type AnySpriteEffect, type BatchCullBounds, type BitmapFont, CAVE_INTERIOR_SKSL, Camera2D, type CanvasLike, type CaveInteriorEffect, type ColorFilterFactoryLike, type CompiledShader, type CustomShaderEffect, type DrawSurfaceLike, type Drawable, type DropShadowEffect, FIRE_SKSL, FOG_SKSL, FOREST_CANOPY_SKSL, type FireEffect, type FlashEffect, type FogEffect, type FollowOptions, type ForestCanopyEffect, type FrameRenderer, type FrameRendererCompiledPass, type FrameRendererModule, type FrameRendererPostFxChain, type FrameRendererPostFxDescriptor, type FrameRendererPostFxRuntime, type Glyph, type GrayscaleEffect, type ImageFilterFactoryLike, type KerningPair, MOON_CRATER_SKSL, MOUNTAIN_HILLS_SKSL, type MoonCraterEffect, type MountainHillsEffect, type OutlineEffect, type PaintLike, type PictureLike, type PictureRecorderLike, type PositionData, RIVER_WAVE_SKSL, ROOFS_CITY_SKSL, type RSXformLike, type RectLike, type RenderStats, Renderer, type RiverWaveEffect, type RoofsCityEffect, type RuntimeEffectFactoryLike, type RuntimeEffectLike, type ShaderUniforms, Sprite, type SpriteAnchor, SpriteBatch, type SpriteColor, type SpriteData, type SpriteDrawCommand, type SpriteEffect, type TintEffect, WATER_SKSL, type WaterEffect, caveInterior, createFrameRenderer, createRenderSystem, custom, drawNineSlice, drawOrderCompare, drawText, dropShadow, fire, flash, flashIntensity, fog, forestCanopy, getKerning, getXformCounters, grayscale, measureText, moonCrater, mountainHills, outline, parseBMFontJSON, resetXformCounters, riverWave, roofsCity, sortByDrawOrder, tint, updateEffect, water };
933
+ export declare function drawText(batch: SpriteBatch, font: BitmapFont, image: SkImageLike, text: string, x: number, y: number, scale?: number): void;
934
+ export type { AnySpriteEffect, BatchCullBounds, BitmapFont, CanvasLike, CaveInteriorEffect, ColorFilterFactoryLike, CompiledShader, CustomShaderEffect, DrawSurfaceLike, Drawable, DropShadowEffect, FireEffect, FlashEffect, FogEffect, FollowOptions, ForestCanopyEffect, FrameRenderer, FrameRendererCompiledPass, FrameRendererModule, FrameRendererPostFxChain, FrameRendererPostFxDescriptor, FrameRendererPostFxRuntime, Glyph, GrayscaleEffect, ImageFilterFactoryLike, KerningPair, MoonCraterEffect, MountainHillsEffect, OutlineEffect, PaintLike, PictureLike, PictureRecorderLike, PositionData, RSXformLike, RectLike, RenderStats, RiverWaveEffect, RoofsCityEffect, RuntimeEffectFactoryLike, RuntimeEffectLike, ShaderUniforms, SpriteAnchor, SpriteColor, SpriteData, SpriteDrawCommand, SpriteEffect, TintEffect, WaterEffect };
955
935
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/camera2d.ts","../src/draw-order.ts","../src/renderer.ts","../src/sprite-effects.ts","../src/sprite-batch.ts","../src/frame-renderer.ts","../src/nine-slice.ts","../src/render-system.ts","../src/shaders.ts","../src/sprite-font.ts"],"mappings":";;;;;UAGiB;;EAEf;;EAEA,SAAS;;EAET,WAAW;;;;;;;cAiGA;;EAEX;EACA;;EAGA;;EAGA;;EAGA;;EAGA;;EAGA,QAAQ;UAEA;UACA;UACA;UACA;UACA;UACA;;EAGR,YAAY,eAAe;;EAM3B,OAAO,QAAQ,MAAM,UAAU;;EAK/B;;;;;;;;;;;;EAeA,eAAe;;MAKX;;EAKJ,MAAM,mBAAmB;;;;;EAoBzB,YAAY,mBAAmB;;;;;EAoB/B,OAAO;;MAuEH;;MAKA;;EAKJ,cAAc,gBAAgB,iBAAiB;;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ACA;EACA;;EAEA;EACA;;EAEA;;;UAIe;EACf;EACA;EACA;;;UAIe;;EAEf;;EAEA;;EAEA,QAAQ,YAAY;;EAEpB,UAAU;;;;;iBAMI,gBAAgB,gBAAgB;;iBA8ChC,WAAW,MAAM,YAAY,eAAe;;iBAK5C,YAAY,MAAM,YAAY;;;;;iBAoB9B,SACd,OAAO,aACP,MAAM,YACN,OAAO,aACP,cACA,WACA,WACA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/camera2d.ts","../src/draw-order.ts","../src/renderer.ts","../src/sprite-effects.ts","../src/sprite-batch.ts","../src/frame-renderer.ts","../src/nine-slice.ts","../src/render-system.ts","../src/shaders.ts","../src/sprite-font.ts"],"mappings":";;;;UAGiB;;EAEf;;EAEA,SAAS;;EAET,WAAW;;;;;;;qBAiGA;;EAEX;EACA;;EAGA;;EAGA;;EAGA;;EAGA;;EAGA,QAAQ;UAEA;UACA;UACA;UACA;UACA;UACA;;EAGR,YAAY,eAAe;;EAM3B,OAAO,QAAQ,MAAM,UAAU;;EAK/B;;;;;;;;;;;;EAeA,eAAe;;MAKX;;EAKJ,MAAM,mBAAmB;;;;;EAoBzB,YAAY,mBAAmB;;;;;EAoB/B,OAAO;;MAuEH;;MAKA;;EAKJ,cAAc,gBAAgB,iBAAiB;;EAK/C,kBAAkB,gBAAgB,gBAAgB,KAAK,OAAO;;EAW9D,cAAc,iBAAiB,kBAAkB;;EAKjD,kBAAkB,iBAAiB,iBAAiB,KAAK,OAAO;;EAahE,aAAa;;EAKb,cAAc,KAAK,OAAO;UAUlB;;;UCnVO;;EAEf;;;;;;;;;;;;;wBAcc,gBAAgB,UAAU,UAAU,OAAO,KAAK,kBAAkB;;;;;wBAmBlE,iBAAiB,GAAG,UAAU,GAAG;;UCnChC;EACf;EACA;EACA,UAAU,WAAW;EACrB,MAAM,YAAY;;EAElB,OAAO,iBAAiB,YAAY;EACpC,MAAM;;;UAIS;;;;;;;;;;EAUf;;;;;;;;EAQA;;;;;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;;;;UAWM;WACN,QAAQ;EACjB,WACE,uBACA,wBACA,eACA;EAEF,UAAU,OAAO,aAAa,UAAU;EACxC,kBACE,SAAS,mCACT,OAAO,iCACP,eACA,0BACU;EACZ,iBACE,SAAS,mCACT,OAAO;;;;;;EAOT;EACA,YAAY;;;;;;;;wBAsCE,oBAAoB,MAAM,sBAAsB;;wBAgqBhD;;;;;;;;;;;;;wBAiBA;EAAsB;EAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBC17BvC,cACd,OAAO,aACP,OAAO,aACP,OAAO,aACP,WACA,WACA,WACA,WACA,eACA,SAAS,iBACT;;UCrCe;EACf;EACA;;;;;;UAOe;EACf;EACA;;;UAIe;EACf,OAAO;EACP,OAAO;EACP;EACA;EACA;;;;EAIA,SAAS;;EAET,SAAS;;;;EAIT;;;;EAIA;;;;;;;;;;;EAWA;;;;;;;EAOA;;;;EAIA;;EAEA;;;;;;;;;;;;;;;;;;;;wBA2Bc,mBACd,OAAO,OACP,OAAO,OACP,aAAa,aAAa,eAC1B,WAAW,aAAa,aACxB,OAAO;;qBA6DI,QAAM,aAAA;qBC/JN;qBAmCA;qBA0CA;qBA0BA;qBA6BA;qBA8BA;qBAyBA;qBAkCA;qBAgCA;;UCzPI;;EAEf;;EAEA;EACA;EACA;EACA;;EAEA;EACA;;EAEA;;;UAIe;EACf;EACA;EACA;;;UAIe;;EAEf;;EAEA;;EAEA,QAAQ,YAAY;;EAEpB,UAAU;;;;;wBAMI,gBAAgB,gBAAgB;;wBA8ChC,WAAW,MAAM,YAAY,eAAe;;wBAK5C,YAAY,MAAM,YAAY;;;;;wBAoB9B,SACd,OAAO,aACP,MAAM,YACN,OAAO,aACP,cACA,WACA,WACA"}
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  let _flare_engine_ecs = require("@flare-engine/ecs");
3
- //#region src/camera2d.ts
3
+ // src/camera2d.ts
4
4
  /** Simple pseudo-random for deterministic shake. Avoids Math.random() allocs. */
5
5
  function pseudoRandom(seed) {
6
6
  const x = Math.sin(seed * 12.9898 + seed * 78.233) * 43758.5453;
@@ -284,8 +284,7 @@ var Camera2D = class {
284
284
  else this.y = b.y + b.height / 2;
285
285
  }
286
286
  };
287
- //#endregion
288
- //#region src/draw-order.ts
287
+ // src/draw-order.ts
289
288
  /**
290
289
  * Sort an array of drawables by z-index (ascending = back to front).
291
290
  * Uses insertion sort which is fast for nearly-sorted arrays
@@ -317,8 +316,7 @@ function sortByDrawOrder(items, length) {
317
316
  function drawOrderCompare(a, b) {
318
317
  return a.z - b.z;
319
318
  }
320
- //#endregion
321
- //#region src/shaders.ts
319
+ // src/shaders.ts
322
320
  const FIRE_SKSL = `
323
321
  uniform float2 resolution;
324
322
  uniform float3 color;
@@ -592,8 +590,7 @@ half4 main(float2 coord) {
592
590
  return half4(col, 1.0);
593
591
  }
594
592
  `;
595
- //#endregion
596
- //#region src/sprite-effects.ts
593
+ // src/sprite-effects.ts
597
594
  /** Create a tint effect. */
598
595
  function tint(color, amount) {
599
596
  return {
@@ -783,8 +780,7 @@ function flashIntensity(effect) {
783
780
  const t = effect.elapsed / effect.duration;
784
781
  return Math.max(0, 1 - t);
785
782
  }
786
- //#endregion
787
- //#region src/frame-renderer.ts
783
+ // src/frame-renderer.ts
788
784
  /** See the dev-flag note at the top of this file. */
789
785
  const G = globalThis;
790
786
  const BLEND_SRC_OVER = 3;
@@ -1457,8 +1453,7 @@ function fillCustomUniforms(effect, shader, out) {
1457
1453
  for (let k = 0; k < size; k++) out[info.slot + k] = value[k] ?? 0;
1458
1454
  }
1459
1455
  }
1460
- //#endregion
1461
- //#region src/nine-slice.ts
1456
+ // src/nine-slice.ts
1462
1457
  /**
1463
1458
  * Draw a sprite using a 9-slice (scale-9) layout.
1464
1459
  *
@@ -1521,8 +1516,7 @@ function _slice(batch, image, sx, sy, sw, sh, dx, dy, dw, dh, effect, alpha) {
1521
1516
  if (sw <= 0 || sh <= 0 || dw <= 0 || dh <= 0) return;
1522
1517
  batch.drawRaw(image, sx, sy, sw, sh, dx, dy, dw, dh, effect, 0, 0, alpha, 0, true);
1523
1518
  }
1524
- //#endregion
1525
- //#region src/render-system.ts
1519
+ // src/render-system.ts
1526
1520
  /**
1527
1521
  * Create a render system function.
1528
1522
  *
@@ -1584,8 +1578,7 @@ const Sprite = (0, _flare_engine_ecs.defineComponent)("Sprite", () => ({
1584
1578
  },
1585
1579
  z: 0
1586
1580
  }));
1587
- //#endregion
1588
- //#region src/renderer.ts
1581
+ // src/renderer.ts
1589
1582
  /**
1590
1583
  * Renderer — manages the Skia Canvas lifecycle for a frame.
1591
1584
  * `begin()` to start, draw your content, `end()` to finish.
@@ -1653,8 +1646,7 @@ var Renderer = class {
1653
1646
  this.stats.batchCount++;
1654
1647
  }
1655
1648
  };
1656
- //#endregion
1657
- //#region src/sprite-batch.ts
1649
+ // src/sprite-batch.ts
1658
1650
  /**
1659
1651
  * SpriteBatch — collects sprite draw commands and groups them by texture
1660
1652
  * (and optionally by effect) for efficient batched rendering.
@@ -1858,8 +1850,7 @@ var SpriteBatch = class {
1858
1850
  };
1859
1851
  }
1860
1852
  };
1861
- //#endregion
1862
- //#region src/sprite-font.ts
1853
+ // src/sprite-font.ts
1863
1854
  /**
1864
1855
  * Parse BMFont JSON format (common output from tools like Hiero, BMFont, msdf-bmfont).
1865
1856
  */
@@ -1920,7 +1911,6 @@ function drawText(batch, font, image, text, x, y, scale = 1) {
1920
1911
  prevCode = code;
1921
1912
  }
1922
1913
  }
1923
- //#endregion
1924
1914
  exports.CAVE_INTERIOR_SKSL = CAVE_INTERIOR_SKSL;
1925
1915
  exports.Camera2D = Camera2D;
1926
1916
  exports.FIRE_SKSL = FIRE_SKSL;