本文整理汇总了C#中Color.ScaleBrightness方法的典型用法代码示例。如果您正苦于以下问题:C# Color.ScaleBrightness方法的具体用法?C# Color.ScaleBrightness怎么用?C# Color.ScaleBrightness使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Color
的用法示例。
在下文中一共展示了Color.ScaleBrightness方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MixWith
public static Color MixWith(this Color c, Color other, float ratio, bool lockBrightness = false)
{
float myRatio = 1.0f - ratio;
if (lockBrightness)
{
int oldBrightness = Math.Max(c.R, Math.Max(c.G, c.B));
int newBrightness = Math.Max(other.R, Math.Max(other.G, other.B));
other = other.ScaleBrightness((float)oldBrightness / (float)newBrightness);
}
return Color.FromArgb(c.A,
(byte)Math.Min(Math.Max((float)c.R * myRatio + (float)other.R * ratio, 0.0f), 255.0f),
(byte)Math.Min(Math.Max((float)c.G * myRatio + (float)other.G * ratio, 0.0f), 255.0f),
(byte)Math.Min(Math.Max((float)c.B * myRatio + (float)other.B * ratio, 0.0f), 255.0f));
}
示例2: DrawGroupHeaderBackground
public void DrawGroupHeaderBackground(Graphics g, Rectangle rect, Color baseColor, GroupHeaderStyle style)
{
if (rect.Height == 0 || rect.Width == 0) return;
Color lightColor = baseColor.ScaleBrightness(style == GroupHeaderStyle.SmoothSunken ? 0.85f : 1.1f);
Color darkColor = baseColor.ScaleBrightness(style == GroupHeaderStyle.SmoothSunken ? 0.95f : 0.85f);
LinearGradientBrush gradientBrush = new LinearGradientBrush(rect, lightColor, darkColor, 90.0f);
if (style != GroupHeaderStyle.Simple && style != GroupHeaderStyle.Flat)
g.FillRectangle(gradientBrush, rect);
else
g.FillRectangle(new SolidBrush(baseColor), rect);
if (style == GroupHeaderStyle.Flat) return;
g.DrawLine(new Pen(Color.FromArgb(128, Color.White)), rect.Left, rect.Top, rect.Right, rect.Top);
g.DrawLine(new Pen(Color.FromArgb(64, Color.Black)), rect.Left, rect.Bottom - 1, rect.Right, rect.Bottom - 1);
g.DrawLine(new Pen(Color.FromArgb(64, Color.White)), rect.Left, rect.Top, rect.Left, rect.Bottom - 1);
g.DrawLine(new Pen(Color.FromArgb(32, Color.Black)), rect.Right, rect.Top, rect.Right, rect.Bottom - 1);
}
示例3: GetBackgroundColor
public Color GetBackgroundColor(Color baseColor, bool focus, int indent)
{
float brightnessScale = 1.0f;
if (focus) brightnessScale *= this.FocusBrightnessScale;
brightnessScale *= (float)Math.Pow(this.NestedBrightnessScale, Math.Max((indent - this.NestedBrightnessOffset) / PropertyEditing.GroupedPropertyEditor.DefaultIndent, 0));
if (brightnessScale != 1.0f) baseColor = baseColor.ScaleBrightness(brightnessScale);
return baseColor;
}