feat: HD Remaster toggle with 4x canvas render path
G.hdRemaster persisted in localStorage (meatslicer_hd_remaster), toggled from the title screen via H key or the bottom-left tag; activation reloads so the asset tier and canvas resolution swap at boot. draw() applies a uniform hdScale() transform, the room-layer cache renders at render scale, and image smoothing follows the tier.
This commit is contained in:
1 parent
24c1958f2b
commit
ea354d0153
3 files changed
+35
-7
No files matched your search
+7
-5
@@ -393,17 +393,19 @@ function drawFloor(ctx, r) {
|
||||
// browser; headless tests keep the simple direct path.
|
||||
const canCache = typeof document !== 'undefined' && document.createElement && G.imagesLoaded;
|
||||
if (!canCache) { drawFloorTiles(ctx, r); return; }
|
||||
const key = r.gx + ',' + r.gy + ':' + G.floor + ':' + r.shape + ':' + r.theme;
|
||||
const key = r.gx + ',' + r.gy + ':' + G.floor + ':' + r.shape + ':' + r.theme + ':' + hdScale();
|
||||
if (!G.roomLayer || G.roomLayerKey !== key) {
|
||||
const a = roomBounds(r);
|
||||
const rs = hdScale();
|
||||
const layer = document.createElement('canvas');
|
||||
layer.width = Math.max(W, a.x1); layer.height = Math.max(H, a.y1);
|
||||
layer.width = Math.max(W, a.x1) * rs; layer.height = Math.max(H, a.y1) * rs;
|
||||
const lctx = layer.getContext('2d');
|
||||
lctx.imageSmoothingEnabled = false;
|
||||
drawFloorTiles(lctx, r, layer.width, layer.height);
|
||||
lctx.setTransform(rs, 0, 0, rs, 0, 0);
|
||||
lctx.imageSmoothingEnabled = !G.hdRemaster;
|
||||
drawFloorTiles(lctx, r, layer.width / rs, layer.height / rs);
|
||||
G.roomLayer = layer; G.roomLayerKey = key;
|
||||
}
|
||||
ctx.drawImage(G.roomLayer, 0, 0);
|
||||
ctx.drawImage(G.roomLayer, 0, 0, G.roomLayer.width / hdScale(), G.roomLayer.height / hdScale());
|
||||
}
|
||||
|
||||
function drawRoom(ctx) {
|
||||
|
||||
Reference in new issue
Block a user