Skip to content

Commit 5f47400

Browse files
Merge pull request #88 from Muckenbatscher/cleanup/unused
Cleanup/unused
2 parents 4e3e6f7 + e49498b commit 5f47400

File tree

5 files changed

+23
-163
lines changed

5 files changed

+23
-163
lines changed

MaterialTheming.Tests/ColorValidation/TestThemeTypeValidator.cs

Lines changed: 0 additions & 33 deletions
This file was deleted.

MaterialTheming.Tests/ColorValidation/ThemeValidator.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,6 @@ namespace MaterialTheming.Tests.ColorValidation;
66

77
internal class ThemeValidator
88
{
9-
public static ThemeValidationResult ValidateThemeColors<TTestTheme>()
10-
where TTestTheme : ITestTheme, new()
11-
{
12-
var theme = ThemeCreationService.CreateThemeColors<TTestTheme>();
13-
return CreateFromColorDifferences(
14-
typeof(TTestTheme),
15-
ColorDifferenceService.GetColorDifferences<TTestTheme>(theme));
16-
}
17-
189
public static ThemeValidationResult ValidateThemeColors(ITestTheme testTheme)
1910
{
2011
var themeColors = ThemeCreationService.CreateThemeColors(testTheme);

MaterialTheming/ColorDefinitions/HctColor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ public override string ToString()
9696
private void SetInternalState(RgbColor rgb)
9797
{
9898
Cam16 cam = Cam16.FromRgbColor(rgb);
99-
hue = cam.GetHue();
100-
chroma = cam.GetChroma();
99+
hue = cam.Hue;
100+
chroma = cam.Chroma;
101101
tone = ColorUtils.LstarFromRgb(rgb);
102102
}
103103

MaterialTheming/MaterialDesign/DynamicColors/DynamicScheme.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,4 @@ public static double GetRotatedHue(HctColor sourceColorHct, double[] hueBreakpoi
129129
double calculatedRotation = GetPiecewiseValue(sourceHue, hueBreakpoints, rotations);
130130
return MathUtils.SanitizeDegrees(sourceHue + calculatedRotation);
131131
}
132-
133-
public HctColor GetHct(DynamicColor dynamicColor)
134-
{
135-
return dynamicColor.GetHct(this);
136-
}
137132
}

MaterialTheming/MaterialDesign/Hct/Cam16.cs

Lines changed: 21 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,21 @@ internal class Cam16
1616
[0.38752654, 0.62144744, -0.00897398],
1717
[-0.01584150, -0.03412294, 1.0499644]
1818
};
19-
20-
private readonly double hue;
21-
private readonly double chroma;
22-
private readonly double j;
23-
private readonly double q;
24-
private readonly double m;
25-
private readonly double s;
26-
27-
/** Hue in CAM16 */
28-
public double GetHue()
29-
{
30-
return hue;
31-
}
32-
33-
/** Chroma in CAM16 */
34-
public double GetChroma()
35-
{
36-
return chroma;
37-
}
38-
39-
/** Lightness in CAM16 */
40-
public double GetJ()
41-
{
42-
return j;
43-
}
19+
/// <summary>
20+
/// Hue in CAM16
21+
/// </summary>
22+
public double Hue { get; private set; }
23+
/// <summary>
24+
/// Chroma in CAM16
25+
/// </summary>
26+
public double Chroma { get; private set; }
27+
/// <summary>
28+
/// Lightness in CAM16
29+
/// </summary>
30+
public double J { get; private set; }
31+
public double Q { get; private set; }
32+
public double M { get; private set; }
33+
public double S { get; private set; }
4434

