Pikchr

Decouple text color from foreground color
Login

Decouple text color from foreground color

(1) By Warren Young (wyoung) on 2020-10-29 21:40:48 [source]

I just had a use for making a box with a different outline color than the color of the text it contained.

I think the current behavior where the two colors track is fine, but you should be able to decouple them, like so:

   box color blue textcolor red "Hi!"

I considered using "text color" here, but I don't know how that would interact with the grammar's use of "text" as an object class. If the grammar allows it, I think it's more PIC-ish that way.

(2) By Jonathan EUnice (jonathan-3play) on 2024-01-22 20:56:48 in reply to 1 [link] [source]

I agree. Color is a super-useful visual signal. Unfortunately not one that could be used in the original PIC, and its controls feel stunted in everything that comes thereafter. Reviewing the source code, fill and color are differentiated, but there is no separate structure for storing the text color; text color is conflated with the stroke/outline/line color.

In some cases you can work around this, e.g.:

S: box rad 10px "Super" fit invis
box with .nw at S.nw height S.height width S.width color blue

but it quickly turns what started as a fairly high-level language into a very low-level one. My experiments using macros to get around this were also not hugely successful.

So consider this a big +1 for this feature request.