From a4316446112f9e814668c2caff7f826f512f8fed Mon Sep 17 00:00:00 2001 From: Lea Verou Date: Mon, 1 Mar 2021 17:43:44 -0500 Subject: [PATCH] [css-color-5] Remove adjusters from color-mix() and simplify grammar --- css-color-5/Overview.bs | 74 ++++++----------------------------------- 1 file changed, 10 insertions(+), 64 deletions(-) diff --git a/css-color-5/Overview.bs b/css-color-5/Overview.bs index 020a38098f6..afe1eb48223 100644 --- a/css-color-5/Overview.bs +++ b/css-color-5/Overview.bs @@ -119,74 +119,17 @@ Mixing colors: the ''color-mix()'' function {#color-mix} in a given [=colorspace=], by a specified amount. - Multiple color-adjusters can be specified. -
-	color-mix() = color-mix([ in <> ]?, <>#{2})
+	color-mix() = color-mix([ in <> ]?, <>{2} [ <> ]?)
 
-
-	<mix-component> = <> [ <> | <>+ ]?
-
- - -
-	<color-adjuster> = [ [
-			  <> | <> | <>
-			| <> | <> | <>
-		] | alpha ] <>?
-	<srgb-adjuster> = red || green || blue
-	<hsl-adjuster> = <> || saturation || lightness
-	<hwb-adjuster> = <> ||  whiteness || blackness
-	<xyz-adjuster> = x || y || z
-	<lab-adjuster> = lightness || a || b
-	<lch-adjuster> = lightness || chroma || <>
-	<hue-adjuster> = hue [shorter | longer | increasing | decreasing | specified ]?
-
- -Arguments are normalized as follows: - -1. When a percentage is specified without any [=color-adjuster=]s, - it is expanded to all adjusters available for the given [=colorspace=] plus alpha. -2. If a percentage is omitted and there are no adjusters present on any color arguments, - it defaults to 50% (an equal mix of the two colors). -3. Adjusters that are not present on a color default to 0% (i.e. the corresponding components are taken from the other color). -4. Adjusters that are only present on one of the colors default to 100% - p on the second color, - where p is the percentage of the corresponding adjuster in the other color. -5. If the sum of corresponding adjusters across all colors is not 100%, percentages are scaled proportionally so that the sum is exactly 100%. - -Issue: Do missing adjusters default to 0% everywhere, or only in the second color? -If the former, we can end up with adjusters that sum to 0% pretty easily. - -The meaning of the adjusters is defined by colorspace. -For example, if the [=colorspace=] is [=hsl=], -hue means the HSL hue, which is not the same as the LCH hue; -if the colorspace is [=lch=], -lightness means the LCH Lightness, which is the same as Lab lightness, -but different to the HSL Lightness. - -Only the [=color-adjuster=]s defined for a given [=colorspace=] are available. -For example, it is not possible to use the HWB [=whiteness=] adjuster unless the colorspace is [=hwb=]. -The alpha adjuster is available on any [=colorspace=]. +If a percentage is omitted, it defaults to 50% (an equal mix of the two colors). If the specified colorspace has a smaller gamut than the one in which the color to be adjusted is specified, gamut mapping will occur. -Note: not all [=color-adjuster=]s are equally useful. -Adjustments in LCH are the most useful, which is why it is the default. -Adjustments on the a and b axes are rarely needed. -Adjustments in the srgb-related spaces (srgb itself, hsl, hwb) -are provided mainly for backward compatibility -with the sorts of adjustments currently done in CSS preprocessors. -Adjusting the individual x, y and z channels will produce significant hue shifts; -however, adjusting all three channels together is useful -and will lighten or darken the color. - -The [=hue-adjuster=] takes optional keywords, to specify the [[css-color-4#hue-interpolation]] algorithm. -If no keyword is specified, it is as if ''shorter'' were specified. -
This example produces a mixture of 40% peru and 60% lightgoldenrod. @@ -227,7 +170,7 @@ If no keyword is specified, it is as if ''shorter'' were specified. keeps the intermediate colors as saturated as the endpoint colors. -
color-mix(teal 65%, olive);
+
color-mix(in lch, teal 65%, olive);
@@ -251,10 +194,8 @@ If no keyword is specified, it is as if ''shorter'' were specified. * which is a slightly-blueish green: rgb(7.7377% 52.5730% 37.3213%)
-Instead of mixing all channels equally, color-adjusters can be used -to only mix certain channels. The unmixed channels in the result -are copied across from the first color. - +