Figure 6-3 Use Graphics.DrawPolygon to create shapes made of multiple lines in C#

Printer QR Code ISO/IEC18004 in C# Figure 6-3 Use Graphics.DrawPolygon to create shapes made of multiple lines

Figure 6-3 Use Graphics.DrawPolygon to create shapes made of multiple lines
Painting Quick Response Code In Visual C#.NET
Using Barcode generation for .NET framework Control to generate, create QR Code JIS X 0510 image in VS .NET applications.
www.OnBarcode.com
QR-Code Reader In Visual C#.NET
Using Barcode reader for .NET framework Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
NOTE Horizontal, and then vertical
Barcode Creation In Visual C#
Using Barcode generator for .NET framework Control to generate, create bar code image in .NET framework applications.
www.OnBarcode.com
Barcode Recognizer In C#
Using Barcode decoder for .NET Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
When you pass coordinates to any .NET Framework method, you will pass the horizontal (X) coordinate first, and then the vertical (Y) coordinate second. In a 100-by-100 pixel image, 0,0 is the upper left corner; 100,0 is the upper right corner; 0, 100 is the lower left corner; and 100,100 is the lower right corner.
Draw QR Code JIS X 0510 In .NET
Using Barcode generation for ASP.NET Control to generate, create QR Code image in ASP.NET applications.
www.OnBarcode.com
Generate QR Code JIS X 0510 In Visual Studio .NET
Using Barcode maker for .NET Control to generate, create QR-Code image in .NET framework applications.
www.OnBarcode.com
6
QR Code Drawer In VB.NET
Using Barcode maker for .NET Control to generate, create QR Code JIS X 0510 image in .NET framework applications.
www.OnBarcode.com
Creating QR In Visual C#
Using Barcode generator for VS .NET Control to generate, create QR image in VS .NET applications.
www.OnBarcode.com
Graphics
Encode GS1 128 In C#.NET
Using Barcode creation for VS .NET Control to generate, create EAN128 image in .NET framework applications.
www.OnBarcode.com
Generate UPC A In C#.NET
Using Barcode generation for .NET framework Control to generate, create UPCA image in .NET framework applications.
www.OnBarcode.com
How to Customize Pens
Code 39 Extended Creation In Visual C#
Using Barcode drawer for .NET framework Control to generate, create Code39 image in VS .NET applications.
www.OnBarcode.com
Making International Standard Book Number In C#
Using Barcode printer for .NET Control to generate, create ISBN - 13 image in .NET framework applications.
www.OnBarcode.com
Besides controlling the color and size of a pen, which are specified in the Pen constructor, you can also control the pattern and endcaps. The endcaps are the ends of the line, and you can use them to create arrows and other special effects. By default, pens draw solid lines. To draw a dotted line, create an instance of the Pen class, and then set the Pen.DashStyle property to one of these values: DashStyle.Dash, DashStyle.DashDot, DashStyle.DashDotDot, DashStyle.Dot, or DashStyle.Solid. The following code, which requires the System.Drawing.Drawing2D namespace, demonstrates each of these pen styles and creates the result shown in Figure 6-4:
Recognize QR Code ISO/IEC18004 In Visual Basic .NET
Using Barcode scanner for VS .NET Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
DataMatrix Printer In None
Using Barcode creator for Software Control to generate, create DataMatrix image in Software applications.
www.OnBarcode.com
' VB Dim g As Graphics = Me.CreateGraphics Dim p As Pen = New Pen(Color.Red, 7) p.DashStyle = DashStyle.Dot g.DrawLine(p, 50, 25, 400, 25) p.DashStyle = DashStyle.Dash g.DrawLine(p, 50, 50, 400, 50) p.DashStyle = DashStyle.DashDot g.DrawLine(p, 50, 75, 400, 75) p.DashStyle = DashStyle.DashDotDot g.DrawLine(p, 50, 100, 400, 100) p.DashStyle = DashStyle.Solid g.DrawLine(p, 50, 125, 400, 125) // C# Graphics g = this.CreateGraphics(); Pen p = new Pen(Color.Red, 7); p.DashStyle = DashStyle.Dot; g.DrawLine(p, 50, 25, 400, 25); p.DashStyle = DashStyle.Dash; g.DrawLine(p, 50, 50, 400, 50); p.DashStyle = DashStyle.DashDot; g.DrawLine(p, 50, 75, 400, 75); p.DashStyle = DashStyle.DashDotDot; g.DrawLine(p, 50, 100, 400, 100); p.DashStyle = DashStyle.Solid; g.DrawLine(p, 50, 125, 400, 125);
Code-39 Creation In Java
Using Barcode encoder for Java Control to generate, create Code 39 Extended image in Java applications.
www.OnBarcode.com
Creating Bar Code In None
Using Barcode generation for Microsoft Word Control to generate, create bar code image in Office Word applications.
www.OnBarcode.com
Lesson 1: Drawing Graphics
Generating PDF 417 In Java
Using Barcode creator for BIRT Control to generate, create PDF-417 2d barcode image in Eclipse BIRT applications.
www.OnBarcode.com
Recognize UCC-128 In Visual C#.NET
Using Barcode scanner for .NET Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
Figure 6-4 The Pen class provides several dash styles
Decoding UPC-A In Visual Studio .NET
Using Barcode reader for Visual Studio .NET Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
QR-Code Creation In Java
Using Barcode encoder for Java Control to generate, create Denso QR Bar Code image in Java applications.
www.OnBarcode.com
You can also use the Pen.DashOffset and Pen.DashPattern properties to define a custom dash pattern. To control the endcaps and create arrows or callouts, modify the Pen.StartCap and Pen.EndCap properties using the LineCap enumeration. The following code demonstrates most of the pen cap styles and creates the result shown in Figure 6-5:
' VB Dim g As Graphics = Me.CreateGraphics Dim p As Pen = New Pen(Color.Red, 10) p.StartCap = LineCap.ArrowAnchor p.EndCap = LineCap.DiamondAnchor g.DrawLine(p, 50, 25, 400, 25) p.StartCap = LineCap.SquareAnchor p.EndCap = LineCap.Triangle g.DrawLine(p, 50, 50, 400, 50) p.StartCap = LineCap.Flat p.EndCap = LineCap.Round g.DrawLine(p, 50, 75, 400, 75) p.StartCap = LineCap.RoundAnchor p.EndCap = LineCap.Square g.DrawLine(p, 50, 100, 400, 100) // C# Graphics g = this.CreateGraphics(); Pen p = new Pen(Color.Red, 10); p.StartCap = LineCap.ArrowAnchor; p.EndCap = LineCap.DiamondAnchor; g.DrawLine(p, 50, 25, 400, 25); p.StartCap = LineCap.SquareAnchor; p.EndCap = LineCap.Triangle; g.DrawLine(p, 50, 50, 400, 50);
6
Graphics
p.StartCap = LineCap.Flat; p.EndCap = LineCap.Round; g.DrawLine(p, 50, 75, 400, 75); p.StartCap = LineCap.RoundAnchor; p.EndCap = LineCap.Square; g.DrawLine(p, 50, 100, 400, 100);
Figure 6-5
The Pen class provides options for startcaps and endcaps
How to Fill Shapes
For most of the Draw methods, the Graphics class also has Fill methods that draw a shape and fill in the contents. These methods work exactly like the Draw methods, except they require an instance of the Brush class instead of the Pen class. The Brush class is abstract, so you must instantiate one of the child classes:
System.Drawing.Drawing2D.HatchBrush Defines a rectangular brush with a hatch
style, a foreground color, and a background color
System.Drawing.Drawing2D.LinearGradientBrush
Encapsulates a brush with a linear gradient that provides a visually appealing, professional-looking fill
System.Drawing.Drawing2D.PathGradientBrush Provides similar functionality to
LinearGradientBrush; however, you can define a complex fill pattern that fades between multiple points
System.Drawing.SolidBrush
Defines a brush of a single color
System.Drawing.TextureBrush Defines a brush made from an image that can be
tiled across a shape, like a wallpaper design For example, the following code draws a solid maroon, five-sided polygon, as shown in Figure 6-6:
' VB Dim g As Graphics = Me.CreateGraphics Dim b As Brush = New SolidBrush(Color.Maroon) Dim points As Point() = New Point() {New Point(10, 10), New Point(10, 100), _ New Point(50, 65), New Point(100, 100), New Point(85, 40)}
Lesson 1: Drawing Graphics
g.FillPolygon(b, points) // C# Graphics g = this.CreateGraphics(); Brush b = new SolidBrush(Color.Maroon); Point[] points = new Point[] {new Point(10, 10), new Point(10, 100), new Point(50, 65), new Point(100, 100), new Point(85, 40)}; g.FillPolygon(b, points);
Copyright © OnBarcode.com . All rights reserved.