Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
waacton committed Jul 12, 2024
2 parents 3f9d08b + 7cc5aec commit e59195c
Show file tree
Hide file tree
Showing 78 changed files with 912 additions and 235 deletions.
2 changes: 1 addition & 1 deletion Example.Diagrams/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ void UvChromaticity()
var rangeV = (0.0, 0.4);
var plot = Utils.GetEmptyPlot(rangeU, rangeV, majorTickInterval: 0.05);

var fillMarkers = Utils.GetUvFillMarkers(rangeU, rangeV, increment: 0.001);
var fillMarkers = Utils.GetUvFillMarkers(rangeU, rangeV, increment: 0.00025);
foreach (var marker in fillMarkers)
{
plot.Add.Plottable(marker);
Expand Down
20 changes: 17 additions & 3 deletions Example.Diagrams/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,19 @@ internal static List<Marker> GetXyFillMarkers((double min, double max) rangeX, (
var chromaticity = new Chromaticity(x, y);
var color = GetPlotColour(chromaticity);
if (color == null) continue;

var markerStyle = new MarkerStyle
{
Fill = new FillStyle { Color = color.Value },
Outline = new LineStyle { Color = Colors.Transparent, Width = 0f },
Size = 1.5f
};

var marker = new Marker { X = x, Y = y, Color = color.Value, Size = 2.5f };
var marker = new Marker { X = x, Y = y, MarkerStyle = markerStyle };
data.Add(marker);
}
}

return data;
}

Expand All @@ -88,7 +95,14 @@ internal static List<Marker> GetUvFillMarkers((double min, double max) rangeU, (
var color = GetPlotColour(chromaticity);
if (color == null) continue;

var marker = new Marker { X = u, Y = v, Color = color.Value, Size = 2.5f };
var markerStyle = new MarkerStyle
{
Fill = new FillStyle { Color = color.Value },
Outline = new LineStyle { Color = Colors.Transparent, Width = 0f },
Size = 2f
};

var marker = new Marker { X = u, Y = v, MarkerStyle = markerStyle };
data.Add(marker);
}
}
Expand Down
8 changes: 8 additions & 0 deletions Example.Web/wwwroot/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
<base href="/" /> <!-- needs to be /colour-picker/ when deployed -->
<link rel="stylesheet" href="css/app.css" />
<link rel="icon" type="image/png" href="favicon.png" />

<meta property="og:title" content="Unicolour Picker">
<meta property="og:type" content="website" />
<meta property="og:image" content="https://repository-images.githubusercontent.com/451181558/3373029a-fa50-4546-8942-0c02cbd3e89a">
<meta property="og:url" content="https://unicolour.wacton.xyz/colour-picker/">
<meta property="og:description" content="A colour picker for any colour space, made with Wacton.Unicolour 🌈">
<meta property="og:site_name" content="Unicolour Picker">
<meta name="twitter:card" content="summary_large_image">
</head>

