Browse Source

fix: Add maxPixelRatio to allow for a lower multiplier than current devicePixelRatio (#1282)

Co-authored-by: Sebastian Löfgren <[email protected]>
Sechgulo 2 months ago
parent
commit
e086966e4c
1 changed files with 6 additions and 1 deletions
  1. 6 1
      hxd/Window.js.hx

+ 6 - 1
hxd/Window.js.hx

@@ -74,6 +74,11 @@ class Window {
 		(default : true)
 		(default : true)
 	**/
 	**/
 	public var useScreenPixels : Bool = js.Browser.supported;
 	public var useScreenPixels : Bool = js.Browser.supported;
+	/**
+		Sets the maximum pixel ratio that will be used (only applicable with useScreenPixels enabled).
+		(default : Browser.window.devicePixelRatio)
+	**/
+	public var maxPixelRatio : Float = js.Browser.window.devicePixelRatio;
 	/**
 	/**
 		When enabled, the user click event on the canvas that would trigger mouse capture to be enabled would be discarded.
 		When enabled, the user click event on the canvas that would trigger mouse capture to be enabled would be discarded.
 		(default : true)
 		(default : true)
@@ -306,7 +311,7 @@ class Window {
 	}
 	}
 
 
 	function getPixelRatio() {
 	function getPixelRatio() {
-		return useScreenPixels ? js.Browser.window.devicePixelRatio : 1;
+		return useScreenPixels ? Math.min(js.Browser.window.devicePixelRatio, maxPixelRatio) : 1;
 	}
 	}
 
 
 	function get_width() {
 	function get_width() {