本文整理汇总了C#中Color.GetBrightness方法的典型用法代码示例。如果您正苦于以下问题:C# Color.GetBrightness方法的具体用法?C# Color.GetBrightness怎么用?C# Color.GetBrightness使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Color
的用法示例。
在下文中一共展示了Color.GetBrightness方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SimilarColors
private static bool SimilarColors(Color colorOne, Color colorTwo)
{
if (Math.Abs(colorOne.GetHue()-colorTwo.GetHue()) <= 36)
{
//Console.WriteLine("Hue");
return true;
}
if (Math.Abs(colorOne.GetBrightness()-colorTwo.GetBrightness()) <= .1)
{
//Console.WriteLine("Hue");
return true;
}
if (Math.Abs(colorOne.GetSaturation()-colorTwo.GetSaturation()) <= .1)
{
//Console.WriteLine("Hue");
return true;
}
return false;
}
示例2: UpdateHsb
private void UpdateHsb(Color value) {
Hue = (int)value.GetHue();
var brightness = value.GetBrightness();
Brightness = (int)(brightness * 100);
var saturation = value.GetSaturation();
Saturation = (int)(saturation * 100);
UpdateThumbPosition();
}
示例3: ToSurface
public static unsafe void ToSurface(this Texture2D image, TextSurface surface, Color[] cachedColorArray, bool blockMode = false)
{
int imageWidth = image.Width;
int imageHeight = image.Height;
image.GetData<Color>(cachedColorArray);
SurfaceEditor editor = new SurfaceEditor(surface);
editor.Clear();
global::System.Threading.Tasks.Parallel.For(0, imageHeight / surface.Font.Size.Y, (h) =>
//for (int h = 0; h < imageHeight / surface.Font.Size.Y; h++)
{
int startY = (h * surface.Font.Size.Y);
//System.Threading.Tasks.Parallel.For(0, imageWidth / surface.Font.Size.X, (w) =>
for (int w = 0; w < imageWidth / surface.Font.Size.X; w++)
{
int startX = (w * surface.Font.Size.X);
float allR = 0;
float allG = 0;
float allB = 0;
for (int y = 0; y < surface.Font.Size.Y; y++)
{
for (int x = 0; x < surface.Font.Size.X; x++)
{
int cY = y + startY;
int cX = x + startX;
Color color = cachedColorArray[cY * imageWidth + cX];
allR += color.R;
allG += color.G;
allB += color.B;
}
}
byte sr = (byte)(allR / (surface.Font.Size.X * surface.Font.Size.Y));
byte sg = (byte)(allG / (surface.Font.Size.X * surface.Font.Size.Y));
byte sb = (byte)(allB / (surface.Font.Size.X * surface.Font.Size.Y));
var newColor = new Color(sr, sg, sb);
float sbri = newColor.GetBrightness() * 255;
if (blockMode)
{
if (sbri > 204)
editor.SetGlyph(w, h, 219, newColor); //█
else if (sbri > 152)
editor.SetGlyph(w, h, 178, newColor); //▓
else if (sbri > 100)
editor.SetGlyph(w, h, 177, newColor); //▒
else if (sbri > 48)
editor.SetGlyph(w, h, 176, newColor); //░
}
else
{
if (sbri > 230)
editor.SetGlyph(w, h, (int)'#', newColor);
else if (sbri > 207)
editor.SetGlyph(w, h, (int)'&', newColor);
else if (sbri > 184)
editor.SetGlyph(w, h, (int)'$', newColor);
else if (sbri > 161)
editor.SetGlyph(w, h, (int)'X', newColor);
else if (sbri > 138)
editor.SetGlyph(w, h, (int)'x', newColor);
else if (sbri > 115)
editor.SetGlyph(w, h, (int)'=', newColor);
else if (sbri > 92)
editor.SetGlyph(w, h, (int)'+', newColor);
else if (sbri > 69)
editor.SetGlyph(w, h, (int)';', newColor);
else if (sbri > 46)
editor.SetGlyph(w, h, (int)':', newColor);
else if (sbri > 23)
editor.SetGlyph(w, h, (int)'.', newColor);
}
}
}
);
}
示例4: HSLColor
public HSLColor(Color color)
{
Hue = color.GetHue();
Saturation = color.GetSaturation();
Lightness = color.GetBrightness();
}