Skip to content

Commit

Permalink
Merge branch 'v5' into 'main'
Browse files Browse the repository at this point in the history
Prepare version 5.0

See merge request Wacton/Unicolour!77
  • Loading branch information
waacton committed Feb 8, 2025
2 parents 9ad552f + eafdeb0 commit 7645ad6
Show file tree
Hide file tree
Showing 17 changed files with 915 additions and 387 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ riderModule.iml
/_ReSharper.Caches/

.idea/
/artifacts/
/artifacts/
/nuget/
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022-2024 William Acton
Copyright (c) 2022-2025 William Acton

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
209 changes: 140 additions & 69 deletions README.md

Large diffs are not rendered by default.

23 changes: 18 additions & 5 deletions Unicolour.Datasets/Unicolour.Datasets.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,41 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AssemblyName>Wacton.Unicolour.Datasets</AssemblyName>
<RootNamespace>Wacton.Unicolour.Datasets</RootNamespace>
<LangVersion>10</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>2.3.0</Version>
<Version>3.0.0</Version>
<Authors>William Acton</Authors>
<Description>Datasets for use with 🌈 Wacton.Unicolour</Description>
<Copyright>William Acton</Copyright>
<PackageProjectUrl>https://github.com/waacton/Unicolour</PackageProjectUrl>
<PackageIcon>Resources\Unicolour.Datasets.png</PackageIcon>
<RepositoryUrl>https://github.com/waacton/Unicolour</RepositoryUrl>
<PackageTags>unicolour colour color colour-data color-data colour-dataset color-dataset colormap colormaps colourmap colourmaps color-palette colour-palette pigments paints</PackageTags>
<PackageReleaseNotes>Add Nord dataset</PackageReleaseNotes>
<PackageReleaseNotes>Add Artist Paint Spectral Database pigment dataset</PackageReleaseNotes>
<PackageIcon>Resources\Unicolour.Datasets.png</PackageIcon>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageReadmeFile>README_UnicolourDatasets_nuget.md</PackageReadmeFile>
<PackageOutputPath>..\nuget</PackageOutputPath>
</PropertyGroup>

<ItemGroup>
<None Update="Resources\Unicolour.Datasets.png">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>

<None Include="..\LICENSE">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>

<None Include="..\Unicolour.Readme\README_UnicolourDatasets_nuget.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

<ItemGroup>
Expand Down
20 changes: 17 additions & 3 deletions Unicolour.Experimental/Unicolour.Experimental.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,38 @@
<AssemblyName>Wacton.Unicolour.Experimental</AssemblyName>
<RootNamespace>Wacton.Unicolour.Experimental</RootNamespace>
<LangVersion>10</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>Wacton.Unicolour.Experimental</PackageId>
<Version>1.0.0</Version>
<Authors>William Acton</Authors>
<Description>Experimental additions to 🌈 Wacton.Unicolour</Description>
<Copyright>William Acton</Copyright>
<PackageProjectUrl>https://github.com/waacton/Unicolour</PackageProjectUrl>
<RepositoryUrl>https://github.com/waacton/Unicolour</RepositoryUrl>
<PackageTags>unicolour colour color pigments pigment-mixing kubelka-munk reflectance reflectance-curves spectral.js paints paint-mixing</PackageTags>
<PackageReleaseNotes>Add reflectance generation and Spectral.js implementation</PackageReleaseNotes>
<PackageTags>unicolour colour color pigments pigment-mixing pigment-generation kubelka-munk reflectance reflectance-curves spectral.js paints paint-mixing</PackageTags>
<PackageReleaseNotes>Add pigment generation and Spectral.js implementation</PackageReleaseNotes>
<PackageIcon>Resources\Unicolour.Experimental.png</PackageIcon>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageReadmeFile>README_UnicolourExperimental_nuget.md</PackageReadmeFile>
<PackageOutputPath>..\nuget</PackageOutputPath>
</PropertyGroup>

