Skip to content

Commit

Permalink
Clean up some APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
albi005 committed Apr 24, 2022
1 parent 82e0891 commit 6a8ac4b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
17 changes: 9 additions & 8 deletions MaterialColorUtilities/ColorAppearance/Cam16.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ namespace MaterialColorUtilities.ColorAppearance;
public class Cam16
{
// Transforms XYZ color space coordinates to 'cone'/'RGB' responses in CAM16.
public static double[][] XyzToCam16Rgb =
internal static readonly double[][] XyzToCam16Rgb =
{
new[] { 0.401288, 0.650173, -0.051461 },
new[] { -0.250268, 1.204414, 0.045854 },
new[] { -0.002079, 0.048952, 0.953127 }
};

// Transforms 'cone'/'RGB' responses in CAM16 to XYZ color space coordinates.
public static double[][] Cam16RgbToXyz =
internal static readonly double[][] Cam16RgbToXyz =
{
new[] { 1.8620678, -1.0112547, 0.14918678 },
new[] { 0.38752654, 0.62144744, -0.00897398 },
Expand Down Expand Up @@ -91,6 +91,11 @@ public class Cam16
/// <summary>b* coordinate in CAM16-UCS</summary>
public double Bstar { get; set; }

/// <summary>
/// CAM16 instances also have coordinates in the CAM16-UCS space, called J*,
/// a*, b*, or jstar, astar, bstar in code. CAM16-UCS is included in the CAM16
/// specification, and should be used when measuring distances between colors.
/// </summary>
public double Distance(Cam16 other)
{
double dJ = Jstar - other.Jstar;
Expand Down Expand Up @@ -144,7 +149,6 @@ private Cam16(double hue, double chroma, double j, double q, double m, double s,
/// </summary>
/// <param name="argb">ARGB representation of a color.</param>
/// <param name="viewingConditions">Information about the environment where the color was observed.</param>
/// <returns></returns>
public static Cam16 FromIntInViewingConditions(int argb, ViewingConditions viewingConditions)
{
// Transform ARGB int to XYZ
Expand Down Expand Up @@ -240,7 +244,7 @@ public static Cam16 FromIntInViewingConditions(int argb, ViewingConditions viewi
/// <param name="c">chroma</param>
/// <param name="h">hue</param>
/// <param name="viewingConditions">Information about the environment where the color was observed.</param>
private static Cam16 FromJchInViewingConditions(
public static Cam16 FromJchInViewingConditions(
double j, double c, double h, ViewingConditions viewingConditions)
{
double q =
Expand Down Expand Up @@ -299,10 +303,7 @@ public static Cam16 FromIntInViewingConditions(int argb, ViewingConditions viewi
/// which are near-identical to the default viewing conditions for sRGB.
/// </summary>
/// <returns></returns>
public int ToInt()
{
return Viewed(ViewingConditions.Default);
}
public int ToInt() => Viewed(ViewingConditions.Default);

/// <summary>
/// ARGB representation of the color, in defined viewing conditions.
Expand Down
22 changes: 11 additions & 11 deletions MaterialColorUtilities/ColorAppearance/ViewingConditions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class ViewingConditions
/// <summary>
/// sRGB-like viewing conditions.
/// </summary>
public static ViewingConditions Default = Make(
public static ViewingConditions Default { get; } = Make(
new[]
{
ColorUtils.WhitePointD65[0],
Expand All @@ -46,16 +46,16 @@ public class ViewingConditions
2.0,
false);

public double N { get; set; }
public double Aw { get; set; }
public double Nbb { get; set; }
public double Ncb { get; set; }
public double C { get; set; }
public double Nc { get; set; }
public double[] RgbD { get; set; }
public double Fl { get; set; }
public double FlRoot { get; set; }
public double Z { get; set; }
public double N { get; }
public double Aw { get; }
public double Nbb { get; }
public double Ncb { get; }
public double C { get; }
public double Nc { get; }
public double[] RgbD { get; }
public double Fl { get; }
public double FlRoot { get; }
public double Z { get; }

public static ViewingConditions Make(
double[] whitePoint,
Expand Down
2 changes: 1 addition & 1 deletion MaterialColorUtilities/Utils/MathUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace MaterialColorUtilities.Utils;
/// <summary>
/// Utility methods for mathematical operations.
/// </summary>
public class MathUtils
public static class MathUtils
{
/// <summary>The linear interpolation function.</summary>
/// <returns>
Expand Down
2 changes: 1 addition & 1 deletion MaterialColorUtilities/Utils/StringUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// <summary>
/// Utility methods for string representations of colors.
/// </summary>
public class StringUtils
public static class StringUtils
{
/// <summary>
/// Hex string representing color, ex. #ff0000 for red.
Expand Down

0 comments on commit 6a8ac4b

Please sign in to comment.