@@ -172,8 +172,8 @@ export class Canvas {
172172 this . currentZoom = Math . min ( Math . max ( newZoom , this . minZoom ) , this . maxZoom ) ;
173173
174174 const stageCenter = {
175- x : this . application . canvas . width / 2 ,
176- y : this . application . canvas . height / 2
175+ x : this . viewportSize . width / 2 ,
176+ y : this . viewportSize . height / 2
177177 } ;
178178
179179 const distanceFromCenter = {
@@ -239,9 +239,10 @@ export class Canvas {
239239 return ;
240240 }
241241
242+ // In CSS pixels: the canvas element's own width counts device pixels.
242243 this . viewportContainer . position = {
243- x : this . application . canvas . width / 2 - ( this . edit . size . width * this . currentZoom ) / 2 ,
244- y : this . application . canvas . height / 2 - ( this . edit . size . height * this . currentZoom ) / 2
244+ x : this . viewportSize . width / 2 - ( this . edit . size . width * this . currentZoom ) / 2 ,
245+ y : this . viewportSize . height / 2 - ( this . edit . size . height * this . currentZoom ) / 2
245246 } ;
246247
247248 this . syncContentTransforms ( ) ;
@@ -380,7 +381,9 @@ export class Canvas {
380381 target,
381382 ...( frame ? { frame } : { } ) ,
382383 format : pixiFormat ,
383- quality : options . quality ?? 0.85
384+ quality : options . quality ?? 0.85 ,
385+ // Captures stay in output pixels whatever the screen's density.
386+ resolution : 1
384387 } ) ;
385388 }
386389
@@ -623,6 +626,9 @@ export class Canvas {
623626 width : this . viewportSize . width ,
624627 height : this . viewportSize . height ,
625628 antialias : true ,
629+ // Draws at the screen's pixel density, so text and frames stay sharp on phones and retina screens. 2 caps the fill cost on 3x phones.
630+ resolution : Math . min ( window . devicePixelRatio || 1 , 2 ) ,
631+ autoDensity : true ,
626632 powerPreference : "high-performance" ,
627633 eventFeatures : {
628634 globalMove : true , // Required for drag handling in SelectionHandles
0 commit comments