new Pen(lgbrush, Math.Min(cx, cy) / 25), Gradient Pen : Pens : Graphics C# Source Code


Custom Search

C# Source Code » Graphics » Pens »

 

new Pen(lgbrush, Math.Min(cx, cy) / 25), Gradient Pen








    
 

using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
   
class GradientPen: Form 
{
     public static void Main()
     {
          Application.Run(new GradientPen());
     }
     public GradientPen()
     {
          ResizeRedraw = true; 
     }
     protected override void OnPaint(PaintEventArgs pea)
     {
          DoPage(pea.Graphics, ForeColor,ClientSize.Width, ClientSize.Height);
     }        
     protected void DoPage(Graphics grfx, Color clr, int cx, int cy)
     {
          Brush lgbrush = new LinearGradientBrush(
                                   new Rectangle(0, 0, cx, cy), 
                                   Color.White, Color.Black,
                                   LinearGradientMode.BackwardDiagonal);
   
          Pen pen = new Pen(lgbrush, Math.Min(cx, cy) / 25);
   
          pen.Alignment = PenAlignment.Inset;
   
          grfx.DrawRectangle(pen, 0, 0, cx, cy);
          grfx.DrawLine(pen, 0, 0, cx, cy);
          grfx.DrawLine(pen, 0, cy, cx, 0);
     }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Graphics
» Pens