This commit is contained in:
33333-33333 2026-06-22 02:03:19 +09:00
commit e8f1d1db1e
60 changed files with 2417 additions and 612 deletions

View file

@ -10,8 +10,8 @@ const stainOverlayCache = new Map();
const SPRITE_CACHE_LIMIT = 128;
const STAIN_CACHE_LIMIT = 64;
const INITIAL_IMAGE_IDS = new Set(["smile", "hungry_70", "zunchi_slave", "zunchi_slave_alt", "zunchi", "zunchi_02", "genkotsu", "pushpin", "pushpin_stuck"]);
const EARLY_IMAGE_IDS = new Set(["smile", "angry", "teary", "jito", "drool", "cry", "sleep", "pokan", "normal_smirk", "normal_tongue", "normal_happy", "weak", "hurt", "hurt2", "fear", "flee", "flee_fear2", "fear_blue", "fear_cry", "sleep2", "stress_dizzy", "stress_sweat", "intimidate", "birth_ritual", "zunchi_slave", "zunchi_slave_alt", "hungry_70", "zunchi", "zunchi_02", "genkotsu", "pushpin", "pushpin_stuck"]);
const INITIAL_IMAGE_IDS = new Set(["smile", "hungry_70", "zunchi_slave", "zunchi_slave_alt", "zunchi", "zunchi_02", "genkotsu", "pushpin", "pushpin_stuck", "oshibyo", "oshibyo_stuck"]);
const EARLY_IMAGE_IDS = new Set(["smile", "angry", "teary", "jito", "drool", "cry", "sleep", "pokan", "normal_smirk", "normal_tongue", "normal_happy", "weak", "hurt", "hurt2", "fear", "flee", "flee_fear2", "fear_blue", "fear_cry", "sleep2", "stress_dizzy", "stress_sweat", "intimidate", "birth_ritual", "zunchi_slave", "zunchi_slave_alt", "hungry_70", "zunchi", "zunchi_02", "genkotsu", "pushpin", "pushpin_stuck", "oshibyo", "oshibyo_stuck"]);
function trimCanvasCache(cache, limit = 128) {
while (cache.size > limit) {
@ -32,6 +32,13 @@ function getCachedSpriteCanvas(id, img, w, h) {
const qw = quantizedCanvasSize(w);
const qh = quantizedCanvasSize(h);
const key = `${id}:${qw}x${qh}`;
if (window.TarinaiPhysics?.createCachedCanvas) {
return window.TarinaiPhysics.createCachedCanvas(scaledSpriteCache, key, qw, qh, (c) => {
if ("imageSmoothingQuality" in c) c.imageSmoothingQuality = "high";
c.clearRect(0, 0, qw, qh);
c.drawImage(img, 0, 0, qw, qh);
}, { limit: SPRITE_CACHE_LIMIT });
}
let canvas = scaledSpriteCache.get(key);
if (canvas) return canvas;
canvas = document.createElement("canvas");
@ -54,16 +61,10 @@ function getCachedStainOverlayCanvas(id, img, w, h, stain = 0, seed = 0.5) {
const bucket = Math.max(1, Math.min(8, Math.ceil(stain * 8)));
const seedBucket = Math.round((seed || 0) * 16);
const key = `${id}:${qw}x${qh}:s${bucket}:r${seedBucket}`;
let canvas = stainOverlayCache.get(key);
if (canvas) return canvas;
canvas = document.createElement("canvas");
canvas.width = qw;
canvas.height = qh;
const c = canvas.getContext("2d");
c.imageSmoothingEnabled = true;
if ("imageSmoothingQuality" in c) c.imageSmoothingQuality = "high";
c.clearRect(0, 0, qw, qh);
c.drawImage(img, 0, 0, qw, qh);
const buildOverlay = (c) => {
if ("imageSmoothingQuality" in c) c.imageSmoothingQuality = "high";
c.clearRect(0, 0, qw, qh);
c.drawImage(img, 0, 0, qw, qh);
c.globalCompositeOperation = "source-in";
c.globalAlpha = 0.34 + bucket * 0.075;
c.fillStyle = "rgba(28, 92, 22, 0.96)";
@ -81,6 +82,16 @@ function getCachedStainOverlayCanvas(id, img, w, h, stain = 0, seed = 0.5) {
}
c.globalAlpha = 1;
c.globalCompositeOperation = "source-over";
};
if (window.TarinaiPhysics?.createCachedCanvas) return window.TarinaiPhysics.createCachedCanvas(stainOverlayCache, key, qw, qh, buildOverlay, { limit: STAIN_CACHE_LIMIT });
let canvas = stainOverlayCache.get(key);
if (canvas) return canvas;
canvas = document.createElement("canvas");
canvas.width = qw;
canvas.height = qh;
const c = canvas.getContext("2d");
c.imageSmoothingEnabled = true;
buildOverlay(c);
stainOverlayCache.set(key, canvas);
trimCanvasCache(stainOverlayCache, STAIN_CACHE_LIMIT);
return canvas;