better scaling!
This commit is contained in:
@@ -75,14 +75,27 @@
|
||||
range (+ (* percent-complete (- maximum-size minimum-size)) minimum-size)]
|
||||
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]
|
||||
(let [image (pixmap image)
|
||||
maximum-size (or maximum-size 1.0)]
|
||||
(fn [[x y]]
|
||||
(let [percent-complete (-> image
|
||||
(pixmap! :get-pixel x (- 240 y))
|
||||
color
|
||||
(.r))]
|
||||
(let [percent-complete (get-scale-value image x y)]
|
||||
(if (< y 0)
|
||||
maximum-size
|
||||
(+ (* percent-complete (- maximum-size minimum-size)) minimum-size))))))
|
||||
|
||||
Reference in New Issue
Block a user