Skip to content

Commit 228744e

Browse files
author
Johann Dirry
committed
Making enum values PascalCase and using explicit types where not obvious
1 parent 270ebf9 commit 228744e

37 files changed

+651
-650
lines changed

src/MaterialDesign3.MaterialColorUtilities/Blend/Blend.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ public static int Harmonize(int designColor, int sourceColor)
2222
{
2323
var fromHct = Hct.FromInt(designColor);
2424
var toHct = Hct.FromInt(sourceColor);
25-
var differenceDegrees = DifferenceDegrees(fromHct.Hue, toHct.Hue);
26-
var rotationDegrees = Min(differenceDegrees * 0.5, 15.0);
27-
var outputHue = SanitizeDegreesDouble(
25+
double differenceDegrees = DifferenceDegrees(fromHct.Hue, toHct.Hue);
26+
double rotationDegrees = Min(differenceDegrees * 0.5, 15.0);
27+
double outputHue = SanitizeDegreesDouble(
2828
fromHct.Hue + rotationDegrees * RotationDirection(fromHct.Hue, toHct.Hue));
2929
return Hct.From(outputHue, fromHct.Chroma, fromHct.Tone).Argb;
3030
}
@@ -41,7 +41,7 @@ public static int Harmonize(int designColor, int sourceColor)
4141
/// </returns>
4242
public static int HctHue(int from, int to, double amount)
4343
{
44-
var ucs = Cam16Ucs(from, to, amount);
44+
int ucs = Cam16Ucs(from, to, amount);
4545
var ucsCam = Cam16.FromInt(ucs);
4646
var fromCam = Cam16.FromInt(from);
4747
var blended = Hct.From(ucsCam.GetHue(), fromCam.GetChroma(), ColorUtils.LstarFromArgb(from));
@@ -61,15 +61,15 @@ public static int Cam16Ucs(int from, int to, double amount)
6161
{
6262
var fromCam = Cam16.FromInt(from);
6363
var toCam = Cam16.FromInt(to);
64-
var fromJ = fromCam.GetJstar();
65-
var fromA = fromCam.GetAstar();
66-
var fromB = fromCam.GetBstar();
67-
var toJ = toCam.GetJstar();
68-
var toA = toCam.GetAstar();
69-
var toB = toCam.GetBstar();
70-
var jstar = fromJ + (toJ - fromJ) * amount;
71-
var astar = fromA + (toA - fromA) * amount;
72-
var bstar = fromB + (toB - fromB) * amount;
64+
double fromJ = fromCam.GetJstar();
65+
double fromA = fromCam.GetAstar();
66+
double fromB = fromCam.GetBstar();
67+
double toJ = toCam.GetJstar();
68+
double toA = toCam.GetAstar();
69+
double toB = toCam.GetBstar();
70+
double jstar = fromJ + (toJ - fromJ) * amount;
71+
double astar = fromA + (toA - fromA) * amount;
72+
double bstar = fromB + (toB - fromB) * amount;
7373
return Cam16.FromUcs(jstar, astar, bstar).ToInt();
7474
}
75-
}
75+
}

src/MaterialDesign3.MaterialColorUtilities/Contrast/Contrast.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ public static class Contrast
7474
/// </summary>
7575
public static double RatioOfYs(double y1, double y2)
7676
{
77-
var lighter = y1 > y2 ? y1 : y2;
78-
var darker = (lighter == y2) ? y1 : y2;
77+
double lighter = y1 > y2 ? y1 : y2;
78+
double darker = (lighter == y2) ? y1 : y2;
7979
return (lighter + 5.0) / (darker + 5.0);
8080
}
8181

@@ -113,20 +113,20 @@ public static double Lighter(double tone, double ratio)
113113
{
114114
return -1.0;
115115
}
116-
var darkY = ColorUtils.YFromLstar(tone);
117-
var lightY = ratio * (darkY + 5.0) - 5.0;
116+
double darkY = ColorUtils.YFromLstar(tone);
117+
double lightY = ratio * (darkY + 5.0) - 5.0;
118118
if (lightY is < 0.0 or > 100.0)
119119
{
120120
return -1.0;
121121
}
122-
var realContrast = RatioOfYs(lightY, darkY);
123-
var delta = Abs(realContrast - ratio);
122+
double realContrast = RatioOfYs(lightY, darkY);
123+
double delta = Abs(realContrast - ratio);
124124
if (realContrast < ratio && delta > ContrastRatioEpsilon)
125125
{
126126
return -1.0;
127127
}
128128

