Fork me on GitHub
#cljfx
<
2024-04-19
>
Jonathan Bennett02:04:59

I'm having a bit of trouble understanding image-view. I have the following method which, as far as I understand, should draw the image found by find-sprite using the appropriate color at the x,y coordinates I pass in. But it's sticking them in the top-left corner instead.

clojure
(defn draw-sprite
  [{:keys [unit force x y]}]
  {:fx/type :image-view
   :image (cu/find-sprite unit)
   :effect {:fx/type :blend
            :top-input {:fx/type :color-input
                        :paint (force :color)
                        :x 0 :y 0 :width 100 :height 100}
            :bottom-input {:fx/type :image-input
                           :source (cu/find-sprite unit)}
            :mode :src-atop
            :opacity 0.5}
   :x x
   :y y})
I'm not sure what I'm doing wrong here. When I replaced :x 0 :y 0 inside the :top-input call with :x x :y y, it just made the sprite white (like the color overlay was in the wrong place).