@@ -72,6 +72,7 @@ def _rc_present_bitmap(self, *, data, format, **kwargs):
7272
7373 def _rc_set_logical_size (self , width , height ):
7474 logical_size = float (width ), float (height )
75+
7576 physical_size = (
7677 int (logical_size [0 ] * self ._pixel_ratio ),
7778 int (logical_size [1 ] * self ._pixel_ratio ),
@@ -94,6 +95,24 @@ def _rc_set_cursor(self, cursor):
9495
9596 # %% Extra API
9697
98+ def set_physical_size (self , width : int , height : int ):
99+ """Set the size of the backbuffer (in physical pixels).
100+
101+ The logical size is re-calculated using the current pixel ratio.
102+ """
103+ physical_size = int (width ), int (height )
104+ self ._set_size_info (physical_size , self ._pixel_ratio )
105+
106+ def set_pixel_ratio (self , pixel_ratio : float ):
107+ """Set the pixel ratio, changing the logical size of the canvas.
108+
109+ The physical size remains the same. If you want to retain a certain
110+ logical size, first set the pixel ratio and then the logical size.
111+ """
112+ self ._pixel_ratio = float (pixel_ratio )
113+ physical_size = self .get_physical_size ()
114+ self ._set_size_info (physical_size , self ._pixel_ratio )
115+
97116 def draw (self ):
98117 """Perform a draw and get the resulting image.
99118
0 commit comments