RenderConfig

The renderConfig object allows developers to customize the rendering settings for animations.

Properties

PropertyTypeRequiredDefaultDescription
devicePixelRationumberNowindow.devicePixelRatio * 0.75 if DPI > 1, else 1Controls the pixel ratio for rendering. On high-DPI displays (window.devicePixelRatio > 1), the pixel ratio is scaled down to 75% of the device’s pixel ratio. On standard displays, the default is 1.
freezeOnOffscreenbooleanNotrueFreezes animation when offscreen to conserve resources, and resumes the animation when they are visible again.
autoResizebooleanNofalseAutomatically adjusts the animation size when the canvas element is resized.

devicePixelRatio Explained

The devicePixelRatio property is used to control the resolution at which animations are rendered. The default behavior is as follows:

  • High-DPI displays (window.devicePixelRatio > 1): The devicePixelRatio is set to 75% of the device’s native pixel ratio to optimize performance on higher resolution displays without significantly impacting visual quality.
    • Example: If window.devicePixelRatio is 2, the devicePixelRatio will default to 2 * 0.75 = 1.5.
  • Standard displays (window.devicePixelRatio <= 1): The devicePixelRatio is set to 1, ensuring the animations are rendered at their native resolution.

For more information on window.devicePixelRatio, refer to the MDN documentation.