You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/start.rst
+50Lines changed: 50 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -70,6 +70,56 @@ Rendering with wgpu:
70
70
# ... wgpu code
71
71
72
72
73
+
Physical size, logical size, and pixel-ratio
74
+
--------------------------------------------
75
+
76
+
The context has properties for the logical size, physical size, and the
77
+
pixel-ratio.
78
+
79
+
* The physical size represent the actual number of "harware pixels" of the canvas surface.
80
+
* The logical size represents the size in "virtual pixels", which is used to scale elements like text, points, line thickness etc.
81
+
* The pixel-ratio represents the factor between the physical size and the logical size.
82
+
83
+
On regular screens, the physical size and logical size are often equal:
84
+
85
+
.. code-block::
86
+
87
+
+----+----+----+----+
88
+
| | | | | Physical pixels
89
+
+----+----+----+----+
90
+
+----+----+
91
+
| | | Logical pixels, pixel-ratio 1.0
92
+
+----+----+
93
+
94
+
On HiDPI / Retina displays, there are many more pixels, but they are much smaller. To prevent things like text to become tiny,
95
+
the logical pixels are made larger, i.e. pixel-ratio is increased (by the operating system), usually by a factor 2:
96
+
97
+
.. code-block::
98
+
99
+
+--+--+--+--+
100
+
| | | | | Physical pixels
101
+
+--+--+--+--+
102
+
+-----+-----+
103
+
| | | Logical pixels, pixel-ratio 2.0
104
+
+-----+-----+
105
+
106
+
Other operating system may increase the pixel-ratio as a global zoom factor, to increase the size of elements such as text in all applications.
107
+
This means that the pixel-ratio can indeed be fractional:
108
+
109
+
.. code-block::
110
+
111
+
+----+----+----+----+
112
+
| | | | | Physical pixels
113
+
+----+----+----+----+
114
+
+-----+-----+
115
+
| | | Logical pixels, pixel-ratio ± 1.2
116
+
+-----+-----+
117
+
118
+
Side note: on MacOS, the pixel-ratio is fixed to either 1.0 or 2.0, usually the latter on a Retina display with reasonable resolution settings. (The OS level
119
+
zooming is implemented by rendering the whole screen to an offscreen buffer with
120
+
a different size than the physical screen, and then up/down-scaling that to the
0 commit comments