@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.mts +42 -62
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +42 -62
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineComponent } from "@flare-engine/ecs";
|
|
2
|
-
|
|
2
|
+
// src/camera2d.ts
|
|
3
3
|
/** Simple pseudo-random for deterministic shake. Avoids Math.random() allocs. */
|
|
4
4
|
function pseudoRandom(seed) {
|
|
5
5
|
const x = Math.sin(seed * 12.9898 + seed * 78.233) * 43758.5453;
|
|
@@ -283,8 +283,7 @@ var Camera2D = class {
|
|
|
283
283
|
else this.y = b.y + b.height / 2;
|
|
284
284
|
}
|
|
285
285
|
};
|
|
286
|
-
|
|
287
|
-
//#region src/draw-order.ts
|
|
286
|
+
// src/draw-order.ts
|
|
288
287
|
/**
|
|
289
288
|
* Sort an array of drawables by z-index (ascending = back to front).
|
|
290
289
|
* Uses insertion sort which is fast for nearly-sorted arrays
|
|
@@ -316,8 +315,7 @@ function sortByDrawOrder(items, length) {
|
|
|
316
315
|
function drawOrderCompare(a, b) {
|
|
317
316
|
return a.z - b.z;
|
|
318
317
|
}
|
|
319
|
-
|
|
320
|
-
//#region src/shaders.ts
|
|
318
|
+
// src/shaders.ts
|
|
321
319
|
const FIRE_SKSL = `
|
|
322
320
|
uniform float2 resolution;
|
|
323
321
|
uniform float3 color;
|
|
@@ -591,8 +589,7 @@ half4 main(float2 coord) {
|
|
|
591
589
|
return half4(col, 1.0);
|
|
592
590
|
}
|
|
593
591
|
`;
|
|
594
|
-
|
|
595
|
-
//#region src/sprite-effects.ts
|
|
592
|
+
// src/sprite-effects.ts
|
|
596
593
|
/** Create a tint effect. */
|
|
597
594
|
function tint(color, amount) {
|
|
598
595
|
return {
|
|
@@ -782,8 +779,7 @@ function flashIntensity(effect) {
|
|
|
782
779
|
const t = effect.elapsed / effect.duration;
|
|
783
780
|
return Math.max(0, 1 - t);
|
|
784
781
|
}
|
|
785
|
-
|
|
786
|
-
//#region src/frame-renderer.ts
|
|
782
|
+
// src/frame-renderer.ts
|
|
787
783
|
/** See the dev-flag note at the top of this file. */
|
|
788
784
|
const G = globalThis;
|
|
789
785
|
const BLEND_SRC_OVER = 3;
|
|
@@ -1456,8 +1452,7 @@ function fillCustomUniforms(effect, shader, out) {
|
|
|
1456
1452
|
for (let k = 0; k < size; k++) out[info.slot + k] = value[k] ?? 0;
|
|
1457
1453
|
}
|
|
1458
1454
|
}
|
|
1459
|
-
|
|
1460
|
-
//#region src/nine-slice.ts
|
|
1455
|
+
// src/nine-slice.ts
|
|
1461
1456
|
/**
|
|
1462
1457
|
* Draw a sprite using a 9-slice (scale-9) layout.
|
|
1463
1458
|
*
|
|
@@ -1520,8 +1515,7 @@ function _slice(batch, image, sx, sy, sw, sh, dx, dy, dw, dh, effect, alpha) {
|
|
|
1520
1515
|
if (sw <= 0 || sh <= 0 || dw <= 0 || dh <= 0) return;
|
|
1521
1516
|
batch.drawRaw(image, sx, sy, sw, sh, dx, dy, dw, dh, effect, 0, 0, alpha, 0, true);
|
|
1522
1517
|
}
|
|
1523
|
-
|
|
1524
|
-
//#region src/render-system.ts
|
|
1518
|
+
// src/render-system.ts
|
|
1525
1519
|
/**
|
|
1526
1520
|
* Create a render system function.
|
|
1527
1521
|
*
|
|
@@ -1583,8 +1577,7 @@ const Sprite = defineComponent("Sprite", () => ({
|
|
|
1583
1577
|
},
|
|
1584
1578
|
z: 0
|
|
1585
1579
|
}));
|
|
1586
|
-
|
|
1587
|
-
//#region src/renderer.ts
|
|
1580
|
+
// src/renderer.ts
|
|
1588
1581
|
/**
|
|
1589
1582
|
* Renderer — manages the Skia Canvas lifecycle for a frame.
|
|
1590
1583
|
* `begin()` to start, draw your content, `end()` to finish.
|
|
@@ -1652,8 +1645,7 @@ var Renderer = class {
|
|
|
1652
1645
|
this.stats.batchCount++;
|
|
1653
1646
|
}
|
|
1654
1647
|
};
|
|
1655
|
-
|
|
1656
|
-
//#region src/sprite-batch.ts
|
|
1648
|
+
// src/sprite-batch.ts
|
|
1657
1649
|
/**
|
|
1658
1650
|
* SpriteBatch — collects sprite draw commands and groups them by texture
|
|
1659
1651
|
* (and optionally by effect) for efficient batched rendering.
|
|
@@ -1857,8 +1849,7 @@ var SpriteBatch = class {
|
|
|
1857
1849
|
};
|
|
1858
1850
|
}
|
|
1859
1851
|
};
|
|
1860
|
-
|
|
1861
|
-
//#region src/sprite-font.ts
|
|
1852
|
+
// src/sprite-font.ts
|
|
1862
1853
|
/**
|
|
1863
1854
|
* Parse BMFont JSON format (common output from tools like Hiero, BMFont, msdf-bmfont).
|
|
1864
1855
|
*/
|
|
@@ -1919,7 +1910,6 @@ function drawText(batch, font, image, text, x, y, scale = 1) {
|
|
|
1919
1910
|
prevCode = code;
|
|
1920
1911
|
}
|
|
1921
1912
|
}
|
|
1922
|
-
//#endregion
|
|
1923
1913
|
export { CAVE_INTERIOR_SKSL, Camera2D, FIRE_SKSL, FOG_SKSL, FOREST_CANOPY_SKSL, MOON_CRATER_SKSL, MOUNTAIN_HILLS_SKSL, RIVER_WAVE_SKSL, ROOFS_CITY_SKSL, Renderer, Sprite, SpriteBatch, WATER_SKSL, 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 };
|
|
1924
1914
|
|
|
1925
1915
|
//# sourceMappingURL=index.mjs.map
|