Skip to content

Commit 54be250

Browse files
authored
[css-fonts-4] Animating palettes (#9282)
* [css-fonts-4] Font-palette palette-mix() function Describe modified font-palette syntax and rules for interpolation and percentage normalization referencing the CSS Color spec. * [css-fonts-4] Add animated Nabla example Demonstrates animation of font-palette. * [css-fonts-4] Refine font-palette computed value
1 parent ad5ad42 commit 54be250

File tree

2 files changed

+62
-4
lines changed

2 files changed

+62
-4
lines changed

css-fonts-4/Overview.bs

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6963,13 +6963,14 @@ as well as the colored versions.
69636963

69646964
<pre class="propdef">
69656965
Name: font-palette
6966-
Value: normal | light | dark | <<palette-identifier>>
6966+
Value: normal | light | dark | <<palette-identifier>> | <<palette-mix()>>
69676967
Initial: normal
69686968
Applies to: all elements and text
69696969
Inherited: yes
69706970
Percentages: N/a
6971-
Computed value: specified keyword or identifier
6972-
Animation type: discrete
6971+
Computed value: specified keyword, identifier or <<palette-mix()>> function.
6972+
<<palette-mix>> must be simplified to a single keyword or identifier if resulting palette is equivalent.
6973+
Animation type: by computed value
69736974
</pre>
69746975

69756976
<wpt>
@@ -7022,6 +7023,12 @@ Animation type: discrete
70227023
parsing/font-palette-valid.html
70237024
</wpt>
70247025

7026+
With the <code>palette-mix()</code> function defined as follows:
7027+
7028+
<pre class="prod def" nohighlight>
7029+
<dfn>palette-mix()</dfn> = palette-mix(<<color-interpolation-method>> , [ [normal | light | dark | <<palette-identifier>> | <<palette-mix()>> ] && <<percentage [0,100]>>? ]#{2})
7030+
</pre>
7031+
70257032
<dl dfn-for=font-palette dfn-type=value>
70267033
<dt><dfn>normal</dfn>
70277034
<dd>
@@ -7073,6 +7080,25 @@ Animation type: discrete
70737080
be a modification of an existing palette already present in the font,
70747081
or be an entirely new palette.
70757082

7083+
<dt><dfn type><<palette-mix()>></dfn>
7084+
<dd>
7085+
This value defines a position in the interpolation between two palette values,
7086+
identified by <<palette-identifier>>, by the palette keywords
7087+
''font-palette/normal'', ''font-palette/light'', ''font-palette/dark'',
7088+
or by another <<palette-mix()>> value.
7089+
7090+
The glyphs of the font must be rendered with a palette that is created by
7091+
interpolating for each palette color index between the matching color indices
7092+
of the first and second palette specified as arguments,
7093+
recursively resolving <<palette-mix()>> functions if needed.
7094+
7095+
For each palette color, the interpolation follows
7096+
the rules of the <<color-mix()>> function.
7097+
7098+
When not specified otherwise the <<color-interpolation-method>> is
7099+
<code>in ''oklab''</code> as recommended by [[css-color-5#interpolation-space]].
7100+
7101+
Percentages are normalized according to [[css-color-5#color-mix-percent-norm]].
70767102
</dl>
70777103

70787104
Note: The names 'light' and 'dark' describe the <i>background</i> the color palette is usable on,
@@ -7083,7 +7109,39 @@ Note: The names 'light' and 'dark' describe the <i>background</i> the color pale
70837109
.banner {font-palette: dark;
70847110
}
70857111
}
7086-
</pre>
7112+
</pre>
7113+
</div>
7114+
7115+
<div class="example" id="ex-bixa-palette">
7116+
Animate between palettes.
7117+
7118+
<pre>
7119+
@font-palette-values --pink {
7120+
font-family: Nabla;
7121+
base-palette: 1;
7122+
}
7123+
@font-palette-values --yellow {
7124+
font-family: Nabla;
7125+
base-palette: 7;
7126+
}
7127+
@keyframes animate-palette {
7128+
from {
7129+
font-palette: --yellow;
7130+
}
7131+
to {
7132+
font-palette: --pink;
7133+
}
7134+
}
7135+
p {
7136+
font-family: Nabla;
7137+
animation: animate-palette 1.4s infinite alternate linear;
7138+
}
7139+
</pre>
7140+
7141+
<figure>
7142+
<img src="images/nabla-animated.webp" alt="The word Animate animated between a pink and a yellow palette."/>
7143+
<figcaption>Nabla Color by typearture.com - animating between palettes 1 and 7 in the font.</figcaption>
7144+
</figure>
70877145
</div>
70887146

70897147

237 KB
Binary file not shown.

0 commit comments

Comments
 (0)