Graphics 2 - Gradients & more advanced brushes - CSharp #4 ~ VBTheory™ Tutorials

Friday, October 17, 2014

Graphics 2 - Gradients & more advanced brushes - CSharp #4


Code:
SolidBrush:
 SolidBrush b = new SolidBrush(Color.Blue);
Or:
 Brush b = SystemBrushes.Control;
Or:
 Brush b = Brushes.Blue;

TextureBrush
 TextureBrush b = new TextureBrush(new Bitmap(@"PATH HERE", WrapMode.Tile);

HatchBrush
 HatchBrush b = new HatchBrush(HatchStyle.Cross, Color.Black);

LinearGradientBrush
 LinearGradientBrush b = new LinearGradientBrush(new Point(X1, Y1), new Point(X2, Y2), color1, color2);

PathGradientBrush
 PathGradientBrush b = new PathGradientBrush(new [] {new Point(X, Y), new Point(X, Y), ...})
 b.CenterPoint = new Point(X, Y);
 b.CenterColor = Color.Blue;
 b.SurroundColor = new [] {Color.Red, Color.Black, ....};

Don't forget to add this at the end to fill the form with your brush:
 e.Graphics.FillRectangle(b, e.ClipRectangle);


HatchStyles:
All HatchStyles available in C#



Share