本文整理匯總了C#中System.Drawing.Rectangle.Deflated方法的典型用法代碼示例。如果您正苦於以下問題:C# Rectangle.Deflated方法的具體用法?C# Rectangle.Deflated怎麽用?C# Rectangle.Deflated使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Drawing.Rectangle
的用法示例。
在下文中一共展示了Rectangle.Deflated方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: DrawBorder
public static void DrawBorder(Graphics graphics, Rectangle rect, Color color)
{
var BrightHighlight = ((ColorF)color * 234 / 220.0).FullAlpha;
var DarkHighlight = ((ColorF)color * 192 / 220.0).FullAlpha;
var BrightShadow = ((ColorF)color * 212 / 220.0).FullAlpha;
var DarkShadow = ((ColorF)color * 130 / 220.0).FullAlpha;
var BrightFace = ((ColorF)color * 248 / 220.0).FullAlpha;
var DarkFace = ((ColorF)color * 178 / 220.0).FullAlpha;
var bgBrush = new SolidBrush(((ColorF)BrightFace + (ColorF)DarkFace) / 2);
float angle = (float)(Math.Atan2(rect.Width, rect.Height) * 180 / Math.PI);
var hlPen = new Pen(new LinearGradientBrush(rect, BrightHighlight, DarkHighlight, angle));
var shPen = new Pen(new LinearGradientBrush(rect, BrightShadow, DarkShadow, angle));
var fcPen = new Pen(new LinearGradientBrush(rect, BrightFace, DarkFace, angle));
graphics.FillRectangle(bgBrush, rect);
graphics.DrawLine(hlPen, new Point(1, 0), new Point(rect.Width - 2, 0));
graphics.DrawLine(hlPen, new Point(0, 1), new Point(0, rect.Height - 2));
graphics.DrawLine(hlPen, new Point(rect.Width - 3, 3), new Point(rect.Width - 3, rect.Height - 3));
graphics.DrawLine(hlPen, new Point(3, rect.Height - 3), new Point(rect.Width - 3, rect.Height - 3));
graphics.DrawLine(shPen, new Point(3, 2), new Point(rect.Width - 4, 2));
graphics.DrawLine(shPen, new Point(2, 3), new Point(2, rect.Height - 4));
graphics.DrawLine(shPen, new Point(rect.Width - 1, 1), new Point(rect.Width - 1, rect.Height - 2));
graphics.DrawLine(shPen, new Point(1, rect.Height - 1), new Point(rect.Width - 1, rect.Height - 1));
graphics.DrawRectangle(fcPen, rect.Deflated(1, 1, 2, 2));
}
示例2: DrawWallpaper
public static void DrawWallpaper(Graphics graphics, Rectangle rect, Color light, Color shadow)
{
float angle = (float)(Math.Atan2(rect.Width, rect.Height) * 180 / Math.PI);
var screenRect = rect.Deflated(3, 3);
var wpBrush = new LinearGradientBrush(rect, light, shadow, angle);
var shadowColorA = ColorF.FromHSLA(shadow.GetHue() / 360, shadow.GetSaturation() * 2, shadow.GetBrightness() / 4, 0.5);
var shadowColorB = ColorF.FromHSLA(light.GetHue() / 360, light.GetSaturation() * 2, light.GetBrightness() / 4, 0.5);
var shadowPen = new Pen(new LinearGradientBrush(rect, shadowColorA, shadowColorB, angle));
var shadowColorC = (shadowColorA + shadowColorB) / 2;
shadowColorC.A /= 2;
var innerShadowPen = new Pen(shadowColorC);
graphics.FillRectangle(wpBrush, screenRect);
graphics.DrawRectangle(innerShadowPen, 4, 3, rect.Width - 9, rect.Height - 6);
graphics.DrawRectangle(shadowPen, screenRect.Deflated(0, 0, 1, 1));
}