Skip to content

Commit 4ceb46c

Browse files
committed
Prepare for more color functions
1 parent c9bc34e commit 4ceb46c

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Released on tbd.
1414
- Added support for 8-digit hex color codes (#132)
1515
- Added more CSSOM possibilities and helpers (#6)
1616
- Added parts of recent color spec update such as `rgb` with spaces (#131)
17+
- Added now Color L4 parsing with `hsl`, `hwb`, `lab`, `lch`, `oklab`, and `oklch`
1718

1819
# 0.17.0
1920

src/AngleSharp.Css/Constants/FunctionNames.cs

+20
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,26 @@ public static class FunctionNames
262262
/// </summary>
263263
public static readonly String Hwba = "hwba";
264264

265+
/// <summary>
266+
/// The LAB (Lightness, A-axis, B-axis) function.
267+
/// </summary>
268+
public static readonly String Lab = "lab";
269+
270+
/// <summary>
271+
/// The LCH (Lightness, Chroma, Hue) function.
272+
/// </summary>
273+
public static readonly String Lch = "lch";
274+
275+
/// <summary>
276+
/// The Oklab (Lightness, A-axis, B-axis) function.
277+
/// </summary>
278+
public static readonly String Oklab = "oklab";
279+
280+
/// <summary>
281+
/// The Oklch (Lightness, Chroma, Hue) function.
282+
/// </summary>
283+
public static readonly String Oklch = "oklch";
284+
265285
/// <summary>
266286
/// The content function.
267287
/// </summary>

src/AngleSharp.Css/Parser/Micro/ColorParser.cs

+33
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ static class ColorParser
2121
{ FunctionNames.Gray, ParseGray },
2222
{ FunctionNames.Hwb, ParseHwba },
2323
{ FunctionNames.Hwba, ParseHwba },
24+
{ FunctionNames.Lab, ParseLab },
25+
{ FunctionNames.Lch, ParseLch },
26+
{ FunctionNames.Oklab, ParseOklab},
27+
{ FunctionNames.Oklch, ParseOklch },
2428
};
2529

2630
/// <summary>
@@ -221,6 +225,35 @@ static class ColorParser
221225
return null;
222226
}
223227

228+
private static Color? ParseLab(StringSource source)
229+
{
230+
// lab(50% 40 59.5)
231+
// lab(50 % 40 59.5 / 0.5)
232+
return null;
233+
}
234+
235+
private static Color? ParseLch(StringSource source)
236+
{
237+
// lch(52.2% 72.2 50)
238+
// lch(52.2 % 72.2 50 / 0.5)
239+
return null;
240+
}
241+
242+
243+
private static Color? ParseOklab(StringSource source)
244+
{
245+
// oklab(59% 0.1 0.1)
246+
// oklab(59 % 0.1 0.1 / 0.5)
247+
return null;
248+
}
249+
250+
private static Color? ParseOklch(StringSource source)
251+
{
252+
// oklch(60% 0.15 50)
253+
// oklch(60 % 0.15 50 / 0.5)
254+
return null;
255+
}
256+
224257
private static Color? ParseHwba(StringSource source)
225258
{
226259
var h = ParseAngle(source);

0 commit comments

Comments
 (0)