better scaling!

This commit is contained in:
2015-05-05 17:42:45 -07:00
parent a661426343
commit ae50600203

View File

@@ -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))))))