Open jakeklassen opened 1 year ago
Skia-canvas has the same API surface as html-canvas. https://www.w3schools.com/tags/canvas_scale.asp
so I guess we might need dwm version of window.devicePixelRatio
to achieve that?
@nhrones yeah that makes sense but I'm thinking more along the lines of:
canvas.style.transform = `scale(4)`;
Using the context API to scale a 128x128 canvas won't make the canvas fill the 512x512 window. Unless I am misunderstanding something. I'm thinking something along the lines of a window stretch mode that could be fill
, etc. Not sure how to achieve that with this lib.
Hopefully that helps clear up my original question.
I'm not sure this is the proper place to ask, but does anyone have an example of how to best scale a Skia Canvas to match the window size?
For example, say I am making a game with a canvas size
128x128
and a window sized at512x512
(so 4x), is there an easy way to auto scale (stretch) the canvas to the window size? I don't want to actually create a512x512
canvas and the draw all the native128x128
sprite at a larger resolution.I'm basically after something like the
transform: scale(4)
you'd get with CSS.