Skip to content

Commit 7645ad6

Browse files
committed
Merge branch 'v5' into 'main'
Prepare version 5.0 See merge request Wacton/Unicolour!77
2 parents 9ad552f + eafdeb0 commit 7645ad6

17 files changed

+915
-387
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ riderModule.iml
55
/_ReSharper.Caches/
66

77
.idea/
8-
/artifacts/
8+
/artifacts/
9+
/nuget/

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022-2024 William Acton
3+
Copyright (c) 2022-2025 William Acton
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 140 additions & 69 deletions
Large diffs are not rendered by default.

Unicolour.Datasets/Unicolour.Datasets.csproj

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,41 @@
22

33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
5-
<ImplicitUsings>enable</ImplicitUsings>
6-
<Nullable>enable</Nullable>
75
<AssemblyName>Wacton.Unicolour.Datasets</AssemblyName>
86
<RootNamespace>Wacton.Unicolour.Datasets</RootNamespace>
97
<LangVersion>10</LangVersion>
8+
<ImplicitUsings>enable</ImplicitUsings>
9+
<Nullable>enable</Nullable>
1010
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
11-
<Version>2.3.0</Version>
11+
<Version>3.0.0</Version>
1212
<Authors>William Acton</Authors>
1313
<Description>Datasets for use with 🌈 Wacton.Unicolour</Description>
1414
<Copyright>William Acton</Copyright>
1515
<PackageProjectUrl>https://github.com/waacton/Unicolour</PackageProjectUrl>
16-
<PackageIcon>Resources\Unicolour.Datasets.png</PackageIcon>
1716
<RepositoryUrl>https://github.com/waacton/Unicolour</RepositoryUrl>
1817
<PackageTags>unicolour colour color colour-data color-data colour-dataset color-dataset colormap colormaps colourmap colourmaps color-palette colour-palette pigments paints</PackageTags>
19-
<PackageReleaseNotes>Add Nord dataset</PackageReleaseNotes>
18+
<PackageReleaseNotes>Add Artist Paint Spectral Database pigment dataset</PackageReleaseNotes>
19+
<PackageIcon>Resources\Unicolour.Datasets.png</PackageIcon>
20+
<PackageLicenseFile>LICENSE</PackageLicenseFile>
21+
<PackageReadmeFile>README_UnicolourDatasets_nuget.md</PackageReadmeFile>
22+
<PackageOutputPath>..\nuget</PackageOutputPath>
2023
</PropertyGroup>
2124

2225
<ItemGroup>
2326
<None Update="Resources\Unicolour.Datasets.png">
2427
<Pack>True</Pack>
2528
<PackagePath>\</PackagePath>
2629
</None>
30+
31+
<None Include="..\LICENSE">
32+
<Pack>True</Pack>
33+
<PackagePath>\</PackagePath>
34+
</None>
35+
36+
<None Include="..\Unicolour.Readme\README_UnicolourDatasets_nuget.md">
37+
<Pack>True</Pack>
38+
<PackagePath>\</PackagePath>
39+
</None>
2740
</ItemGroup>
2841

2942
<ItemGroup>

Unicolour.Experimental/Unicolour.Experimental.csproj

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,38 @@
55
<AssemblyName>Wacton.Unicolour.Experimental</AssemblyName>
66
<RootNamespace>Wacton.Unicolour.Experimental</RootNamespace>
77
<LangVersion>10</LangVersion>
8+
<ImplicitUsings>enable</ImplicitUsings>
89
<Nullable>enable</Nullable>
910
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
10-
<PackageId>Wacton.Unicolour.Experimental</PackageId>
11+
<Version>1.0.0</Version>
1112
<Authors>William Acton</Authors>
1213
<Description>Experimental additions to 🌈 Wacton.Unicolour</Description>
1314
<Copyright>William Acton</Copyright>
1415
<PackageProjectUrl>https://github.com/waacton/Unicolour</PackageProjectUrl>
1516
<RepositoryUrl>https://github.com/waacton/Unicolour</RepositoryUrl>
16-
<PackageTags>unicolour colour color pigments pigment-mixing kubelka-munk reflectance reflectance-curves spectral.js paints paint-mixing</PackageTags>
17-
<PackageReleaseNotes>Add reflectance generation and Spectral.js implementation</PackageReleaseNotes>
17+
<PackageTags>unicolour colour color pigments pigment-mixing pigment-generation kubelka-munk reflectance reflectance-curves spectral.js paints paint-mixing</PackageTags>
18+
<PackageReleaseNotes>Add pigment generation and Spectral.js implementation</PackageReleaseNotes>
1819
<PackageIcon>Resources\Unicolour.Experimental.png</PackageIcon>
20+
<PackageLicenseFile>LICENSE</PackageLicenseFile>
21+
<PackageReadmeFile>README_UnicolourExperimental_nuget.md</PackageReadmeFile>
22+
<PackageOutputPath>..\nuget</PackageOutputPath>
1923
</PropertyGroup>
2024

