minimojs 1.0.0-alpha.2 → 1.0.0-alpha.3

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/minimo.d.ts CHANGED
@@ -72,6 +72,14 @@ export declare class Sprite {
72
72
  * Used for both canvas rendering (font size) and AABB collision detection.
73
73
  */
74
74
  size: number;
75
+ /**
76
+ * CSS text color used when rendering this sprite.
77
+ *
78
+ * This mainly affects monochrome glyphs and symbol-style sprites.
79
+ * Full-color emoji may ignore this and render with their native colors,
80
+ * depending on browser behavior.
81
+ */
82
+ color: string;
75
83
  /**
76
84
  * Visual rotation of the sprite in degrees.
77
85
  * `0` = upright. Positive values rotate clockwise.
@@ -193,7 +201,7 @@ export interface PointerInfo {
193
201
  * ## Quick Start
194
202
  *
195
203
  * ```ts
196
- * import { Game, Sprite } from "minimojs";
204
+ * import { Game, Sprite } from "https://cdn.jsdelivr.net/npm/minimojs@<version>/dist/minimo.js";
197
205
  *
198
206
  * const game = new Game(800, 600);
199
207
  *
@@ -976,6 +984,22 @@ export declare class Game {
976
984
  * ```
977
985
  */
978
986
  drawText(text: string, x: number, y: number, fontSize: number, color?: string, centered?: boolean): void;
987
+ /**
988
+ * Clears the internal sprite glyph cache.
989
+ *
990
+ * MinimoJS prerenders sprite glyphs into offscreen canvases for more stable
991
+ * emoji rendering and better performance. In long-running sessions, you can
992
+ * call this to release cached glyph variants and force them to be rebuilt on
993
+ * the next render.
994
+ *
995
+ * This does not change any sprite state. It only clears cached render data.
996
+ *
997
+ * @example
998
+ * ```ts
999
+ * game.clearSpriteCache();
1000
+ * ```
1001
+ */
1002
+ clearSpriteCache(): void;
979
1003
  /**
980
1004
  * Returns a pseudo-random floating-point number in the range `[0, 1)`.
981
1005
  * Delegates to `Math.random()`.
package/dist/minimo.js CHANGED
@@ -87,6 +87,14 @@ export class Sprite {
87
87
  * Used for both canvas rendering (font size) and AABB collision detection.
88
88
  */
89
89
  this.size = 32;
90
+ /**
91
+ * CSS text color used when rendering this sprite.
92
+ *
93
+ * This mainly affects monochrome glyphs and symbol-style sprites.
94
+ * Full-color emoji may ignore this and render with their native colors,
95
+ * depending on browser behavior.
96
+ */
97
+ this.color = "#000000";
90
98
  /**
91
99
  * Visual rotation of the sprite in degrees.
92
100
  * `0` = upright. Positive values rotate clockwise.
@@ -171,7 +179,7 @@ export class Sprite {
171
179
  * ## Quick Start
172
180
  *
173
181
  * ```ts
174
- * import { Game, Sprite } from "minimojs";
182
+ * import { Game, Sprite } from "https://cdn.jsdelivr.net/npm/minimojs@<version>/dist/minimo.js";
175
183
  *
176
184
  * const game = new Game(800, 600);
177
185
  *
@@ -1169,6 +1177,24 @@ export class Game {
1169
1177
  // -------------------------------------------------------------------------
1170
1178
  // Misc
1171
1179
  // -------------------------------------------------------------------------
1180
+ /**
1181
+ * Clears the internal sprite glyph cache.
1182
+ *
1183
+ * MinimoJS prerenders sprite glyphs into offscreen canvases for more stable
1184
+ * emoji rendering and better performance. In long-running sessions, you can
1185
+ * call this to release cached glyph variants and force them to be rebuilt on
1186
+ * the next render.
1187
+ *
1188
+ * This does not change any sprite state. It only clears cached render data.
1189
+ *
1190
+ * @example
1191
+ * ```ts
1192
+ * game.clearSpriteCache();
1193
+ * ```
1194
+ */
1195
+ clearSpriteCache() {
1196
+ this._spriteGlyphCache.clear();
1197
+ }
1172
1198
  /**
1173
1199
  * Returns a pseudo-random floating-point number in the range `[0, 1)`.
1174
1200
  * Delegates to `Math.random()`.
@@ -1535,7 +1561,8 @@ export class Game {
1535
1561
  /** @internal */
1536
1562
  _getSpriteGlyphCanvas(sprite) {
1537
1563
  const size = Math.max(1, Math.round(sprite.size));
1538
- const cacheKey = `${sprite.sprite}::${size}`;
1564
+ const color = sprite.color;
1565
+ const cacheKey = `${sprite.sprite}::${size}::${color}`;
1539
1566
  const cached = this._spriteGlyphCache.get(cacheKey);
1540
1567
  if (cached)
1541
1568
  return cached;
@@ -1552,7 +1579,7 @@ export class Game {
1552
1579
  glyphCtx.shadowBlur = 0;
1553
1580
  glyphCtx.shadowOffsetX = 0;
1554
1581
  glyphCtx.shadowOffsetY = 0;
1555
- glyphCtx.fillStyle = "#ffffff";
1582
+ glyphCtx.fillStyle = color;
1556
1583
  glyphCtx.font = `${size}px "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif`;
1557
1584
  glyphCtx.textAlign = "center";
1558
1585
  glyphCtx.textBaseline = "middle";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "minimojs",
3
- "version": "1.0.0-alpha.2",
3
+ "version": "1.0.0-alpha.3",
4
4
  "description": "MinimoJS v1 — ultra-minimal, flat, deterministic 2D web game engine. Emoji-only sprites, rAF loop, TypeScript-first, LLM-friendly.",
5
5
  "type": "module",
6
6
  "main": "dist/minimo.js",