From: Christopher William Bowron
Subject: clx colors
Date: 
Message-ID: <lxblmk3my9v.fsf@arctic.cse.msu.edu>
I just got clx successfully installed on my windows box using clisp
and xfree86... I just need to do some simple stuff and i am having
some difficulties finding the answers to my question in the docs...

what i want to do is set a certain pixel a certain color... i got the
setting the pixel part with draw-point and tearing apart the hello
world demo... but i can only set a pixel to the foreground color and
i would like to be able to set the foreground color which i can't
figure out...

any example code or links would be much appreciated...

-- 
(setq sig '((Christopher Bowron)
	    (········@cps.msu.edu)
	    (www.cse.msu.edu/~bowronch)
	    ("we came, we saw, we got bored and left")))

From: Valeriy E. Ushakov
Subject: Re: clx colors
Date: 
Message-ID: <9mid15$1l15$1@news.spbu.ru>
Christopher William Bowron <········@arctic.cse.msu.edu> wrote:

> I just got clx successfully installed on my windows box using clisp
> and xfree86... I just need to do some simple stuff and i am having
> some difficulties finding the answers to my question in the docs...

Heh, welcome to the wonderful horrible world of X11 ;)


> what i want to do is set a certain pixel a certain color... i got the
> setting the pixel part with draw-point and tearing apart the hello
> world demo... but i can only set a pixel to the foreground color and
> i would like to be able to set the foreground color which i can't
> figure out...

The key word to look for is 'graphic context' (gcontext, gc).

E.g. menu-refresh in demo/menu.lisp does something like:

;; draw menu title in inversed colors
(let ((fg (gcontext-background gcontext))
      (bg (gcontext-foreground gcontext)))
  (with-gcontext (gcontext :foreground fg :background bg)
    (draw-image-glyphs (menu-window menu) gcontext x y (menu-title menu))))


> any example code or links would be much appreciated...

You probably need to find some Xlib introductory material (Xlib to C
is what CLX to CL) that covers basic X11 concepts.  On the minus side
- you will be drowned in the C verbiage required to do anything, on
the plus side - you will *really* start to appreciate how CLX spares
your from all that verbiage.

SY, Uwe
-- 
···@ptc.spbu.ru                         |       Zu Grunde kommen
http://www.ptc.spbu.ru/~uwe/            |       Ist zu Grunde gehen
From: Donald Fisk
Subject: Re: clx colors
Date: 
Message-ID: <3B92D542.525D5520@enterprise.net>
Christopher William Bowron wrote:
> 
> I just got clx successfully installed on my windows box using clisp
> and xfree86... I just need to do some simple stuff and i am having
> some difficulties finding the answers to my question in the docs...
> 
> what i want to do is set a certain pixel a certain color... i got the
> setting the pixel part with draw-point and tearing apart the hello
> world demo... but i can only set a pixel to the foreground color and
> i would like to be able to set the foreground color which i can't
> figure out...
> 
> any example code or links would be much appreciated...

It took me a while too, but I persevered.

You should find a copy of Gilbert Baumann's CLX Manual
(http://www.uni-karlsruhe.de/~unk6/clxman/)

I have written this piece of code:

(defvar *display*)
(defvar *screen*)
(defvar *root-window*)
 
(defun init-graphics ()
  ;; Prevents error in close display.
  (setq *warn-on-floating-point-contagion* nil)
 
  (setq *display* (xlib:open-display ""))
  (setq *screen* (first (xlib:display-roots *display*)))
  (setq *root-window* (xlib:screen-root *screen*)))
 
(init-graphics)
                                                                                
;;; Generates an error if the color doesn't exist, and x-colors tend
;;; to have silly names like PapayaWhip, so it's wise to try it out
;;; before incorporating calls into code.
(defun find-color (name)
  (let ((colormap (xlib:screen-default-colormap *screen*)))
    (xlib:alloc-color colormap (xlib:lookup-color colormap name))))

;;; Some useful colors.
(defconstant +white+ (find-color "white"))
(defconstant +navajo-white+ (find-color "NavajoWhite"))
(defconstant +pink+ (find-color "pink"))
(defconstant +red+ (find-color "red"))
(defconstant +orange+ (find-color "orange"))
(defconstant +yellow+ (find-color "yellow"))
(defconstant +green+ (find-color "green"))
(defconstant +cyan+ (find-color "cyan"))
(defconstant +blue+ (find-color "blue"))
(defconstant +navy-blue+ (find-color "NavyBlue"))
(defconstant +magenta+ (find-color "magenta"))
(defconstant +gainsboro+ (find-color "gainsboro"))
(defconstant +black+ (find-color "black"))

A previous version of the same code had:                            
(defconstant +magenta+ (xlib:make-color :red 1 :green 0 :blue 1))
etc.

Hope that helps.

-- 
Le Hibou
"The reasonable man adapts himself to the world; the unreasonable
one persists in trying to adapt the world to himself. Therefore
all progress depends on the unreasonable man."  -- G.B. Shaw