1
0
Fork 0
mirror of https://github.com/heyarne/airsonic-ui.git synced 2026-05-07 02:33:39 +02:00

Fix canvas aspect ration on non-retina displays

This commit is contained in:
Arne Schlüter 2018-10-23 15:55:47 +02:00
commit 6cdd413553

View file

@ -13,14 +13,14 @@
pixel-ratio (.-devicePixelRatio js/window)] pixel-ratio (.-devicePixelRatio js/window)]
(set! (. canvas -width) width) (set! (. canvas -width) width)
(set! (. canvas -height) height) (set! (. canvas -height) height)
(set! (.. canvas -style -width) (str width "px"))
(set! (.. canvas -style -height) (str height "px"))
;; retina drawing code: ;; retina drawing code:
;; set up dimensions, reset the transform matrix to the identity ;; set up dimensions, reset the transform matrix to the identity
;; matrix and automatically scale up ;; matrix and automatically scale up
(when (> pixel-ratio 1) (when (> pixel-ratio 1)
(set! (. canvas -width) (* pixel-ratio width)) (set! (. canvas -width) (* pixel-ratio width))
(set! (. canvas -height) (* pixel-ratio height)) (set! (. canvas -height) (* pixel-ratio height))
(set! (.. canvas -style -width) (str width "px"))
(set! (.. canvas -style -height) (str height "px"))
(.setTransform ctx 1 0 0 1 0 0) (.setTransform ctx 1 0 0 1 0 0)
(.scale ctx pixel-ratio pixel-ratio)) (.scale ctx pixel-ratio pixel-ratio))
(draw ctx))) (draw ctx)))