2125
<ItemGroup>
2226
<None Update="Resources\Unicolour.Experimental.png">
2327
<Pack>True</Pack>
2428
<PackagePath>\</PackagePath>
2529
</None>
30+
31+
<None Include="..\LICENSE">
32+
<Pack>True</Pack>
33+
<PackagePath>\</PackagePath>
34+
</None>
35+
36+
<None Include="..\Unicolour.Readme\README_UnicolourExperimental_nuget.md">
37+
<Pack>True</Pack>
38+
<PackagePath>\</PackagePath>
39+
</None>
2640
</ItemGroup>
2741

2842
<ItemGroup>

Unicolour.Readme/Program.cs

Lines changed: 62 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Text.RegularExpressions;
22
using Wacton.Unicolour;
33
using Wacton.Unicolour.Datasets;
4+
using Wacton.Unicolour.Experimental;
45
using Wacton.Unicolour.Icc;
56

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

4142
var ukText = textForDocs;
42-
var usText = textForDocs;
43-
4443
ukText += Environment.NewLine;
4544
ukText += $"Also available in [American]({readmeAmericanFilename}) \ud83c\uddfa\ud83c\uddf8.";
4645
File.WriteAllText(Path.Combine(sourceRoot, Path.GetFileName(readmePath)), ukText);
46+
47+
// substitute parts of the readme text that shouldn't change
48+
var guidSubstitutes = new (string original, string guid)[]
49+
{
50+
("https://unicolour.wacton.xyz/wxy-colour-space", Guid.NewGuid().ToString()),
51+
("https://play.unity.com/en/games/6826f61f-3806-4155-b824-7866b1edaed7/3d-colour-space-visualisation-unicolour-demo", Guid.NewGuid().ToString()),
52+
("Unicolour", Guid.NewGuid().ToString()),
53+
("unicolour", Guid.NewGuid().ToString()),
54+
("ColourSpace", Guid.NewGuid().ToString())
55+
};
56+
57+
var guidText = guidSubstitutes.Aggregate(textForDocs, (current, substitute) => current.Replace(substitute.original, substitute.guid));
4758

48-
// could use regex but why bother? also want to be careful not to change spelling of "unicolour", "ColourSpace", etc.
49-
usText = usText
59+
// could use regex but why bother?
60+
var usText = guidText
5061
.Replace("Colour ", "Color ")
5162
.Replace("Colours ", "Colors ")
5263
.Replace("Colour&", "Color&")
5364
.Replace("colour&", "color&")
5465
.Replace(" colour", " color")
66+
.Replace("colour.", "color.")
5567
.Replace("-colour", "-color")
5668
.Replace("colourful", "colorful")
5769
.Replace(" grey ", " gray ")
@@ -62,6 +74,8 @@ void ProcessDocsReadme(string readmePath)
6274
.Replace("isation ", "ization ")
6375
.Replace("isations ", "izations ")
6476
.Replace("metre", "meter");
77+
78+
usText = guidSubstitutes.Aggregate(usText, (current, substitute) => current.Replace(substitute.guid, substitute.original));
6579
usText += Environment.NewLine;
6680
usText += $"Also available in [British]({readmeFilename}) \ud83c\uddec\ud83c\udde7.";
6781
File.WriteAllText(Path.Combine(sourceRoot, Path.GetFileName(readmeAmericanPath)), usText);
@@ -128,17 +142,21 @@ void Quickstart()
128142
var magenta = red.Mix(blue, ColourSpace.Hsl);
129143
Console.WriteLine(magenta.Rgb); // 1.00 0.00 1.00
130144
Console.WriteLine(magenta.Hex); // #FF00FF
145+
146+
// #FF0000, #FF0080, #FF00FF, #8000FF, #0000FF
147+
var palette = red.Palette(blue, ColourSpace.Hsl, 5);
148+
Console.WriteLine(palette.Select(colour => colour.Hex));
131149

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

