From fed3f87604768ba795803a56dd34295b028974bd Mon Sep 17 00:00:00 2001 From: Brian Frank Date: Mon, 30 Dec 2024 11:00:58 -0500 Subject: [PATCH] dom: Win.devicePixelRatio --- src/doc/docIntro/doc/ChangeLog.fandoc | 3 +++ src/dom/es/CanvasGraphics.js | 5 +++-- src/dom/es/WinPeer.js | 8 +++++++- src/dom/fan/Win.fan | 6 +++++- src/dom/js/WinPeer.js | 8 +++++++- 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/doc/docIntro/doc/ChangeLog.fandoc b/src/doc/docIntro/doc/ChangeLog.fandoc index 26c6d0745..7c460b8a4 100644 --- a/src/doc/docIntro/doc/ChangeLog.fandoc +++ b/src/doc/docIntro/doc/ChangeLog.fandoc @@ -6,6 +6,9 @@ ** license: Licensed under the Academic Free License version 3.0 ************************************************************************** +*Build 1.0.82 (working)* +- Win.devicePixelRatio + *Build 1.0.81 (6 Dec 2024)* - New markdown pod - New util::Console API diff --git a/src/dom/es/CanvasGraphics.js b/src/dom/es/CanvasGraphics.js index 7884315b4..eb4e43f4d 100644 --- a/src/dom/es/CanvasGraphics.js +++ b/src/dom/es/CanvasGraphics.js @@ -172,7 +172,7 @@ class CanvasGraphics extends sys.Obj { } // This drawEllipse(Float x, Float y, Float w, Float h) - drawEllipsefunction(x, y, w, h) + drawEllipse(x, y, w, h) { this.pathEllipse(x, y, w, h); this.cx.stroke(); @@ -273,4 +273,5 @@ class CanvasGraphics extends sys.Obj { // state for fields in push/pop #stack = new Array(); -} \ No newline at end of file +} + diff --git a/src/dom/es/WinPeer.js b/src/dom/es/WinPeer.js index a921d2524..47430b1ca 100644 --- a/src/dom/es/WinPeer.js +++ b/src/dom/es/WinPeer.js @@ -137,6 +137,11 @@ class WinPeer extends sys.Obj { return this.#screenSize; } + devicePixelRatio(self) + { + return sys.Float.make(this.win.devicePixelRatio); + } + #parent; parent(self) { @@ -457,4 +462,5 @@ class WinPeer extends sys.Obj { return map; } -} \ No newline at end of file +} + diff --git a/src/dom/fan/Win.fan b/src/dom/fan/Win.fan index 6c4407337..f00a67402 100644 --- a/src/dom/fan/Win.fan +++ b/src/dom/fan/Win.fan @@ -79,6 +79,9 @@ class Win ** Return the size of the screen in pixels. native Size screenSize() + ** Ratio of physical pixels to the resolution in CSS pixels + native Float devicePixelRatio() + ** Returns a reference to the parent of the current window ** or subframe, or null if this is the top-most window. native Win? parent() @@ -255,4 +258,5 @@ class Win ** Poll for a browser dependent map of diagnostics name/value pairs ** for current state of JsVM and DOM. @NoDoc native Str:Obj diagnostics() -} \ No newline at end of file +} + diff --git a/src/dom/js/WinPeer.js b/src/dom/js/WinPeer.js index 2fbe295a9..5393dccf5 100644 --- a/src/dom/js/WinPeer.js +++ b/src/dom/js/WinPeer.js @@ -128,6 +128,11 @@ fan.dom.WinPeer.prototype.screenSize = function(self) return this.$screenSize; } +fan.dom.WinPeer.prototype.devicePixelRatio = function(self) +{ + return fan.sys.Float.make(this.win.devicePixelRatio); +} + fan.dom.WinPeer.prototype.parent = function(self) { if (this.win == this.win.parent) return null; @@ -452,4 +457,5 @@ fan.dom.WinPeer.prototype.diagnostics = function(self) map.set("perf.timing.load", dur(t.loadEventStart, t.loadEventEnd)); return map; -} \ No newline at end of file +} +