fix(stack): crisp sprite draw, no block strokes, stricter image gate
Thai: ปิด smoothing ตอนวาดบล็อก, เช็ค img.complete, เอา stroke รอบบล็อกออกทั้งหมด English: pixel-style scaling; avoid stroke halo on fallback too. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -225,17 +225,23 @@
|
||||
function drawStackBlockSpriteOrHue(ctx, sx, sy, drawW, drawH, seat, heavy, hueFallback, opts) {
|
||||
const o = opts || {};
|
||||
const rec = resolveStackBlockSpriteRec(seat, heavy);
|
||||
if (rec && rec.ready && rec.img && rec.img.naturalWidth > 0) {
|
||||
const img = rec.img;
|
||||
const img = rec && rec.img;
|
||||
if (rec && rec.ready && img && img.complete && img.naturalWidth > 0 && img.naturalHeight > 0) {
|
||||
const iw = img.naturalWidth;
|
||||
const ih = img.naturalHeight;
|
||||
if (iw > 0 && ih > 0 && drawW > 0 && drawH > 0) {
|
||||
if (drawW > 0 && drawH > 0) {
|
||||
const scale = Math.min(drawW / iw, drawH / ih);
|
||||
const dw = iw * scale;
|
||||
const dh = ih * scale;
|
||||
const dx = sx + (drawW - dw) * 0.5;
|
||||
const dy = sy + (drawH - dh) * 0.5;
|
||||
ctx.drawImage(img, 0, 0, iw, ih, dx, dy, dw, dh);
|
||||
const prevSmooth = ctx.imageSmoothingEnabled;
|
||||
try {
|
||||
ctx.imageSmoothingEnabled = false;
|
||||
ctx.drawImage(img, 0, 0, iw, ih, dx, dy, dw, dh);
|
||||
} finally {
|
||||
ctx.imageSmoothingEnabled = prevSmooth;
|
||||
}
|
||||
if (o.missOverlay) {
|
||||
ctx.fillStyle = 'rgba(247, 118, 190, 0.42)';
|
||||
ctx.fillRect(dx, dy, dw, dh);
|
||||
@@ -7240,12 +7246,7 @@
|
||||
const hue = (i * 47) % 360;
|
||||
const seatL = L.seat != null ? L.seat : 1;
|
||||
const heavyL = !!L.heavy;
|
||||
const drewSpr = drawStackBlockSpriteOrHue(ctx, sx, sy, drawW, drawH, seatL, heavyL, hue, {});
|
||||
if (!drewSpr) {
|
||||
ctx.strokeStyle = 'rgba(255,255,255,0.38)';
|
||||
ctx.lineWidth = 1;
|
||||
ctx.strokeRect(sx, sy, drawW, drawH);
|
||||
}
|
||||
drawStackBlockSpriteOrHue(ctx, sx, sy, drawW, drawH, seatL, heavyL, hue, {});
|
||||
}
|
||||
if (m.settling) {
|
||||
const s = m.settling;
|
||||
@@ -7266,12 +7267,7 @@
|
||||
ctx.save();
|
||||
ctx.translate(cxs, cys);
|
||||
ctx.rotate(rotRad);
|
||||
const drewSet = drawStackBlockSpriteOrHue(ctx, -drawW / 2, -drawH / 2, drawW, drawH, seatS, heavyS, hue, {});
|
||||
if (!drewSet) {
|
||||
ctx.strokeStyle = 'rgba(255, 200, 140, 0.9)';
|
||||
ctx.lineWidth = 2;
|
||||
ctx.strokeRect(-drawW / 2, -drawH / 2, drawW, drawH);
|
||||
}
|
||||
drawStackBlockSpriteOrHue(ctx, -drawW / 2, -drawH / 2, drawW, drawH, seatS, heavyS, hue, {});
|
||||
ctx.restore();
|
||||
} else {
|
||||
const twWorld = m.widthTiles * tileSize;
|
||||
@@ -7319,12 +7315,7 @@
|
||||
ctx.save();
|
||||
ctx.translate(bcx, bcy);
|
||||
ctx.rotate(fallTiltRad + swingTiltRad);
|
||||
const drewSwing = drawStackBlockSpriteOrHue(ctx, -twWorld * zoom / 2, 0, twWorld * zoom, drawStripPx, seatDraw, heavyDraw, hueHint, { missTint: !!hitMissTint, missOverlay: !!hitMissTint });
|
||||
if (!drewSwing) {
|
||||
ctx.strokeStyle = hitMissTint ? 'rgba(255, 180, 210, 0.98)' : 'rgba(192, 202, 245, 0.98)';
|
||||
ctx.lineWidth = 2;
|
||||
ctx.strokeRect(-twWorld * zoom / 2, 0, twWorld * zoom, drawStripPx);
|
||||
}
|
||||
drawStackBlockSpriteOrHue(ctx, -twWorld * zoom / 2, 0, twWorld * zoom, drawStripPx, seatDraw, heavyDraw, hueHint, { missTint: !!hitMissTint, missOverlay: !!hitMissTint });
|
||||
ctx.lineWidth = 1;
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
@@ -2009,7 +2009,7 @@
|
||||
</div>
|
||||
<script src="/Game/socket.io/socket.io.js"></script>
|
||||
<script src="js/version.js?v=0.0184"></script>
|
||||
<script src="js/play.js?v=0.275"></script>
|
||||
<script src="js/play.js?v=0.276"></script>
|
||||
<div class="version-tag">v —</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user