<ItemGroup>
<None Update="Resources\Unicolour.Experimental.png">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>

<None Include="..\LICENSE">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>

<None Include="..\Unicolour.Readme\README_UnicolourExperimental_nuget.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

<ItemGroup>
Expand Down
81 changes: 62 additions & 19 deletions Unicolour.Readme/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Text.RegularExpressions;
using Wacton.Unicolour;
using Wacton.Unicolour.Datasets;
using Wacton.Unicolour.Experimental;
using Wacton.Unicolour.Icc;

const string repoReadme = "README.md";
Expand Down Expand Up @@ -39,19 +40,30 @@ void ProcessDocsReadme(string readmePath)
textForDocs = Regex.Replace(textForDocs, @"<details>(.|\n)*?<\/details>", string.Empty);

var ukText = textForDocs;
var usText = textForDocs;

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

// substitute parts of the readme text that shouldn't change
var guidSubstitutes = new (string original, string guid)[]
{
("https://unicolour.wacton.xyz/wxy-colour-space", Guid.NewGuid().ToString()),
("https://play.unity.com/en/games/6826f61f-3806-4155-b824-7866b1edaed7/3d-colour-space-visualisation-unicolour-demo", Guid.NewGuid().ToString()),
("Unicolour", Guid.NewGuid().ToString()),
("unicolour", Guid.NewGuid().ToString()),
("ColourSpace", Guid.NewGuid().ToString())
};

var guidText = guidSubstitutes.Aggregate(textForDocs, (current, substitute) => current.Replace(substitute.original, substitute.guid));

// could use regex but why bother? also want to be careful not to change spelling of "unicolour", "ColourSpace", etc.
usText = usText
// could use regex but why bother?
var usText = guidText
.Replace("Colour ", "Color ")
.Replace("Colours ", "Colors ")
.Replace("Colour&", "Color&")
.Replace("colour&", "color&")
.Replace(" colour", " color")
.Replace("colour.", "color.")
.Replace("-colour", "-color")
.Replace("colourful", "colorful")
.Replace(" grey ", " gray ")
Expand All @@ -62,6 +74,8 @@ void ProcessDocsReadme(string readmePath)
.Replace("isation ", "ization ")
.Replace("isations ", "izations ")
.Replace("metre", "meter");

usText = guidSubstitutes.Aggregate(usText, (current, substitute) => current.Replace(substitute.guid, substitute.original));
usText += Environment.NewLine;
usText += $"Also available in [British]({readmeFilename}) \ud83c\uddec\ud83c\udde7.";
File.WriteAllText(Path.Combine(sourceRoot, Path.GetFileName(readmeAmericanPath)), usText);
Expand Down Expand Up @@ -128,17 +142,21 @@ void Quickstart()
var magenta = red.Mix(blue, ColourSpace.Hsl);
Console.WriteLine(magenta.Rgb); // 1.00 0.00 1.00
Console.WriteLine(magenta.Hex); // #FF00FF

// #FF0000, #FF0080, #FF00FF, #8000FF, #0000FF
var palette = red.Palette(blue, ColourSpace.Hsl, 5);
Console.WriteLine(palette.Select(colour => colour.Hex));

var white = new Unicolour(ColourSpace.Oklab, 1.0, 0.0, 0.0);
var black = new Unicolour(ColourSpace.Oklab, 0.0, 0.0, 0.0);
var difference = white.Difference(black, DeltaE.Ciede2000);
Console.WriteLine(difference); // 100.0000

var equalTristimulus = new Unicolour(ColourSpace.Xyz, 0.5, 0.5, 0.5);
Console.WriteLine(equalTristimulus.Chromaticity.Xy); // (0.3333, 0.3333)
Console.WriteLine(equalTristimulus.Chromaticity.Uv); // (0.2105, 0.3158)
Console.WriteLine(equalTristimulus.Temperature); // 5455.5 K (Δuv -0.00442)
Console.WriteLine(equalTristimulus.DominantWavelength); // 596.1
var equalEnergy = new Unicolour(ColourSpace.Xyz, 0.5, 0.5, 0.5);
Console.WriteLine(equalEnergy.Chromaticity.Xy); // (0.3333, 0.3333)
Console.WriteLine(equalEnergy.Chromaticity.Uv); // (0.2105, 0.3158)
Console.WriteLine(equalEnergy.Temperature); // 5455.5 K (Δuv -0.00442)
Console.WriteLine(equalEnergy.DominantWavelength); // 596.1
}

