Pict color specifications

I am a bit confused about how the colors are specified in the pict package. The colorize[1] procedure allows any of the color/c[2] values to be used (although it is explicitly written in the documented contract what that means). However all the pict constructors[3] which accept color specification for various arguments use only (or/c #f string? (is-a?/c color%)).

Is there some deeper reasoning behind this or should the pict constructors be updated to allow the same flexibilty as colorize? I'd be more than happy to the work.

My impression is that unifying all the contracts to color/c and making sure the constructors use it appropriately won't break anything and it will make more coherent experience when using pict.

[1] 4 Pict Drawing Adjusters.colorize%29%29
[2] 9 Color Helpers.
%28%28lib._pict%2Fcolor..rkt%29._color%2Fc%29%29
[3] 2 Basic Pict Constructors

And apparently, just copy-pasing URLs from the documentation doesn't always work :frowning: Sorry for the inconvenience.

Allowing a floats as rgb values would be nice too.

Something like make-color*.

https://docs.racket-lang.org/metapict/index.html#(part._ref-colors)

1 Like

That looks nice and is definitely useful too!
My motivation is, however, mainly to keep the number of dependencies as low as possible. And currently with colorize I do not need to (require racket/class) just to allow (is-a?/c color%) contract.
If I understand correctly, supporting floats should be pretty straightforward as the value is simple rounded and clamped in the end. Right?

1 Like

Right.

Post must be at least 20 characters.

1 Like