<body>
Expand Down
96 changes: 50 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ It can be used to [mix and compare colours](#mix-colours), as well as [other use
> **Supported colour spaces**
>
> RGB · Linear&nbsp;RGB · HSB&nbsp;/&nbsp;HSV · HSL · HWB · HSI ·
> CIEXYZ · CIExyY · CIELAB · CIELCh<sub>ab</sub> · CIELUV · CIELCh<sub>uv</sub> · HSLuv · HPLuv ·
> CIEXYZ · CIExyY · WXY ·
> CIELAB · CIELCh<sub>ab</sub> · CIELUV · CIELCh<sub>uv</sub> · HSLuv · HPLuv ·
> YPbPr · YCbCr&nbsp;/&nbsp;YUV&nbsp;_(digital)_ · YCgCo · YUV&nbsp;_(PAL)_ · YIQ&nbsp;_(NTSC)_ · YDbDr&nbsp;_(SECAM)_ ·
> TSL · XYB ·
> IPT · IC<sub>T</sub>C<sub>P</sub> · J<sub>z</sub>a<sub>z</sub>b<sub>z</sub> · J<sub>z</sub>C<sub>z</sub>h<sub>z</sub> ·
Expand Down Expand Up @@ -126,44 +127,45 @@ Unicolour colour = new(ColourSpace.Rgb255, 192, 255, 238);
var (l, c, h) = colour.Oklch.Triplet;
```

| Colour&nbsp;space | Enum | Property |
|-----------------------------------------|-------------------------|----------------|
| RGB&nbsp;(0–255) | `ColourSpace.Rgb255` | `.Rgb.Byte255` |
| RGB | `ColourSpace.Rgb` | `.Rgb` |
| Linear&nbsp;RGB | `ColourSpace.RgbLinear` | `.RgbLinear` |
| HSB&nbsp;/&nbsp;HSV | `ColourSpace.Hsb` | `.Hsb` |
| HSL | `ColourSpace.Hsl` | `.Hsl` |
| HWB | `ColourSpace.Hwb` | `.Hwb` |
| HSI | `ColourSpace.Hsi` | `.Hsi` |
| CIEXYZ | `ColourSpace.Xyz` | `.Xyz` |
| CIExyY | `ColourSpace.Xyy` | `.Xyy` |
| CIELAB | `ColourSpace.Lab` | `.Lab` |
| CIELCh<sub>ab</sub> | `ColourSpace.Lchab` | `.Lchab` |
| CIELUV | `ColourSpace.Luv` | `.Luv` |
| CIELCh<sub>uv</sub> | `ColourSpace.Lchuv` | `.Lchuv` |
| HSLuv | `ColourSpace.Hsluv` | `.Hsluv` |
| HPLuv | `ColourSpace.Hpluv` | `.Hpluv` |
| YPbPr | `ColourSpace.Ypbpr` | `.Ypbpr` |
| YCbCr&nbsp;/&nbsp;YUV&nbsp;_(digital)_ | `ColourSpace.Ycbcr` | `.Ycbcr` |
| YCgCo | `ColourSpace.Ycgco` | `.Ycgco` |
| YUV&nbsp;_(PAL)_ | `ColourSpace.Yuv` | `.Yuv` |
| YIQ&nbsp;_(NTSC)_ | `ColourSpace.Yiq` | `.Yiq` |
| YDbDr&nbsp;_(SECAM)_ | `ColourSpace.Ydbdr` | `.Ydbdr` |
| TSL | `ColourSpace.Tsl` | `.Tsl` |
| XYB | `ColourSpace.Xyb` | `.Xyb` |
| IPT | `ColourSpace.Ipt` | `.Ipt` |
| IC<sub>T</sub>C<sub>P</sub> | `ColourSpace.Ictcp` | `.Ictcp` |
| J<sub>z</sub>a<sub>z</sub>b<sub>z</sub> | `ColourSpace.Jzazbz` | `.Jzazbz` |
| J<sub>z</sub>C<sub>z</sub>h<sub>z</sub> | `ColourSpace.Jzczhz` | `.Jzczhz` |
| Oklab | `ColourSpace.Oklab` | `.Oklab` |
| Oklch | `ColourSpace.Oklch` | `.Oklch` |
| Okhsv | `ColourSpace.Okhsv` | `.Okhsv` |
| Okhsl | `ColourSpace.Okhsl` | `.Okhsl` |
| Okhwb | `ColourSpace.Okhwb` | `.Okhwb` |
| CIECAM02 | `ColourSpace.Cam02` | `.Cam02` |
| CAM16 | `ColourSpace.Cam16` | `.Cam16` |
| HCT | `ColourSpace.Hct` | `.Hct` |
| CMYK <sup>[?](#cmyk)</sup> | - | - |
| Colour&nbsp;space | Enum | Property |
|------------------------------------------------------|-------------------------|----------------|
| RGB&nbsp;(0–255) | `ColourSpace.Rgb255` | `.Rgb.Byte255` |
| RGB | `ColourSpace.Rgb` | `.Rgb` |
| Linear&nbsp;RGB | `ColourSpace.RgbLinear` | `.RgbLinear` |
| HSB&nbsp;/&nbsp;HSV | `ColourSpace.Hsb` | `.Hsb` |
| HSL | `ColourSpace.Hsl` | `.Hsl` |
| HWB | `ColourSpace.Hwb` | `.Hwb` |
| HSI | `ColourSpace.Hsi` | `.Hsi` |
| CIEXYZ | `ColourSpace.Xyz` | `.Xyz` |
| CIExyY | `ColourSpace.Xyy` | `.Xyy` |
| [WXY](https://unicolour.wacton.xyz/wxy-colour-space) | `ColourSpace.Wxy` | `.Wxy` |
| CIELAB | `ColourSpace.Lab` | `.Lab` |
| CIELCh<sub>ab</sub> | `ColourSpace.Lchab` | `.Lchab` |
| CIELUV | `ColourSpace.Luv` | `.Luv` |
| CIELCh<sub>uv</sub> | `ColourSpace.Lchuv` | `.Lchuv` |
| HSLuv | `ColourSpace.Hsluv` | `.Hsluv` |
| HPLuv | `ColourSpace.Hpluv` | `.Hpluv` |
| YPbPr | `ColourSpace.Ypbpr` | `.Ypbpr` |
| YCbCr&nbsp;/&nbsp;YUV&nbsp;_(digital)_ | `ColourSpace.Ycbcr` | `.Ycbcr` |
| YCgCo | `ColourSpace.Ycgco` | `.Ycgco` |
| YUV&nbsp;_(PAL)_ | `ColourSpace.Yuv` | `.Yuv` |
| YIQ&nbsp;_(NTSC)_ | `ColourSpace.Yiq` | `.Yiq` |
| YDbDr&nbsp;_(SECAM)_ | `ColourSpace.Ydbdr` | `.Ydbdr` |
| TSL | `ColourSpace.Tsl` | `.Tsl` |
| XYB | `ColourSpace.Xyb` | `.Xyb` |
| IPT | `ColourSpace.Ipt` | `.Ipt` |
| IC<sub>T</sub>C<sub>P</sub> | `ColourSpace.Ictcp` | `.Ictcp` |
| J<sub>z</sub>a<sub>z</sub>b<sub>z</sub> | `ColourSpace.Jzazbz` | `.Jzazbz` |
| J<sub>z</sub>C<sub>z</sub>h<sub>z</sub> | `ColourSpace.Jzczhz` | `.Jzczhz` |
| Oklab | `ColourSpace.Oklab` | `.Oklab` |
| Oklch | `ColourSpace.Oklch` | `.Oklch` |
| Okhsv | `ColourSpace.Okhsv` | `.Okhsv` |
| Okhsl | `ColourSpace.Okhsl` | `.Okhsl` |
| Okhwb | `ColourSpace.Okhwb` | `.Okhwb` |
| CIECAM02 | `ColourSpace.Cam02` | `.Cam02` |
| CAM16 | `ColourSpace.Cam16` | `.Cam16` |
| HCT | `ColourSpace.Hct` | `.Hct` |
| CMYK <sup>[?](#cmyk)</sup> | - | - |

> #### CMYK?
>
Expand Down Expand Up @@ -204,8 +206,9 @@ flowchart TD
HSL(HSL)
HWB(HWB)
HSI(HSI)
XYY(xyY)
XYZ(XYZ)
XYY(xyY)
WXY(WXY)
LAB(LAB)
LCHAB(LCHab)
LUV(LUV)
Expand Down Expand Up @@ -252,6 +255,7 @@ flowchart TD
RGB --> TSL
RGBLIN --> XYB
XYZ --> XYY
XYY --> WXY
XYZ --> LAB
LAB --> LCHAB
XYZ --> LUV
Expand Down Expand Up @@ -574,12 +578,12 @@ All colour spaces are impacted by the reference white point.
Unicolour applies different reference white points to different sets of colour spaces, as shown in the table below.
When a [conversion to or from XYZ space](#convert-between-colour-spaces) involves a change in white point, a chromatic adaptation transform (CAT) is performed using the Bradford method.

| White&nbsp;point&nbsp;configuration | Affected&nbsp;colour&nbsp;spaces |
|-------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `RgbConfiguration` | RGB · Linear&nbsp;RGB · HSB&nbsp;/&nbsp;HSV · HSL · HWB · HSI · YPbPr · YCbCr&nbsp;/&nbsp;YUV&nbsp;_(digital)_ · YCgCo · YUV&nbsp;_(PAL)_ · YIQ&nbsp;_(NTSC)_ · YDbDr&nbsp;_(SECAM)_ · TSL · XYB |
| `XyzConfiguration` | CIEXYZ · CIExyY · CIELAB · CIELCh<sub>ab</sub> · CIELUV · CIELCh<sub>uv</sub> · HSLuv · HPLuv |
| `CamConfiguration` | CIECAM02 · CAM16 |
| None (always D65/2°) | IPT · IC<sub>T</sub>C<sub>P</sub> · J<sub>z</sub>a<sub>z</sub>b<sub>z</sub> · J<sub>z</sub>C<sub>z</sub>h<sub>z</sub> · Oklab · Oklch · Okhsv · Okhsl · Okhwb · HCT |
| White&nbsp;point&nbsp;configuration | Affected&nbsp;colour&nbsp;spaces |
|-------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `RgbConfiguration` | RGB · Linear&nbsp;RGB · HSB&nbsp;/&nbsp;HSV · HSL · HWB · HSI · YPbPr · YCbCr&nbsp;/&nbsp;YUV&nbsp;_(digital)_ · YCgCo · YUV&nbsp;_(PAL)_ · YIQ&nbsp;_(NTSC)_ · YDbDr&nbsp;_(SECAM)_ · TSL · XYB |
| `XyzConfiguration` | CIEXYZ · CIExyY · WXY · CIELAB · CIELCh<sub>ab</sub> · CIELUV · CIELCh<sub>uv</sub> · HSLuv · HPLuv |
| `CamConfiguration` | CIECAM02 · CAM16 |
| None (always D65/2°) | IPT · IC<sub>T</sub>C<sub>P</sub> · J<sub>z</sub>a<sub>z</sub>b<sub>z</sub> · J<sub>z</sub>C<sub>z</sub>h<sub>z</sub> · Oklab · Oklch · Okhsv · Okhsl · Okhwb · HCT |

### Convert between configurations
A `Unicolour` can be converted to a different configuration,
Expand Down
57 changes: 35 additions & 22 deletions Unicolour.Readme/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,68 @@
using Wacton.Unicolour;
using Wacton.Unicolour.Datasets;

const string repoReadme = "README.md";
const string wxyReadme = "docs/wxy-colour-space.md";

var sourceRoot = Path.GetFullPath("./docs");
var solutionRoot = AppDomain.CurrentDomain.BaseDirectory.Split("Unicolour.Readme")[0];
var docsRoot = Path.Combine(solutionRoot, "docs");

ProcessReadme();
ProcessRepoReadme();
ProcessDocsReadme(Path.GetFullPath(repoReadme));
ProcessDocsReadme(Path.GetFullPath(wxyReadme));
CopyDirectory(sourceRoot, docsRoot);
return;

void ProcessReadme()
void ProcessRepoReadme()
{
const string readme = "README.md";
const string readmeAmerican = "README_us.md";
var text = File.ReadAllText(repoReadme);
var textForRepo = text.Replace("../", string.Empty);

var readmeText = File.ReadAllText(readme);
File.WriteAllText(Path.Combine(solutionRoot, repoReadme), textForRepo);
}

var readmeRootText = readmeText
.Replace("../", string.Empty);
File.WriteAllText(Path.Combine(solutionRoot, readme), readmeRootText);
void ProcessDocsReadme(string readmePath)
{
var readmeFilename = Path.GetFileName(readmePath);
var readmeAmericanPath = readmePath.Replace(".md", "_us.md");
var readmeAmericanFilename = Path.GetFileName(readmeAmericanPath);

var readmeDocsText = readmeText
.Replace("docs/", string.Empty)
var text = File.ReadAllText(readmePath);
var textForDocs = text
.Replace("docs/", string.Empty) // docs directory is flat
.Replace("../", "https://github.com/waacton/Unicolour/tree/main/");

// until GitHub Pages supports Mermaid 😑 - just remove it
readmeDocsText = Regex.Replace(readmeDocsText, @"<details>(.|\n)*?<\/details>", string.Empty);
textForDocs = Regex.Replace(textForDocs, @"<details>(.|\n)*?<\/details>", string.Empty);

var readmeUkText = readmeDocsText;
var readmeUsText = readmeDocsText;
var ukText = textForDocs;
var usText = textForDocs;

readmeUkText += Environment.NewLine;
readmeUkText += $"Also available in [American]({readmeAmerican}) \ud83c\uddfa\ud83c\uddf8.";
File.WriteAllText(Path.Combine(sourceRoot, readme), readmeUkText);
ukText += Environment.NewLine;
ukText += $"Also available in [American]({readmeAmericanFilename}) \ud83c\uddfa\ud83c\uddf8.";
File.WriteAllText(Path.Combine(sourceRoot, Path.GetFileName(readmePath)), ukText);

// could use regex but why bother? also want to be careful not to change spelling of "unicolour", "ColourSpace", etc.
readmeUsText = readmeUsText
usText = usText
.Replace("Colour ", "Color ")
.Replace("Colours ", "Colors ")
.Replace("Colour&", "Color&")
.Replace("colour&", "color&")
.Replace(" colour", " color")
.Replace("-colour", "-color")
.Replace("colourful", "colorful")
.Replace(" grey ", " gray ")
.Replace("ise ", "ize ")
.Replace("ised ", "ized ")
.Replace("ises ", "izes ")
.Replace("ising ", "izing ")
.Replace("isation ", "ization ")
.Replace("isations ", "izations ");
readmeUsText += Environment.NewLine;
readmeUsText += $"Also available in [British]({readme}) \ud83c\uddec\ud83c\udde7.";
File.WriteAllText(Path.Combine(sourceRoot, readmeAmerican), readmeUsText);
.Replace("isations ", "izations ")
.Replace("metre", "meter");
usText += Environment.NewLine;
usText += $"Also available in [British]({readmeFilename}) \ud83c\uddec\ud83c\udde7.";
File.WriteAllText(Path.Combine(sourceRoot, Path.GetFileName(readmeAmericanPath)), usText);
}

void CopyDirectory(string sourcePath, string targetPath)
Expand Down
Loading

0 comments on commit e59195c

Please sign in to comment.