saving images with-graphics

38 views
Skip to first unread message

Benjamin Vulpes

unread,
Jun 21, 2014, 6:32:54 PM6/21/14
to clj-pro...@googlegroups.com
I'm trying to generate a bunch of images programmatically with Quil without drawing to the screen (which may be crazy and feel free to tell me so).

The following snippet works just handily:

(defn setup []
  (let [my-image (q/create-image 200 200 :argb)]
    (q/text-align :center :center)
    (q/text "and again?" 100 100)
    (q/save "resources/images/test.png")))


(q/defsketch my-sketch
    :bgcolor "#DDDDDD"
    :title "boss title"
    :setup setup
    :size [200 200])

But this does not:

(defn setup []
  (let [my-graphics (q/create-graphics 200 200 :argb)]
    (q/with-graphics
      (q/text-align :center :center)
      (q/text "how about now?" 100 100)
      (q/save "resources/images/test.png"))))

(q/defsketch my-sketch
  :bgcolor "#DDDDDD"
  :title "boss title"
  :setup setup
  :size [200 200])

Any thoughts?

--bv

Nikita Beloglazov

unread,
Jun 22, 2014, 10:59:20 AM6/22/14
to clj-pro...@googlegroups.com
Hi Benjamin

Your second sketch has few errors.

1. create-graphics takes renderer as third argument and not color mode:
(q/create-graphics 200 200 :java2d)
Or simply
(q/create-graphics 200 200)

2. Your forgot to pass the graphics to with-graphics macro. It should be like this:
(q/with-graphics my-graphics
  ...)

After I did these changes the graphics was sucesfully saved to a file.

Also, why do you create image in your first sketch? You're not using it after it was created.

Thanks,
Nikita



--
You received this message because you are subscribed to the Google Groups "clj-processing" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clj-processin...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages