From: Gregory Novak
Subject: _Simple_ 2D Graphics
Date: 
Message-ID: <m2oe0nf8ed.fsf@euterpe.local>
I've been using Lisp for a small project of personal interest and
found myself wanting to draw simple 2D diagrams (circles, lines, and
such) as output.  I did some digging in the Common Lisp Directory and
didn't find anything that obviously satisfied my need.  There were
many packages, however, so I'm sure I just missed the one I want.

I found many GUI toolkits but they seem rather heavy to me.  I don't
(at this point) need interactivity.  Cl-sdl seemed like a good
candidate but a cursory look at it seemed to reveal that you can draw
using pixels and images, but not circles and arcs.  Cl-gd seems to be
very much along the lines of what I want, but it generates static
images.  I'd like the drawings to appear in a window so that they can
be updated incrementally.  

In short, I'd like to be able to do things like:

(let ((x1 1) (y1 2) (x2 3) (y2 4) (rad 3))
  (with-canvas c
    (circle c x1 y1 rad)
    (line c x1 y1 x2 y2)))

with a minimum of fuss.  What do people use for this sort of thing?

Thank you,
Greg

From: Lars Rune Nøstdal
Subject: Re: _Simple_ 2D Graphics
Date: 
Message-ID: <1141488476.731613.307830@e56g2000cwe.googlegroups.com>
Hi,
Maybe cl-cairo could be of use?

I'm using it to generate PNG-images and display graphics in a
GTK-window/canvas.

Here: http://cairographics.org/cl_2dcairo

-- 
mvh,
Lars Rune Nøstdal
http://lars.nostdal.org/
From: David Trudgett
Subject: Re: _Simple_ 2D Graphics
Date: 
Message-ID: <m3acc7cdbr.fsf@rr.trudgett>
Gregory Novak <·····@ucolick.org> writes:

> I've been using Lisp for a small project of personal interest and
> found myself wanting to draw simple 2D diagrams (circles, lines, and
> such) as output.  I did some digging in the Common Lisp Directory and
> didn't find anything that obviously satisfied my need.  There were
> many packages, however, so I'm sure I just missed the one I want.

You don't say what platform you are using, so I'm going to assume
Darwin... ;-) In that case, X stuff should work, right?

If you don't find anything better, you might want to have a look at my
little CLX-DRAWING-WINDOW package, which I developed for personal use
to do the same sort of thing you're after. (Actually, I'll be building
2D and 3D graphics systems on top of it.)