129-
var returnValue = ColorUtils.LstarFromY(lightY) + LuminanceGamutMapTolerance;
129+
double returnValue = ColorUtils.LstarFromY(lightY) + LuminanceGamutMapTolerance;
130130
if (returnValue is < 0.0 or > 100.0)
131131
{
132132
return -1.0;
@@ -144,7 +144,7 @@ public static double Lighter(double tone, double ratio)
144144
/// <param name="ratio">Desired contrast ratio of return value and tone parameter.</param>
145145
public static double LighterUnsafe(double tone, double ratio)
146146
{
147-
var lighterSafe = Lighter(tone, ratio);
147+
double lighterSafe = Lighter(tone, ratio);
148148
return lighterSafe < 0.0 ? 100.0 : lighterSafe;
149149
}
150150

@@ -160,19 +160,19 @@ public static double Darker(double tone, double ratio)
160160
{
161161
return -1.0;
162162
}
163-
var lightY = ColorUtils.YFromLstar(tone);
164-
var darkY = ((lightY + 5.0) / ratio) - 5.0;
163+
double lightY = ColorUtils.YFromLstar(tone);
164+
double darkY = ((lightY + 5.0) / ratio) - 5.0;
165165
if (darkY is < 0.0 or > 100.0)
166166
{
167167
return -1.0;
168168
}
169-
var realContrast = RatioOfYs(lightY, darkY);
170-
var delta = Abs(realContrast - ratio);
169+
double realContrast = RatioOfYs(lightY, darkY);
170+
double delta = Abs(realContrast - ratio);
171171
if (realContrast < ratio && delta > ContrastRatioEpsilon)
172172
{
173173
return -1.0;
174174
}
175-
var returnValue = ColorUtils.LstarFromY(darkY) - LuminanceGamutMapTolerance;
175+
double returnValue = ColorUtils.LstarFromY(darkY) - LuminanceGamutMapTolerance;
176176
if (returnValue is < 0.0 or > 100.0)
177177
{
178178
return -1.0;
@@ -190,7 +190,7 @@ public static double Darker(double tone, double ratio)
190190
/// <param name="ratio">Desired contrast ratio of return value and tone parameter.</param>
191191
public static double DarkerUnsafe(double tone, double ratio)
192192
{
193-
var darkerSafe = Darker(tone, ratio);
193+
double darkerSafe = Darker(tone, ratio);
194194
return Max(0.0, darkerSafe);
195195
}
196196
}

src/MaterialDesign3.MaterialColorUtilities/Dislike/DislikeAnalyzer.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ public static class DislikeAnalyzer
2020
/// </summary>
2121
public static bool IsDisliked(Hct hct)
2222
{
23-
var roundedHue = Round(hct.Hue);
24-
var roundedChroma = Round(hct.Chroma);
25-
var roundedTone = Round(hct.Tone);
23+
double roundedHue = Round(hct.Hue);
24+
double roundedChroma = Round(hct.Chroma);
25+
double roundedTone = Round(hct.Tone);
2626

27-
var huePasses = roundedHue is >= 90.0 and <= 111.0;
28-
var chromaPasses = roundedChroma > 16.0;
29-
var tonePasses = roundedTone < 65.0;
27+
bool huePasses = roundedHue is >= 90.0 and <= 111.0;
28+
bool chromaPasses = roundedChroma > 16.0;
29+
bool tonePasses = roundedTone < 65.0;
3030

3131
return huePasses && chromaPasses && tonePasses;
3232
}
@@ -40,4 +40,4 @@ public static Hct FixIfDisliked(Hct hct)
4040
? Hct.From(hct.Hue, hct.Chroma, 70.0)
4141
: hct;
4242
}
43-
}
43+
}

0 commit comments

Comments
 (0)