Skip to content

Commit

Permalink
Add missing formats to color spaces
Browse files Browse the repository at this point in the history
Some color spaces couldn't be parsed because they didn't have
any formats.
  • Loading branch information
lloydk committed Feb 14, 2024
1 parent 108022c commit da04a92
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/spaces/a98rgb-linear.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,10 @@ export default new RGBColorSpace({
name: "Linear Adobe® 98 RGB compatible",
white: "D65",
toXYZ_M,
fromXYZ_M
fromXYZ_M,
formats: {
color: {
id: "--a98rgb-linear"
}
}
});
7 changes: 6 additions & 1 deletion src/spaces/p3-linear.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,10 @@ export default new RGBColorSpace({
name: "Linear P3",
white: "D65",
toXYZ_M,
fromXYZ_M
fromXYZ_M,
formats: {
color: {
id: "--p3-linear"
}
}
});
7 changes: 6 additions & 1 deletion src/spaces/prophoto-linear.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,10 @@ export default new RGBColorSpace({
white: "D50",
base: XYZ_D50,
toXYZ_M,
fromXYZ_M
fromXYZ_M,
formats: {
color: {
id: "--prophoto-linear"
}
}
});
6 changes: 6 additions & 0 deletions src/spaces/xyz-abs-d65.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,11 @@ export default new ColorSpace({
toBase (AbsXYZ) {
// Convert to media-white relative XYZ
return AbsXYZ.map(v => Math.max(v / Yw, 0));
},

formats: {
color: {
id: "--xyz-abs-d65"
}
}
});
33 changes: 33 additions & 0 deletions test/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,39 @@ const tests = {
args: "color(--hsv 25deg 50% 75)",
expect: '{"spaceId":"hsv","coords":[25,50,75],"alpha":1}'
},
{
args: "color(--a98rgb-linear 0 1 .5)",
expect: '{"spaceId":"a98rgb-linear","coords":[0,1,0.5],"alpha":1}'
},
{
args: "color(--a98rgb-linear 0 100% 50%)",
expect: '{"spaceId":"a98rgb-linear","coords":[0,1,0.5],"alpha":1}'
},
{
args: "color(--p3-linear 0 1 .5)",
expect: '{"spaceId":"p3-linear","coords":[0,1,0.5],"alpha":1}'
},
{
args: "color(--p3-linear 0% 100% 50%)",
expect: '{"spaceId":"p3-linear","coords":[0,1,0.5],"alpha":1}'
},
{
args: "color(--prophoto-linear 0 1 .5)",
expect: '{"spaceId":"prophoto-linear","coords":[0,1,0.5],"alpha":1}'
},
{
args: "color(--prophoto-linear 0 100% 50%)",
expect: '{"spaceId":"prophoto-linear","coords":[0,1,0.5],"alpha":1}'
},
{
args: "color(--xyz-abs-d65 0 1 .5)",
expect: '{"spaceId":"xyz-abs-d65","coords":[0,1,0.5],"alpha":1}'
},
{
args: "color(--xyz-abs-d65 0 100% 50%)",
expect: '{"spaceId":"xyz-abs-d65","coords":[0,1,0.5],"alpha":1}'
},

{
name: "With transparency",
args: "color(display-p3 0 1 0 / .5)",
Expand Down

0 comments on commit da04a92

Please sign in to comment.