Making a colorpicker

Tom trashtalk217 at gmail.com
Wed Aug 14 18:49:30 UTC 2019


Hi,

I'm back from vacation and continuing my exploration of ltk. I'm 
currently trying to build a color picker and I'm modeling it after the 
blender color picker. To replicate how it looks I need a nice gradient. 
My first instinct was to just put a bunch of really small rectangles 
(pixels) on a canvas. This worked (see attachment), but it took about 5 
minutes for all the pixels to be put on the canvas. Not ideal, 
especially if I have to redraw the gradient when the brightness value is 
changed by some slider or something. My next idea was to use a bitmap. 
This leads my to my first question: How do I get a bitmap on a canvas? I 
tried the following code.

```

(defvar image (open "lena_gray.bmp"))

(with-ltk ()
   (let* ((canvas (make-instance 'canvas
                 :width 400
                 :height 400)))
     (pack canvas)
     (let ((lena (create-bitmap canvas 20 20 :bitmap image)))
       (declare (ignore lena)))))

```

And I get a generic type-error:

The value
   NIL
is not of type
   STREAM
when binding STREAM
    [Condition of type TYPE-ERROR]The value
   NIL
is not of type
   STREAM
when binding STREAM
    [Condition of type TYPE-ERROR]

There is really no example given in the documentation. So I need help 
with this one (Using SBCL on Linux by the way).

The next question is concerning transparent colors. To darken the 
gradient I thought of having an oval over the bitmap, on which I can 
change the transparency value. I haven't found a way to do that with 
"itemconfigure". And I also haven't found a place where all the keyword 
arguments are listed for "itemconfigure". I'm almost certain that there 
are no transparency options for canvas items in tcl/tk. But in case I've 
overlooked them, I'm asking anyway.

I'd also like to say that I accept tips on my approach. Is there an 
obvious solution that I'm missing or are there other general tips I need 
to figure it out myself. Please let me know! Thanks in advance for any help.

Greetings, Tom.




-------------- next part --------------
A non-text attachment was scrubbed...
Name: Pretty gradient.png
Type: image/png
Size: 14609 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/ltk-user/attachments/20190814/f7d1c034/attachment.png>


More information about the ltk-user mailing list