Disclaimer: I'm not sure what you may need to do to get it working,
but, if memory serves, I think someone else here on c.l.l. recently
said they got it working on a Mac (I'm pretty sure it was a Mac) with
minimum effort. He didn't actually say what he did, though.

Here's the stuff, anyway:

http://www.zeta.org.au/~wpower/dkt/programs/utils.lisp
http://www.zeta.org.au/~wpower/dkt/programs/clx-drawing-window.lisp

and the following one has some 2D graphics pixel-based algorithms
(line and circle drawing) I was mucking around with:

http://www.zeta.org.au/~wpower/dkt/programs/graphics.lisp

I've also written a Mandelbrot and Julia set generator which uses
CLX-DRAWING-WINDOW:

http://www.zeta.org.au/~wpower/dkt/programs/fractal.lisp
http://www.zeta.org.au/~wpower/dkt/programs/mand.lisp


>
> I found many GUI toolkits but they seem rather heavy to me.

This should be right up your alley, then, because you'll be able to
get straight down to doing your simple, basic graphics.


> I don't (at this point) need interactivity.

CLX-DRAWING-WINDOW provides only very basic interactivity at this
time: you can define actions to take on left, middle and right mouse
clicks (oh, and you can press 'q' to quit).


>  Cl-sdl seemed like a good candidate but a cursory look at it seemed
> to reveal that you can draw using pixels and images, but not circles
> and arcs.  Cl-gd seems to be very much along the lines of what I
> want, but it generates static images.  I'd like the drawings to
> appear in a window so that they can be updated incrementally.

That's what CLX-DRAWING-WINDOW does.


>
> In short, I'd like to be able to do things like:
>
> (let ((x1 1) (y1 2) (x2 3) (y2 4) (rad 3))
>   (with-canvas c
>     (circle c x1 y1 rad)
>     (line c x1 y1 x2 y2)))
>
> with a minimum of fuss.  What do people use for this sort of thing?

Dunno. Here's a sample of what I do:

    (defun pixel-circle ()
      (with-drawing-window
       (dw *draw-width* *draw-height* "Pixel Circle")
       (let* ((centre '(300 240))
              (radius 200)
              (small-radius (- radius 10)))
         (set-foreground-colour-name dw 'white)
         (make-label dw "DRAW-PIXEL-CIRCLE" '(460 100))
         (set-foreground-colour-name dw 'cyan)
         (make-label dw "XLIB:DRAW-ARC" '(200 100))
         (make-circle dw centre small-radius)
         (set-foreground-colour-name dw 'white)
         (draw-pixel-circle dw centre radius))))


Cheers,

David



-- 

David Trudgett
http://www.zeta.org.au/~wpower/

Naturally the common people don't want war...but after all it is the
leaders of a country who determine policy, and it is always a simple
matter to drag the people along....  All you have to do is tell them
they are being attacked, and denounce the pacifists for lack of
patriotism and exposing the country to danger.  It works the same in
any country.

    -- Hermann Goering (1893-1946), 1936
From: Peter Herth
Subject: Re: _Simple_ 2D Graphics
Date: 
Message-ID: <ducsd6$nmt$03$1@news.t-online.com>
Gregory Novak wrote:
> I've been using Lisp for a small project of personal interest and
> found myself wanting to draw simple 2D diagrams (circles, lines, and
> such) as output.  I did some digging in the Common Lisp Directory and
> didn't find anything that obviously satisfied my need.  There were
> many packages, however, so I'm sure I just missed the one I want.
> 
> I found many GUI toolkits but they seem rather heavy to me.  I don't
> (at this point) need interactivity.  Cl-sdl seemed like a good
> candidate but a cursory look at it seemed to reveal that you can draw
> using pixels and images, but not circles and arcs.  Cl-gd seems to be
> very much along the lines of what I want, but it generates static
> images.  I'd like the drawings to appear in a window so that they can
> be updated incrementally.  
> 
> In short, I'd like to be able to do things like:
> 
> (let ((x1 1) (y1 2) (x2 3) (y2 4) (rad 3))
>   (with-canvas c
>     (circle c x1 y1 rad)
>     (line c x1 y1 x2 y2)))
> 
> with a minimum of fuss.  What do people use for this sort of thing?
> 

The Ltk canvas is very easy to use. Just look at the canvas example in
the Ltk documentation.

Peter


-- 
Ltk, the easy lisp gui http://www.peter-herth.de/ltk/
From: KenNULLSPAMTilton
Subject: Re: _Simple_ 2D Graphics
Date: 
Message-ID: <f2oOf.40$_g6.7@fe12.lga>
Peter Herth wrote:
> Gregory Novak wrote:
> 
>> I've been using Lisp for a small project of personal interest and
>> found myself wanting to draw simple 2D diagrams (circles, lines, and
>> such) as output.  I did some digging in the Common Lisp Directory and
>> didn't find anything that obviously satisfied my need.  There were
>> many packages, however, so I'm sure I just missed the one I want.
>>
>> I found many GUI toolkits but they seem rather heavy to me.  I don't
>> (at this point) need interactivity.  Cl-sdl seemed like a good
>> candidate but a cursory look at it seemed to reveal that you can draw
>> using pixels and images, but not circles and arcs.  Cl-gd seems to be
>> very much along the lines of what I want, but it generates static
>> images.  I'd like the drawings to appear in a window so that they can
>> be updated incrementally. 
>> In short, I'd like to be able to do things like:
>>
>> (let ((x1 1) (y1 2) (x2 3) (y2 4) (rad 3))
>>   (with-canvas c
>>     (circle c x1 y1 rad)
>>     (line c x1 y1 x2 y2)))
>>
>> with a minimum of fuss.  What do people use for this sort of thing?
>>
> 
> The Ltk canvas is very easy to use. Just look at the canvas example in
> the Ltk documentation.

And the Tk Canvas doc. Scroll waaaaaaaaay down (half way) to get to the 
supported item types.

    http://tmml.sourceforge.net/doc/tk/canvas.html

Also, I ahve not explored this, but there seem to be Tk add-ons one 
somehow bolts in, I suppose by building from source (I just install 
binaries), but whadoiknow?

ken
From: Ralph Richard Cook
Subject: Re: _Simple_ 2D Graphics
Date: 
Message-ID: <440b8167.488632@newsgroups.bellsouth.net>
If interactivity isn't an issue, an alternative is to have your Lisp
app output Scalable Vector Graphics (SVG) and look at the output in
Fifefox 1.5 or higher. 

Simple apps could write a file, or you could use one of the web
frameworks and point the browser to that.
From: Raph
Subject: Re: _Simple_ 2D Graphics
Date: 
Message-ID: <1141756375.902498.190880@v46g2000cwv.googlegroups.com>
I built a small canvas that uses GTK to do what you are talking about.

You can find more details at http://www.gotlisp.com/gtk-drawing.html.

I don't think it has any advantages over LTK or any of the other
options already mentioned (and it seems far more limited than
CLX-DRAWING-WINDOW), but I like it.  :)

Raph