4535
/**
4636
* All of the CAM16 dimensions can be calculated from 3 of the dimensions, in the following
@@ -67,12 +57,12 @@ private Cam16(
6757
double m,
6858
double s)
6959
{
70-
this.hue = hue;
71-
this.chroma = chroma;
72-
this.j = j;
73-
this.q = q;
74-
this.m = m;
75-
this.s = s;
60+
this.Hue = hue;
61+
this.Chroma = chroma;
62+
this.J = j;
63+
this.Q = q;
64+
this.M = m;
65+
this.S = s;
7666
}
7767

7868
/**
@@ -178,88 +168,5 @@ internal static Cam16 FromXyzInViewingConditions(
178168

179169
return new Cam16(hue, c, j, q, m, s);
180170
}
181-
182-
/**
183-
* @param j CAM16 lightness
184-
* @param c CAM16 chroma
185-
* @param h CAM16 hue
186-
* @param viewingConditions Information about the environment where the color was observed.
187-
*/
188-
private static Cam16 FromJchInViewingConditions(
189-
double j, double c, double h, ViewingConditions viewingConditions)
190-
{
191-
double q =
192-
4.0
193-
/ viewingConditions.C
194-
* Math.Sqrt(j / 100.0)
195-
* (viewingConditions.Aw + 4.0)
196-
* viewingConditions.FlRoot;
197-
double m = c * viewingConditions.FlRoot;
198-
double alpha = c / Math.Sqrt(j / 100.0);
199-
double s =
200-
50.0 * Math.Sqrt((alpha * viewingConditions.C) / (viewingConditions.Aw + 4.0));
201-
202-
return new Cam16(h, c, j, q, m, s);
203-
}
204-
205-
/**
206-
* RGB representation of the color, in defined viewing conditions.
207-
*
208-
* @param viewingConditions Information about the environment where the color will be viewed.
209-
* @return RGB representation of color
210-
*/
211-
RgbColor Viewed(ViewingConditions viewingConditions)
212-
{
213-
double[] xyz = XyzInViewingConditions(viewingConditions);
214-
return ColorUtils.RgbFromXyz(xyz[0], xyz[1], xyz[2]);
215-
}
216-
217-
internal double[] XyzInViewingConditions(ViewingConditions viewingConditions)
218-
{
219-
double alpha =
220-
(GetChroma() == 0.0 || GetJ() == 0.0) ? 0.0 : GetChroma() / Math.Sqrt(GetJ() / 100.0);
221-
222-
double t =
223-
Math.Pow(
224-
alpha / Math.Pow(1.64 - Math.Pow(0.29, viewingConditions.N), 0.73), 1.0 / 0.9);
225-
double hRad = GetHue() * (Math.PI / 180.0);
226-
227-
double eHue = 0.25 * (Math.Cos(hRad + 2.0) + 3.8);
228-
double ac =
229-
viewingConditions.Aw
230-
* Math.Pow(GetJ() / 100.0, 1.0 / viewingConditions.C / viewingConditions.Z);
231-
double p1 = eHue * (50000.0 / 13.0) * viewingConditions.Nc * viewingConditions.Ncb;
232-
double p2 = (ac / viewingConditions.Nbb);
233-
234-
double hSin = Math.Sin(hRad);
235-
double hCos = Math.Cos(hRad);
236-
237-
double gamma = 23.0 * (p2 + 0.305) * t / (23.0 * p1 + 11.0 * t * hCos + 108.0 * t * hSin);
238-
double a = gamma * hCos;
239-
double b = gamma * hSin;
240-
double rA = (460.0 * p2 + 451.0 * a + 288.0 * b) / 1403.0;
241-
double gA = (460.0 * p2 - 891.0 * a - 261.0 * b) / 1403.0;
242-
double bA = (460.0 * p2 - 220.0 * a - 6300.0 * b) / 1403.0;
243-
244-
double rCBase = Math.Max(0, (27.13 * Math.Abs(rA)) / (400.0 - Math.Abs(rA)));
245-
double rC =
246-
Math.Sign(rA) * (100.0 / viewingConditions.Fl) * Math.Pow(rCBase, 1.0 / 0.42);
247-
double gCBase = Math.Max(0, (27.13 * Math.Abs(gA)) / (400.0 - Math.Abs(gA)));
248-
double gC =
249-
Math.Sign(gA) * (100.0 / viewingConditions.Fl) * Math.Pow(gCBase, 1.0 / 0.42);
250-
double bCBase = Math.Max(0, (27.13 * Math.Abs(bA)) / (400.0 - Math.Abs(bA)));
251-
double bC =
252-
Math.Sign(bA) * (100.0 / viewingConditions.Fl) * Math.Pow(bCBase, 1.0 / 0.42);
253-
double rF = rC / viewingConditions.RgbD[0];
254-
double gF = gC / viewingConditions.RgbD[1];
255-
double bF = bC / viewingConditions.RgbD[2];
256-
257-
double[][] matrix = CAM16RGB_TO_XYZ;
258-
double x = (rF * matrix[0][0]) + (gF * matrix[0][1]) + (bF * matrix[0][2]);
259-
double y = (rF * matrix[1][0]) + (gF * matrix[1][1]) + (bF * matrix[1][2]);
260-
double z = (rF * matrix[2][0]) + (gF * matrix[2][1]) + (bF * matrix[2][2]);
261-
262-
return [x, y, z];
263-
}
264171
}
265172
}

0 commit comments

Comments
 (0)