void FeatureConvert()
Expand All @@ -153,6 +171,7 @@ void FeatureMix()
var blue = new Unicolour(ColourSpace.Hsb, 240, 1.0, 1.0);
var magenta = red.Mix(blue, ColourSpace.Hsl, 0.5, HueSpan.Decreasing);
var green = red.Mix(blue, ColourSpace.Hsl, 0.5, HueSpan.Increasing);
var palette = red.Palette(blue, ColourSpace.Hsl, 10, HueSpan.Longer);
}

void FeatureCompare()
Expand All @@ -169,6 +188,12 @@ void FeatureGamutMap()
var inGamut = outOfGamut.MapToRgbGamut();
}

void FeatureCvd()
{
var colour = new Unicolour(ColourSpace.Rgb255, 192, 255, 238);
var noRed = colour.Simulate(Cvd.Protanopia);
}

void FeatureTemperature()
{
var chromaticity = new Chromaticity(0.3457, 0.3585);
Expand All @@ -180,13 +205,6 @@ void FeatureTemperature()
var (x, y) = d65.Chromaticity;
}

void FeatureSpd()
{
// [575 nm] -> 0.5 · [580 nm] -> 1.0 · [585 nm] -> 0.5
var spd = new Spd(start: 575, interval: 5, [0.5, 1.0, 0.5]);
var intenseYellow = new Unicolour(spd);
}

void FeatureWavelength()
{
var chromaticity = new Chromaticity(0.1, 0.8);
Expand All @@ -202,10 +220,19 @@ void FeatureImaginary()
var isImaginary = impossibleBlue.IsImaginary;
}

void FeatureCvd()
void FeatureSpd()
{
var colour = new Unicolour(ColourSpace.Rgb255, 192, 255, 238);
var noRed = colour.Simulate(Cvd.Protanopia);
/* [575 nm] -> 0.5 · [580 nm] -> 1.0 · [585 nm] -> 0.5 */
var spd = new Spd(start: 575, interval: 5, coefficients: [0.5, 1.0, 0.5]);
var intenseYellow = new Unicolour(spd);
}

void FeaturePigment()
{
/* populate k and s with measurement data */
var phthaloBlue = new Pigment(startWavelength: 380, wavelengthInterval: 10, k: [], s: []);
var hansaYellow = new Pigment(startWavelength: 380, wavelengthInterval: 10, k: [], s: []);
var green = new Unicolour(pigments: [phthaloBlue, hansaYellow], weights: [0.5, 0.5]);
}

void FeatureIcc()
Expand Down Expand Up @@ -279,4 +306,20 @@ void Datasets()
var pink = Css.DeepPink;
var green = Xkcd.NastyGreen;
var mapped = Colourmaps.Viridis.Map(0.5);
var palette = Colourmaps.Turbo.Palette(10);
}

void ExperimentalPigmentGenerator()
{
var redPigment = PigmentGenerator.From(new Unicolour("#FF0000"));
var bluePigment = PigmentGenerator.From(new Unicolour("#0000FF"));
var magenta = new Unicolour([redPigment, bluePigment], [0.5, 0.5]);
}

void ExperimentalSpectralJs()
{
var blue = new Unicolour("#0000FF");
var yellow = new Unicolour("#FFFF00");
var green = SpectralJs.Mix([blue, yellow], [0.5, 0.5]);
var palette = SpectralJs.Palette(blue, yellow, 9);
}
Loading

0 comments on commit 7645ad6

Please sign in to comment.