Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adapting quil's create-graphics example to spit out a pdf generates a 0 byte pdf #189

Closed
ghost opened this issue Sep 4, 2016 · 1 comment

Comments

@ghost
Copy link

ghost commented Sep 4, 2016

Not sure where I am doing something wrong, but I tried to change the example at
to one where the image would be spitted out as pdf by changing line 42 from

(let [gr (create-graphics spiral-size spiral-size :java2d)]

to

(let [gr (create-graphics spiral-size spiral-size :pdf "filename.pdf")]

and changing line 48-49

(with-graphics gr (draw-spiral))

to

(with-graphics gr (draw-spiral) (exit))

Not sure why it doesn't spit out a pdf. Maybe some trivial misunderstanding on my side.

@nbeloglazov
Copy link
Member

nbeloglazov commented Oct 15, 2016

Hi. Sorry for the late reply. I did some debugging and it's indeed impossible to do using only quil API, you'll have to use java interop. So the code will look like this:

(let [gr (create-graphics spiral-size spiral-size :pdf "filename.pdf")]
  (with-graphics gr (draw-spiral))
  (.dispose gr))

Note the (.dispose gr) call at the end. This call closes pdf writer and flushes all content to file on disk. Actually I think there is a more idiomatic Processing way to do it using beginRecord() and endRecord() methods, but quil currently doesn't expose them. I'll add do-record macro:

(do-record (create-graphics spiral-size spiral-size :pdf "filename.pdf")
  (draw-spiral))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant