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
69656965
Name: font-palette
6966-
Value: normal | light | dark | <>
6966+
Value: normal | light | dark | <> | <>
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 <> function.
6972+
<> must be simplified to a single keyword or identifier if resulting palette is equivalent.
6973+
Animation type: by computed value
69736974
69746975

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

7026+
With the palette-mix() function defined as follows:
7027+
7028+
7029+
palette-mix() = palette-mix(<> , [ [normal | light | dark | <> | <> ] && <>? ]#{2})
7030+
7031+
70257032
70267033
normal
70277034
@@ -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+
<>
7084+
7085+
This value defines a position in the interpolation between two palette values,
7086+
identified by <>, by the palette keywords
7087+
''font-palette/normal'', ''font-palette/light'', ''font-palette/dark'',
7088+
or by another <> 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 <> functions if needed.
7094+
7095+
For each palette color, the interpolation follows
7096+
the rules of the <> function.
7097+
7098+
When not specified otherwise the <> is
7099+
in ''oklab'' as recommended by [[css-color-5#interpolation-space]].
7100+
7101+
Percentages are normalized according to [[css-color-5#color-mix-percent-norm]].
70767102
70777103

70787104
Note: The names 'light' and 'dark' describe the background the color palette is usable on,
@@ -7083,7 +7109,39 @@ Note: The names 'light' and 'dark' describe the background the color pale
70837109
.banner {font-palette: dark;
70847110
}
70857111
}
7086-
7112+
7113+
7114+
7115+
7116+
Animate between palettes.
7117+
7118+
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+
7140+
7141+
7142+
The word Animate animated between a pink and a yellow palette.
7143+
Nabla Color by typearture.com - animating between palettes 1 and 7 in the font.
7144+
70877145
70887146

70897147

237 KB
Binary file not shown.

0 commit comments

Comments
 (0)