PuzzleScriptPlus icon indicating copy to clipboard operation
PuzzleScriptPlus copied to clipboard

Allow more control over scaling factor

Open Auroriax opened this issue 3 years ago • 4 comments

Currently PuzzleScript will always attempt to scale the game so that all the pixels are zoomed into a rounded factor. However, on games with big sprites on small screens (e.g. mobile) this might not always be what you want, and the zooming factor needs to have more intervals, even if the tradeoff is that the pixels won't be sharp.

Introduce a prelude flag to set this, and determine how to best explain/document it for developers.

Auroriax avatar Dec 20 '22 22:12 Auroriax

Hmm, it seems like it would be an easy change, but it isn't because of many code being written for pixel perfect ratios. Each time I attempt to do it, it'll look ugly.

I thought a good first step would be to change resizing so that sprites are not regenerated when the size changes, and are always on 1:1 scale on the sheet. However, pixel perfect scaling of images is not something that most browsers support, meaning you have little control over the scaling algorithm.

Moving back to the backlog.

Auroriax avatar Dec 23 '22 21:12 Auroriax

However, pixel perfect scaling of images is not something that most browsers support, meaning you have little control over the scaling algorithm

I don't think that's correct; I believe something like this should do it:

canvas {
  image-rendering:-moz-crisp-edges;
  image-rendering:pixelated;
}

or in javascript:

const ctx = mycanvas.getContext('2d')
ctx.imageSmoothingEnabled = false

(more info)

It seems to me that a prelude flag that applies imageSmoothingEnabled in javascript and also allows non-integer-scale resolutions should be doable!

pancelor avatar Dec 28 '22 11:12 pancelor

(Sorry for the late reply) I think I stumbled across https://greggman.github.io/pixel-perfect.js/#details and based on that decided it wouldn't be easy to get to work. But I should probably have another look

Auroriax avatar Feb 02 '23 15:02 Auroriax

oh geez, just reading that page gives me a headache. sounds like they know more about the css way than I do. but I would hope that imageSmoothingEnabled=false would work :crossed_fingers:

pancelor avatar Feb 02 '23 20:02 pancelor