4

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.

1 Answer 1

4

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
1
  • I don't know why but now it works too. restart emacs or whatever Sep 10, 2013 at 22:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.