[Openmcl-devel] LUI graphics

Alexander Repenning ralex at cs.colorado.edu
Mon May 24 18:14:29 PDT 2010

On May 24, 2010, at 6:42 PM, Richard Sutton wrote:

> hello,
> LUI looks very promising and i am trying to use it.  I can get the examples in LUI.lisp working fine.  However, none of these examples actually does any conventional drawing; most just set a color for a whole view.  I have done drawing previously with easygui so i have some idea what is involved, but i am still having trouble with exactly the sequence needed to get something to appear.  Is there an example anywhere of, say, simply drawing a line on a window?  or maybe something like tiny.lisp?  thanks for any pointers.
> rich

Hi Rich,

for Cocoa based drawing you would have to define a subclass of view and define its drawing method essentially the same way as in easygui. Here is and existing but rather boring example of a colored rectangle:

=== from file LUI Cocoa.lisp ==========

(defmethod DRAW ((Self rectangle-view))
  (when (native-color Self)
    (#/set (native-color Self)))
  (ns:with-ns-rect (Frame 0.0 0.0 (width Self) (height Self))
    (#_NSRectFill Frame)))

Create your own class, define its draw method and put an instance via add-subviews into a window, e.g.,

 (make-instance 'window)
 (make-instance 'rectangle-view))

If you want to have more sophisticated, Web page like, layout management you may want to use the XML layer on top of things.

Alternatively, if you want to use OpenGL based drawing you subclass opengl-view

==== from circle.lisp ==============

(in-package :xlui)

(defclass CIRCLE-VIEW (opengl-dialog)
  ((radius :accessor radius :initform 1.0 :type float)
   (slices :accessor slices :initform 10 :type integer)))

(defmethod PREPARE-OPENGL ((Self circle-view))
  (glColor3f 1.0 0.0 0.0))

(defmethod DRAW ((Self circle-view))
  (let ((delta (/ (* (float pi 0.0) 2.0) (slices Self))))
    (glBegin GL_LINE_LOOP)
    (dotimes (i (slices Self))
      (let ((angle (* i delta)))
        (glVertex2f (* (cos angle) (radius Self)) (* (sin angle) (radius Self)))))

<application-window title="circle, kinda?" y="300">
  <circle-view slices="6"/>

;; this will create window containing an opengl view that will resize:

Does this help at all?

All the best,  Alex

Prof. Alexander Repenning

University of Colorado
Computer Science Department
Boulder, CO 80309-430

vCard: http://www.cs.colorado.edu/~ralex/AlexanderRepenning.vcf

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20100524/98490064/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PastedGraphic-1.tiff
Type: image/tiff
Size: 276110 bytes
Desc: not available
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20100524/98490064/attachment.tiff>

More information about the Openmcl-devel mailing list