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/RuntimeConfig/index.md
+24-5Lines changed: 24 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,6 +35,7 @@ const App = new MyApp(options);
35
35
|`w`| Number | 1920 | Stage width in pixels |
36
36
|`h`| Number | 1080 | Stage height in pixels |
37
37
|`precision`| Float | 1 | Global stage scaling (see details below) |
38
+
|`devicePixelRatio`| Float | 1 | Handling high DPI (see details below) |
38
39
|`memoryPressure`| Number | 24e6 | Maximum GPU memory usage in pixels (see details below) |
39
40
|`clearColor`| Float[]|[0,0,0,0]| Background color in ARGB values (0 to 1) |
40
41
|`defaultFontFace`| String | "sans-serif" | Default font family to use for text. See the [fontFace Text property](../RenderEngine/Textures/Text.md#properties) for how this value ends up being used. The special [CSS defined font family values](https://developer.mozilla.org/en-US/docs/Web/CSS/font-family#values) of "serif" and "sans-serif" may be used as well. |
@@ -52,21 +53,39 @@ const App = new MyApp(options);
52
53
|`devicePixelRatio`| Number | 1 | The DPR is the logical to physical pixel density for a touch enabled device and affects how we calculate collisions |
53
54
54
55
55
-
## Downscaling
56
+
## Global stage scaling
56
57
57
58
> We advise you to always develop your TV App in a **1080p** coordinate system (the Lightning default).
58
59
59
60
60
-
Assume that you have created an App for 1080p quality, so you have used a 1920x1080 coordinate system to position all of the content. However, you have found out that the App needs to be displayed in a 1280x720 resolution.
61
+
Assume that you have created an App for 1080p quality, where you've used a 1920x1080 coordinate system to position all of the content. However, you've found out that the App needs to be displayed in a 1280x720 resolution.
61
62
62
63
63
-
You can use the `precision` property to perform a *global rescale* of the coordinate system. For example, if you specify `precision: 2/3`, the 1920 x-position will be mapped to the 1280-output pixel coordinate.
64
+
To make this adjustment, you can use the `precision` property to perform a *global rescale* of the coordinate system. For example, if you specify `precision: 2/3`, the 1920 x-position will be mapped to the 1280-output pixel coordinate. This downscaling generally works well and can improve quality (less pixel interpolation) while reducing memory usage.
64
65
66
+
By setting `precision: 2`, the 1920 x-position will be mapped to a 3840-output pixel coordinate, effectively upscaling the content for 4K resolution. Please note that upscaling may result in reduced performance due to the higher GPU memory usage.
65
67
66
-
As a result, the text and off-screen textures are rendered at a *lower resolution* by the [Render Engine](../RenderEngine/index.md), which increases quality (less pixel interpolation) and reduces memory usage.
68
+
Keep in mind that WebGL rasterizes at pixel boundaries. This means that when it uses a line width of 2 in 1080p quality, it may render at either 2px or 3px in 720p (depending on the rendered pixel offset). If you encounter such problems, you'll need to set the sizing at a multiple of 3 to ensure proper rendering.
67
69
70
+
# Handling high pixel density (high DPI)
68
71
69
-
Downscaling with the `precision` option generally works well. But keep in mind that WebGL rasterizes as *pixel boundaries*, so when it uses a line width of 2 in 1080p quality, it may render at either 2px or 3px in 720p (depending on the rendered pixel offset). If you encounter such problems, you have to set the sizing at a multiple of 3.
72
+
With the increasing number of devices in the market having high pixel densities (DPI), it's important to handle high DPI properly in your Lightning app. Fortunately, you can take advantage of the higher resolution by setting the devicePixelRatio property, which is a minor and generally non-disruptive change.
73
+
It's worth noting that canvas elements, like most graphics elements, have two sizes
74
+
75
+
- The size they are displayed in the page
76
+
- The size of their content
77
+
78
+
For a canvas element, the size of the content or drawingBuffer is determined by the width and height attributes of the canvas, while the display size is determined by the CSS attributes applied to the canvas. Setting `devicePixelRatio: 2` will result in the following:
a canvas that has a drawingBuffer of size 3840x2060 pixels but is displayed at a 1920x1080 viewport.
85
+
86
+
When viewed on High DPI displays, the browser will automatically upscale the canvas content to ensure that it appears at the correct size on the screen. However, if the devicePixelRatio (DPR) is not set properly, a Lightning application may appear to render at a lower-than-native resolution, which can introduce aliasing.
87
+
88
+
It's essential to handle high DPI properly to ensure that your Lightning app looks crisp and clear on high DPI displays
0 commit comments