Does anyone know of a cljfx example that renders an image from a resources directory?
if you use ( to get a url, you can pass that to something like https://github.com/phronmophobic/membrane/blob/master/src/membrane/cljfx.clj#L54 to create an javafx.scene.image.Image. You can then draw the image like https://github.com/phronmophobic/membrane/blob/master/src/membrane/cljfx.clj#L571
Here: https://clojurians.slack.com/archives/CGHHJNENB/p1589214377102900 @vlaaad mentions the :image prop of :fx/type :image-view can load resources from the class path. When I set the :url prop value to (http://clojure.java.io/resource "logo.png") I get this exception java.lang.ClassCastException: class java.net.URL cannot be cast to class java.lang.String (java.net.URL and java.lang.String are in module java.base of loader 'bootstrap').
This seems to work:
(defn resource-image [{:keys [resource-file]}]
{:fx/type :image-view
:image (str ( resource-file))}) If you're deploying as a jar, it might be worth double checking if it still works when you jar your application. There are sometimes differences in behavior between file based resources and resources included in the jar.