Files
Andy De George c0ba284473 Initial winforms content migrated (#18)
* Merge winforms framework content to working branch (#14)

* Breadcrumb / TOC / Move net5 to net folder (#15)

* change path from net5 to net

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Add .net 5 winforms placeholder article (#16)

* added some metadata and adjusted net5 placeholder

* corrections

* corrections

* corrections

* Test1

* Swapping landing page vs concept

* fix links

* Fix links

* Fix desc
2020-09-01 16:26:21 -07:00

4.7 KiB

title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
title ms.date dev_langs helpviewer_keywords ms.assetid
Vector Graphics Overview 03/30/2017
csharp
vb
inclusive-inclusive endpoints
coordinate systems
graphics [Windows Forms], vector graphics
0195df81-66be-452d-bb53-5a582ebfdc09

Vector Graphics Overview

GDI+ draws lines, rectangles, and other shapes on a coordinate system. You can choose from a variety of coordinate systems, but the default coordinate system has the origin in the upper-left corner with the x-axis pointing to the right and the y-axis pointing down. The unit of measure in the default coordinate system is the pixel.

The Building Blocks of GDI+

Vector graphic

A computer monitor creates its display on a rectangular array of dots called picture elements or pixels. The number of pixels that appear on the screen varies from one monitor to the next, and the number of pixels that appear on an individual monitor can usually be configured to some extent by the user.

Vector graphic

When you use GDI+ to draw a line, rectangle, or curve, you provide certain key information about the item to be drawn. For example, you can specify a line by providing two points, and you can specify a rectangle by providing a point, a height, and a width. GDI+ works in conjunction with the display driver software to determine which pixels must be turned on to show the line, rectangle, or curve. The following illustration shows the pixels that are turned on to display a line from the point (4, 2) to the point (12, 8).

Vector graphic

Over time, certain basic building blocks have proven to be the most useful for creating two-dimensional pictures. These building blocks, which are all supported by GDI+, are given in the following list:

  • Lines

  • Rectangles

  • Ellipses

  • Arcs

  • Polygons

  • Cardinal splines

  • Bezier splines

Methods For Drawing with a Graphics Object

The xref:System.Drawing.Graphics class in GDI+ provides the following methods for drawing the items in the previous list: xref:System.Drawing.Graphics.DrawLine%2A, xref:System.Drawing.Graphics.DrawRectangle%2A, xref:System.Drawing.Graphics.DrawEllipse%2A, xref:System.Drawing.Graphics.DrawPolygon%2A, xref:System.Drawing.Graphics.DrawArc%2A, xref:System.Drawing.Graphics.DrawCurve%2A (for cardinal splines), and xref:System.Drawing.Graphics.DrawBezier%2A. Each of these methods is overloaded; that is, each method supports several different parameter lists. For example, one variation of the xref:System.Drawing.Graphics.DrawLine%2A method receives a xref:System.Drawing.Pen object and four integers, while another variation of the xref:System.Drawing.Graphics.DrawLine%2A method receives a xref:System.Drawing.Pen object and two xref:System.Drawing.Point objects.

The methods for drawing lines, rectangles, and Bézier splines have plural companion methods that draw several items in a single call: xref:System.Drawing.Graphics.DrawLines%2A, xref:System.Drawing.Graphics.DrawRectangles%2A, and xref:System.Drawing.Graphics.DrawBeziers%2A. Also, the xref:System.Drawing.Graphics.DrawCurve%2A method has a companion method, xref:System.Drawing.Graphics.DrawClosedCurve%2A, that closes a curve by connecting the ending point of the curve to the starting point.

All of the drawing methods of the xref:System.Drawing.Graphics class work in conjunction with a xref:System.Drawing.Pen object. To draw anything, you must create at least two objects: a xref:System.Drawing.Graphics object and a xref:System.Drawing.Pen object. The xref:System.Drawing.Pen object stores attributes, such as line width and color, of the item to be drawn. The xref:System.Drawing.Pen object is passed as one of the arguments to the drawing method. For example, one variation of the xref:System.Drawing.Graphics.DrawLine%2A method receives a xref:System.Drawing.Pen object and four integers as shown in the following example, which draws a rectangle with a width of 100, a height of 50 and an upper-left corner of (20, 10):

[!code-csharpLinesCurvesAndShapes#11] [!code-vbLinesCurvesAndShapes#11]

See also