Skip to content
This repository was archived by the owner on Dec 27, 2023. It is now read-only.

Commit c998ff0

Browse files
committed
Improved XML documentation. Removed unused code. Removed 11 warnings
1 parent ad08f14 commit c998ff0

File tree

2 files changed

+89
-46
lines changed

2 files changed

+89
-46
lines changed

ColorSharp/src/ColorSpaces/AConvertibleColor.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ public T ConvertTo<T> (ConversionStrategy strategy=ConversionStrategy.Default, L
189189

190190
#region abstract methods
191191

192+
/**
193+
* <summary>Tells us if the object represents a valid color sample in current color space.</summary>
194+
*/
192195
public abstract bool IsInsideColorSpace ();
193196

194197
#endregion

ColorSharp/src/ColorSpaces/CIExyY.cs

Lines changed: 86 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* The MIT License (MIT)
33
* Copyright (c) 2014 Andrés Correa Casablanca
44
*
@@ -21,10 +21,10 @@
2121
* SOFTWARE.
2222
*/
2323

24-
/**
25-
* Contributors:
26-
* - Andrés Correa Casablanca <castarco@gmail.com , castarco@litipk.com>
27-
*/
24+
/*
25+
* Contributors:
26+
* - Andrés Correa Casablanca <castarco@gmail.com , castarco@litipk.com>
27+
*/
2828

2929

3030
using System;
@@ -38,32 +38,46 @@ namespace Litipk.ColorSharp
3838
namespace ColorSpaces
3939
{
4040
/**
41-
* CIE 1931 (2º) xyY Color Space.
41+
* <summary>CIE's 1931 (2º) xyY Color Space.</summary>
4242
*/
43-
public class CIExyY : AConvertibleColor
43+
public sealed class CIExyY : AConvertibleColor
4444
{
45-
#region readonly properties
4645

47-
public readonly double x, y, Y;
46+
#region properties
4847

49-
static readonly xyYPoint nullP = new xyYPoint { x = -1.0, y = -1.0 };
50-
static readonly xyYPoint RsRGB = new xyYPoint { x = 0.640074499456775, y = 0.329970510631693 };
51-
static readonly xyYPoint GsRGB = new xyYPoint { x = 0.3, y = 0.6 };
52-
static readonly xyYPoint BsRGB = new xyYPoint { x = 0.150016622340426, y = 0.0600066489361702 };
48+
#region static properties
49+
// Light wavelengths coordinates in the CIE's 1931 xyY color sapce.
50+
static xyYPoint[] Sharkfin;
5351

52+
// Sharkfin transformation with performance purposes.
53+
static xyYPoint[] SortedSharkfin;
5454
#endregion
5555

56+
#region readonly properties
57+
/**
58+
* <value>x component of the CIE's 1931 color space : X/(X+Y+Z) .</value>
59+
*/
60+
public readonly double x;
5661

57-
#region static properties
62+
/**
63+
* <value>y component of the CIE's 1931 color space : Y/(X+Y+Z) .</value>
64+
*/
65+
public readonly double y;
5866

59-
static xyYPoint[] Sharkfin;
60-
static xyYPoint[] SortedSharkfin;
67+
/**
68+
* <value>Y component of the CIE's 1931 color space. The same Y from CIE's 1931 XYZ color space.</value>
69+
*/
70+
public readonly double Y;
71+
#endregion
6172

6273
#endregion
6374

6475

6576
#region constructors
6677

78+
/**
79+
* Static members initialization
80+
*/
6781
static CIExyY()
6882
{
6983
var mfX = CIE1931XYZ5NmMatchingFunctionX.Instance.Amplitudes;
@@ -84,19 +98,27 @@ static CIExyY()
8498
Array.Sort (SortedSharkfin, new xyYPointComparer());
8599
}
86100

101+
/**
102+
* <summary>HACK: DONT' USE this constructor.</summary>
103+
*/
87104
public CIExyY() {
88105
Conversors.Add (typeof(CIEXYZ), ToXYZ);
89106
}
90107

91-
protected CIExyY(AConvertibleColor dataSource=null) : base(dataSource) {
92-
Conversors.Add (typeof(CIEXYZ), ToXYZ);
93-
}
94-
95-
public CIExyY (double x, double y, double Y, AConvertibleColor dataSource=null) : this(dataSource)
108+
/**
109+
* <summary>Creates a new color sample in the CIE's 1931 xyY color space</summary>
110+
* <param name="x">CIE's 1931 xyY x coordinate</param>
111+
* <param name="y">CIE's 1931 xyY y coordinate</param>
112+
* <param name="Y">Lightness parameter</param>
113+
* <param name="dataSource">If you aren't working with ColorSharp internals, don't use this parameter</param>
114+
*/
115+
public CIExyY (double x, double y, double Y, AConvertibleColor dataSource=null) : base(dataSource)
96116
{
97117
this.x = x;
98118
this.y = y;
99119
this.Y = Y;
120+
121+
Conversors.Add (typeof(CIEXYZ), ToXYZ);
100122
}
101123

102124
#endregion
@@ -114,6 +136,9 @@ public CIEXYZ ToXYZ (ConversionStrategy strategy=ConversionStrategy.Default)
114136

115137
#region inherited methods
116138

139+
/**
140+
* <inheritdoc />
141+
*/
117142
public override bool IsInsideColorSpace()
118143
{
119144
// Fast checks
@@ -134,7 +159,43 @@ public override bool IsInsideColorSpace()
134159
}
135160

136161
/**
137-
* Monotone Chain algorithm
162+
* <inheritdoc />
163+
*/
164+
public override bool Equals(Object obj)
165+
{
166+
CIExyY xyYObj = obj as CIExyY;
167+
168+
if (xyYObj == null || GetHashCode () != obj.GetHashCode ())
169+
return false;
170+
171+
return (
172+
Math.Abs (x - xyYObj.x) <= double.Epsilon &&
173+
Math.Abs (y - xyYObj.y) <= double.Epsilon &&
174+
Math.Abs (Y - xyYObj.Y) <= double.Epsilon
175+
);
176+
}
177+
178+
/**
179+
* <inheritdoc />
180+
*/
181+
public override int GetHashCode ()
182+
{
183+
int hash = 19;
184+
185+
hash = hash * 31 + x.GetHashCode ();
186+
hash = hash * 31 + y.GetHashCode ();
187+
hash = hash * 31 + Y.GetHashCode ();
188+
189+
return hash;
190+
}
191+
192+
#endregion
193+
194+
#region internal utilities
195+
196+
/**
197+
* Monotone Chain algorithm. See
198+
* http://en.wikibooks.org/wiki/Algorithm_Implementation/Geometry/Convex_hull/Monotone_chain
138199
*/
139200
static xyYPoint[] findConvexHull(xyYPoint[] points)
140201
{
@@ -162,34 +223,13 @@ static xyYPoint[] findConvexHull(xyYPoint[] points)
162223
return tmpHull;
163224
}
164225

226+
/**
227+
* Used inside findConvexHull method.
228+
*/
165229
static double cross(xyYPoint O, xyYPoint A, xyYPoint B) {
166230
return (A.x - O.x) * (B.y - O.y) - (A.y - O.y) * (B.x - O.x);
167231
}
168232

169-
public override bool Equals(Object obj)
170-
{
171-
CIExyY xyYObj = obj as CIExyY;
172-
173-
if (xyYObj == null || GetHashCode () != obj.GetHashCode ())
174-
return false;
175-
176-
return (
177-
Math.Abs (x - xyYObj.x) <= double.Epsilon &&
178-
Math.Abs (y - xyYObj.y) <= double.Epsilon &&
179-
Math.Abs (Y - xyYObj.Y) <= double.Epsilon
180-
);
181-
}
182-
public override int GetHashCode ()
183-
{
184-
int hash = 19;
185-
186-
hash = hash * 31 + x.GetHashCode ();
187-
hash = hash * 31 + y.GetHashCode ();
188-
hash = hash * 31 + Y.GetHashCode ();
189-
190-
return hash;
191-
}
192-
193233
#endregion
194234
}
195235
}

0 commit comments

Comments
 (0)