[plt-scheme] setting the colour of a snip

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Feb 21 08:35:49 EST 2008

At Wed, 20 Feb 2008 15:44:05 +0000, "Stephen De Gabrielle" wrote:
> Hi,
> 
> this is one way to change the colour of a snip;
> 
> (define red-style (send style-list find-or-create-style (send (send
> this-pasteboard get-style-list) basic-style) (send (make-object
> style-delta%) set-delta-foreground (make-object color% "red"))))
> 
> (define blue-style (send style-list find-or-create-style (send (send
> this-pasteboard get-style-list) basic-style) (send (make-object
> style-delta%) set-delta-foreground (make-object color% "blue"))))
> 
> (send snip set-style red-style)
> 
> Is there another way?

At the editor level, you can just use deltas:

 (define (make-color-delta color)
   (send (make-object style-delta%) set-delta-foreground color))

 (define red-delta (make-color-delta (make-object color% "red")))

 (define blue-delta (make-color-delta (make-object color% "blue")))

 (send pasteboard change-style red-delta snip)

> I'd Ideally want to set snip foreground colour as an rgb triple; for
> instance if I wanted snips to change colour based on changing
> variable; (mouse x position is a nice useless example)  something
> like; (send snip set-foreground  r g b )

You can use the above strategies with `(make-color-delta (make-object
color% r g b))', right?

Matthew



Posted on the users mailing list.