better scaling!
This commit is contained in:
@@ -75,14 +75,27 @@
|
|||||||
range (+ (* percent-complete (- maximum-size minimum-size)) minimum-size)]
|
range (+ (* percent-complete (- maximum-size minimum-size)) minimum-size)]
|
||||||
range)))))
|
range)))))
|
||||||
|
|
||||||
|
(defn get-scale-value [image x y]
|
||||||
|
(let [base-y (Math/floor (- 240 y))
|
||||||
|
other-y (Math/ceil (- 240 y))
|
||||||
|
base-amount (- y (Math/floor y))
|
||||||
|
other-amount (- 1.0 base-amount)
|
||||||
|
base-v (-> image
|
||||||
|
(pixmap! :get-pixel x base-y)
|
||||||
|
color
|
||||||
|
(.r))
|
||||||
|
other-v (-> image
|
||||||
|
(pixmap! :get-pixel x other-y)
|
||||||
|
color
|
||||||
|
(.r))]
|
||||||
|
(+ (* base-v base-amount)
|
||||||
|
(* other-v other-amount))))
|
||||||
|
|
||||||
(defn scaler-fn-from-image [image minimum-size maximum-size]
|
(defn scaler-fn-from-image [image minimum-size maximum-size]
|
||||||
(let [image (pixmap image)
|
(let [image (pixmap image)
|
||||||
maximum-size (or maximum-size 1.0)]
|
maximum-size (or maximum-size 1.0)]
|
||||||
(fn [[x y]]
|
(fn [[x y]]
|
||||||
(let [percent-complete (-> image
|
(let [percent-complete (get-scale-value image x y)]
|
||||||
(pixmap! :get-pixel x (- 240 y))
|
|
||||||
color
|
|
||||||
(.r))]
|
|
||||||
(if (< y 0)
|
(if (< y 0)
|
||||||
maximum-size
|
maximum-size
|
||||||
(+ (* percent-complete (- maximum-size minimum-size)) minimum-size))))))
|
(+ (* percent-complete (- maximum-size minimum-size)) minimum-size))))))
|
||||||
|
|||||||
Reference in New Issue
Block a user