當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。