2D graphics options with Clojure?

910 views
Skip to first unread message

stu

unread,
Apr 30, 2011, 12:26:15 AM4/30/11
to Clojure
Hi,

I'm developing a Clojure project that loads and creates a bunch of
simple 2D geometry (lines, polygons, beziers, text etc). I need to
create in a batch-style way high quality 2D renderings of that
geometry, firstly as PNG files and secondly as PDF files.

What are my options for doing this from Clojure?

So far I can see it might be done with Java2D as I think this can be
used server-side to create the PNG files, but not sure about the
PDFs. I believe I can use Incanter's wrapping of the Processing
libraries for the PNG and again I'm not sure about the PDF option.

The Cairo toolkit is also an option via the Gnome Java bindings and
Java interop?

Are there other options that I'm missing that anyone would like to
report on?

Thanks in advance,

Stu

Nathan Sorenson

unread,
Apr 30, 2011, 3:54:22 AM4/30/11
to Clojure
Batik can serialize to both PNG and PDF. http://xmlgraphics.apache.org/batik/

I currently use Batik in a clojure project doing a lot of drawing of
2d vector-based images. It's a very extensive library but it suits my
needs well.

Dave Ray

unread,
Apr 30, 2011, 11:43:45 AM4/30/11
to clo...@googlegroups.com
I've also had success with Batik for server-side image generation. As
long as you don't mind SVG.

Dave

> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
> Note that posts from new members are moderated - please be patient with your first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

Brenton

unread,
Apr 30, 2011, 1:24:13 PM4/30/11
to Clojure
Stu,

Just a quick thought, you can use Java2D for the images and then iText
to create the PDFs.

Brenton

On Apr 29, 9:26 pm, stu <stuart.hungerf...@gmail.com> wrote:

stu

unread,
May 1, 2011, 5:14:59 AM5/1/11
to Clojure
On Apr 30, 5:54 pm, Nathan Sorenson <n...@sfu.ca> wrote:

> Batik can serialize to both PNG and PDF.http://xmlgraphics.apache.org/batik/
>
> I currently use Batik in a clojure project doing a lot of drawing of
> 2d vector-based images. It's a very extensive library but it suits my
> needs well.

Do you have any Clojure examples of Batik use I could look at?

Thanks,

Stu

fyuryu

unread,
May 1, 2011, 5:33:36 AM5/1/11
to Clojure
Processing has PDF exporting capabilities via one of the standard
libraries that ship with it:

http://processing.org/reference/libraries/pdf/index.html

I haven't used it myself, but I remember seeing nice stuff rendered
with it.

-Roland

Gregg Williams

unread,
May 2, 2011, 6:40:24 PM5/2/11
to Clojure
I have been using a longstanding, well-supported Java 2D drawing
toolkit called Piccolo2D (http://www.piccolo2d.org/index.html). Here
is some text from its home page:

-----
Piccolo2D is a toolkit that supports the development of 2D structured
graphics programs, in general, and Zoomable User Interfaces (ZUIs), in
particular. A ZUI is a new kind of interface that presents a huge
canvas of information on a traditional computer display by letting the
user smoothly zoom in, to get more detailed information, and zoom out
for an overview. We use a "scene graph" model that is common to 3D
environments. Basically, this means that Piccolo2D maintains a
hierarchal structure of objects and cameras, allowing the application
developer to orient, group and manipulate objects in meaningful ways.

Why use Piccolo2D? It will allow you to build structured graphical
applications without worrying so much about the low level details. The
infrastructure provides efficient repainting of the screen, bounds
management, event handling and dispatch, picking (determining which
visual object the mouse is over), animation, layout, and more.
Normally, you would have to write all of this code from scratch.
Additionally, if you want to build an application with zooming, that's
built right into the framework too.

What exactly is it? Piccolo2D is a layer built on top of a lower level
graphics API. There are currently three versions of the toolkit:
Piccolo2D.Java, Piccolo2D.NET and PocketPiccolo2D.NET (for the .NET
Compact Framework). The java version is built on Java 2 and relies on
the Java2D API to do its graphics rendering. The .NET version is built
on the .NET Framework and relies on the GDI+ API to do its graphics
rendering. This makes it easy for Java and C# programmers, even those
targeting PDAs, to build their own animated graphical applications.
And best of all, Piccolo2D is free and open source!
-----

I've been using it with good results; you will need to evaluate it for
your purposes. Good luck, and have fun!

--Gregg

On Apr 29, 9:26 pm, stu <stuart.hungerf...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages