GDI + graphics drawing methods in C #

Source: Internet
Author: User

GDI + Graphics Drawing method

1. First, for drawing graphics, the namespace must first be imported: using System.Drawing.Drawing2D;

2. Then write the program in an event

First, the object of the graphics is instantiated;

Then it is an instanced pen (pen) or brush (brush);

Instantiating a pen mypen = new Pen (color (selection color), line thickness of the pen)

instance of the Brush

SolidBrush: Its instantiation only needs to specify the value of the Color property;

HatchBrush: Its instantiation needs to specify the graphics and colors that need to be drawn;

Linergradientbrush: is used to draw the gradient color map, need to pass in two points and two points of color;

3. Basic Graph Drawing algorithm

Line: Two points indicated on OK;

Rectangle: The coordinates of the incoming starting point and the height and width of the rectangle;

Ellipse: A fixed border method that specifies the coordinates of the upper-left corner of the border and the height and width of the border;

Arc: Still adopt the way that the frame is fixed, then use the starting angle and rotation angle to fix this arc;

Sector: the drawing of a sector is drawn with the direction of the center coordinate and then into the starting angle and rotation angle, which is somewhat similar to drawing arcs.

Polygon: The polygon is drawn in a way that determines the point, then all the points are concentrated in an array after the instantiation point, and the array is passed to the DrawPolygon method, and the polygon is drawn.

 

GDI + graphics drawing methods in C #

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.