当前位置: 首页>>代码示例>>C#>>正文


C# Color.ScaleBrightness方法代码示例

本文整理汇总了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));
 }
开发者ID:highordersoft,项目名称:winforms,代码行数:14,代码来源:ExtMethodsColor.cs

示例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);
		}
开发者ID:Andrea,项目名称:duality-withsvn-history,代码行数:20,代码来源:ControlRenderer.cs

示例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;
        }
开发者ID:highordersoft,项目名称:winforms,代码行数:10,代码来源:ControlRenderer.cs


注:本文中的Color.ScaleBrightness方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。