Re: [css-color] copying a value from another color

On Mon, Mar 9, 2015 at 4:18 PM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:
> On Thu, Mar 5, 2015 at 5:18 PM, Andrew VanWagoner
> <thetalecrafter@gmail.com> wrote:
>> It would be very useful if color adjusters could take a color parameter,
>> instead of just a number or percentage, and simply take the color's value.
>>
>> For example, trying to express a color with proper contrast from a
>> background color, and using the hue of known color:
>>
>> color(var(--background) contrast(0%) hue(var(--color-theme)))
>
> I've thought about something like this, but didn't come up with much
> in the way of a use-case.  Would it help if there was just a way to
> run the contrast() adjuster on two colors: the foreground color you
> want to alter and the background color you want it to contrast
> against?  (I think this is the subject of your other thread; I haven't
> read past its title yet.)

Yeah, I think that's what I'm really going for. The color I'm trying
to generate needs to contrast with some separate color. The other
thread goes into more detail into that. Contrast is really the only
use case I had for borrowing another color's value.

>
>> side note: contrast(100%) is always either black or white, and I would guess
>> would be used a lot less than contrast(0%) which finds the minimum
>> contrasting color. It's odd in my mind that the default if omitted is 100%.
>
> I imagine a major use-case for the contrast adjuster is to
> automatically set the text color appropriately, given a background
> color that it'll be displayed over.  In that case, black/white is the
> most common.  It's also the safest choice, as it provides maximum
> contrast (minimum contrast is set to the WCAG AA level of contrast;
> you should usually try for AAA level for maximum readability).
>
> ~TJ

ok, that makes sense. The default is given this background color,
choose a foreground color (black or white) that best contrasts.

-Andy

Received on Tuesday, 10 March 2015 01:14:56 UTC