Archive Browser
Download Cyotek.Windows.Forms.ColorPicker-1.0.2.0.zip version 1.0.2.0, last updated 13/07/2013 (382.27 KB)
Download- md5: 34597ba8a4143a1794524236d9f43524
using System.Drawing;
namespace Cyotek.Windows.Forms
{
// Cyotek Color Picker controls library
// Copyright © 2013 Cyotek. All Rights Reserved.
// http://cyotek.com/blog/tag/colorpicker
// If you use this code in your applications, donations or attribution are welcome
/// <summary>
/// Provides access to color comparision operations.
/// </summary>
public static class ColorComparer
{
#region Class Members
/// <summary>
/// Ccompares two colors by brightness and returns an indication of their relative sort order.
/// </summary>
/// <param name="x">A color to compare to y.</param>
/// <param name="y">A color to compare to x.</param>
public static int Brightness(Color x, Color y)
{
float v1;
float v2;
int result;
v1 = x.GetBrightness();
v2 = y.GetBrightness();
if (v1 < v2)
result = -1;
else if (v1 > v2)
result = 1;
else
result = 0;
return result;
}
/// <summary>
/// Ccompares two colors by hue and returns an indication of their relative sort order.
/// </summary>
/// <param name="x">A color to compare to y.</param>
/// <param name="y">A color to compare to x.</param>
public static int Hue(Color x, Color y)
{
float v1;
float v2;
int result;
v1 = x.GetHue();
v2 = y.GetHue();
if (v1 < v2)
result = -1;
else if (v1 > v2)
result = 1;
else
result = 0;
return result;
}
/// <summary>
/// Ccompares two colors by value and returns an indication of their relative sort order.
/// </summary>
/// <param name="x">A color to compare to y.</param>
/// <param name="y">A color to compare to x.</param>
public static int Value(Color x, Color y)
{
int v1;
int v2;
int result;
v1 = x.R << 16 | x.G << 8 | x.B;
v2 = y.R << 16 | y.G << 8 | y.B;
if (v1 > v2)
result = -1;
else if (v1 < v2)
result = 1;
else
result = 0;
return result;
}
#endregion
}
}
Donate
This software may be used free of charge, but as with all free software there are costs involved to develop and maintain.
If this site or its services have saved you time, please consider a donation to help with running costs and timely updates.
Donate