Pregunta

I've got the basic quil example working

According to this tutorial the code to load/display an image in processing looks like this:

PImage img; 

void setup() {
   size(320,240);
   img = loadImage("mysummervacation.jpg");
}

void draw() {
   background(0);
   image(img,0,0);
}

I translated it into:

(ns img-demo.core
  (:use quil.core))

(def img (ref nil))

(defn setup []
  (background 0)
  (dosync (ref-set img (load-image "bill.jpg"))))

(defn draw []
  (image @img 0 0))

(defsketch example
  :title "image demo"
  :setup setup
  :draw draw
  :size [2560 1920])

When I execute the code, a window opens, flashes white and stays black afterwards. No errors.

I suspect it has something to do with the image location, because in the tutorial it says: "loadImage() looks for image files stored in your Processing sketch's "data" folder."

I tried various locations and paths, even created a "data" folder inside my project folder and put the image there, but without success.

I'm using Clojure 1.5.1 / Leiningen 2.1.3 / emacs24+ / nrepl

Any idea is welcome,

Thanks in advance.

¿Fue útil?

Solución

I picked a random picture, renamed it to bill.jpg and put it under the project root and your code worked perfectly.

Here are the files and their placement which I think are relevant:

~/Projects/repl/project.clj
~/Projects/repl/bill.jpg
~/Projects/repl/src/img.clj
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top