137-
var equalTristimulus = new Unicolour(ColourSpace.Xyz, 0.5, 0.5, 0.5);
138-
Console.WriteLine(equalTristimulus.Chromaticity.Xy); // (0.3333, 0.3333)
139-
Console.WriteLine(equalTristimulus.Chromaticity.Uv); // (0.2105, 0.3158)
140-
Console.WriteLine(equalTristimulus.Temperature); // 5455.5 K (Δuv -0.00442)
141-
Console.WriteLine(equalTristimulus.DominantWavelength); // 596.1
155+
var equalEnergy = new Unicolour(ColourSpace.Xyz, 0.5, 0.5, 0.5);
156+
Console.WriteLine(equalEnergy.Chromaticity.Xy); // (0.3333, 0.3333)
157+
Console.WriteLine(equalEnergy.Chromaticity.Uv); // (0.2105, 0.3158)
158+
Console.WriteLine(equalEnergy.Temperature); // 5455.5 K (Δuv -0.00442)
159+
Console.WriteLine(equalEnergy.DominantWavelength); // 596.1
142160
}
143161

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

158177
void FeatureCompare()
@@ -169,6 +188,12 @@ void FeatureGamutMap()
169188
var inGamut = outOfGamut.MapToRgbGamut();
170189
}
171190

191+
void FeatureCvd()
192+
{
193+
var colour = new Unicolour(ColourSpace.Rgb255, 192, 255, 238);
194+
var noRed = colour.Simulate(Cvd.Protanopia);
195+
}
196+
172197
void FeatureTemperature()
173198
{
174199
var chromaticity = new Chromaticity(0.3457, 0.3585);
@@ -180,13 +205,6 @@ void FeatureTemperature()
180205
var (x, y) = d65.Chromaticity;
181206
}
182207

183-
void FeatureSpd()
184-
{
185-
// [575 nm] -> 0.5 · [580 nm] -> 1.0 · [585 nm] -> 0.5
186-
var spd = new Spd(start: 575, interval: 5, [0.5, 1.0, 0.5]);
187-
var intenseYellow = new Unicolour(spd);
188-
}
189-
190208
void FeatureWavelength()
191209
{
192210
var chromaticity = new Chromaticity(0.1, 0.8);
@@ -202,10 +220,19 @@ void FeatureImaginary()
202220
var isImaginary = impossibleBlue.IsImaginary;
203221
}
204222

205-
void FeatureCvd()
223+
void FeatureSpd()
206224
{
207-
var colour = new Unicolour(ColourSpace.Rgb255, 192, 255, 238);
208-
var noRed = colour.Simulate(Cvd.Protanopia);
225+
/* [575 nm] -> 0.5 · [580 nm] -> 1.0 · [585 nm] -> 0.5 */
226+
var spd = new Spd(start: 575, interval: 5, coefficients: [0.5, 1.0, 0.5]);
227+
var intenseYellow = new Unicolour(spd);
228+
}
229+
230+
void FeaturePigment()
231+
{
232+
/* populate k and s with measurement data */
233+
var phthaloBlue = new Pigment(startWavelength: 380, wavelengthInterval: 10, k: [], s: []);
234+
var hansaYellow = new Pigment(startWavelength: 380, wavelengthInterval: 10, k: [], s: []);
235+
var green = new Unicolour(pigments: [phthaloBlue, hansaYellow], weights: [0.5, 0.5]);
209236
}
210237

211238
void FeatureIcc()
@@ -279,4 +306,20 @@ void Datasets()
279306
var pink = Css.DeepPink;
280307
var green = Xkcd.NastyGreen;
281308
var mapped = Colourmaps.Viridis.Map(0.5);
309+
var palette = Colourmaps.Turbo.Palette(10);
310+
}
311+
312+
void ExperimentalPigmentGenerator()
313+
{
314+
var redPigment = PigmentGenerator.From(new Unicolour("#FF0000"));
315+
var bluePigment = PigmentGenerator.From(new Unicolour("#0000FF"));
316+
var magenta = new Unicolour([redPigment, bluePigment], [0.5, 0.5]);
317+
}
318+
319+
void ExperimentalSpectralJs()
320+
{
321+
var blue = new Unicolour("#0000FF");
322+
var yellow = new Unicolour("#FFFF00");
323+
var green = SpectralJs.Mix([blue, yellow], [0.5, 0.5]);
324+
var palette = SpectralJs.Palette(blue, yellow, 9);
282325
}

0 commit comments

Comments
 (0)