Sometimes I need a drawing area for visualizing some ideas from the REPL.
This is possible with CLIM and other libraries, but I wanted something more
easy and without any extra libraries. So I created CL-Canvas:
http://www.frank-buss.de/lisp/canvas.html
It can be enhanced to react on mouse and keyboard inputs and it should be
cleanuped, moved to a package and ported to other Lisp implementations and
operating systems, which is easy, except for the window callbacks: I've
tried it with UFFI, first, but it doesn't work, because you can't declare
Lisp callbacks in UFFI. Are there any plans to implement this?
--
Frank Bu�, ··@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
From: Andras Simon
Subject: Re: CL-Canvas or yet another graphics library for Logo and Mandelbrot
Date:
Message-ID: <vcdeke23egn.fsf@csusza.math.bme.hu>
Frank Buss <··@frank-buss.de> writes:
> It can be enhanced to react on mouse and keyboard inputs and it should be
> cleanuped, moved to a package and ported to other Lisp implementations and
> operating systems, which is easy, except for the window callbacks: I've
> tried it with UFFI, first, but it doesn't work, because you can't declare
> Lisp callbacks in UFFI. Are there any plans to implement this?
I think not, but hello-c (Kenny Tilton's UFFI fork) has callback
support for LW/ACL/CMUCL. It's used in cells-gtk. I don't know where
to get the latest version. The tarball I found on c-l.net [1] is LW/ACL
only. Mail me if you need a version with CMUCL support, or ask on the
cells-gtk list.
Andras
[1] http://common-lisp.net/cgi-bin/viewcvs.cgi/cell-cultures/hello-c/hello-c.tar.gz?tarball=1&cvsroot=cells
Andras Simon <······@math.bme.hu> wrote:
> I think not, but hello-c (Kenny Tilton's UFFI fork) has callback
> support for LW/ACL/CMUCL. It's used in cells-gtk. I don't know where
> to get the latest version. The tarball I found on c-l.net [1] is
> LW/ACL only. Mail me if you need a version with CMUCL support, or ask
> on the cells-gtk list.
yes, please send me the version with CMUCL support.
--
Frank Bu�, ··@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
Andras Simon <······@math.bme.hu> wrote:
> I think not, but hello-c (Kenny Tilton's UFFI fork) has callback
> support for LW/ACL/CMUCL. It's used in cells-gtk. I don't know where
I've changed it to hello-c from CVS (which has no CMUCL support for
callbacks). It should work with ACL, too, but I didn't tested it.
CL-Canvas is now in its own package, I've added keyboard and mouse
support and the code is a bit cleaner (perhaps the message-cond macro
could be written simpler). The updated webpage:
http://www.frank-buss.de/lisp/canvas.html
There is no overhead required for setting up complicated structures for
showing a window or registering event handlers. It's really easy to write
simple GUI-programs, like a drawing program:
(let ((mouse-pressed nil)
(last-x 0)
(last-y 0))
(defun on-l-button-down (x y)
(setf mouse-pressed t
last-x x
last-y y))
(defun on-l-button-up (x y)
(declare (ignore x y))
(setf mouse-pressed nil))
(defun on-mouse-move (x y)
(when mouse-pressed
(clc:draw-line last-x last-y x y)
(clc:repaint)
(setf last-x x
last-y y))))
(defun drawing-program ()
(clc:show-canvas 400 400
:caption "Drawing program"
:on-mouse-move #'on-mouse-move
:on-l-button-down #'on-l-button-down
:on-l-button-up #'on-l-button-up
:on-key-down #'(lambda (code)
(when (= code clc:VK_SPACE)
(clc:clear-framebuffer)
(clc:repaint)))))
(drawing-program)
--
Frank Bu�, ··@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
Frank Buss <··@frank-buss.de> wrote:
> http://www.frank-buss.de/lisp/canvas.html
I've added platform independent vector font drawing, but don't blame me for
the code, it is a translation from Java without thinking about how to write
it better in Lisp :-)
--
Frank Bu�, ··@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de