Vb. NET, using GDI paint for specific applications.
Source: Internet
Author: User
The following example draws GDI graphics by overloading the OnPaint () method of the Form1 form
Protected Overrides Sub OnPaint (ByVal e as System.Windows.Forms.PaintEventArgs)
'/////////////Draw any line
Dim g as Graphics = E.graphics
Dim Mypen as Pen = New Pen (color.red, 2)
G.drawline (Mypen, 100, 100, 10, 10)
'/////////////Draws a rectangle (a closed figure of any line)
Dim point1 as PointF = New PointF (100F, 100F)
Dim Point2 as PointF = New PointF (200F, 100F)
Dim Point3 as PointF = New PointF (200F, 200F)
Dim point4 as PointF = New PointF (100F, 200F)
Dim curvepoints as PointF () = {point1, Point2, Point3, point4}
G.drawpolygon (New Pen (Color.Blue, 2), curvepoints)
'////////////text representation
Dim ffamily as FontFamily = New FontFamily ("Arial")
Dim font as Font = New font (ffamily, "M", FontStyle.Bold, Fontstyle.italic, GraphicsUnit.Pixel)
Dim text as String = "I Love you!"
Dim SolidBrush as SolidBrush = New SolidBrush (color.red)
Dim PR as PointF = New PointF (100, 10)
E.graphics.drawstring (text, font, SolidBrush, PR)
'////////////plane drawing
Dim Rec as RectangleF = New RectangleF (10, 10, 200, 100)
G.drawpie (Mypen, REC, 150, 150)
'///////////closed graphics, 0.7 should be a circle
G.drawclosedcurve (Mypen, curvepoints, 0.7, Drawing.Drawing2D.FillMode.Alternate)
'///////////, let's try it for ourselves.
G.drawarc (Mypen, 300, 300, 200, 200, 100, 100)
G.drawcurve (Mypen, curvepoints)
G.drawbezier (Mypen, 50, 50, 100, 50, 100, 100, 50, 100)
G.drawbeziers (Mypen, curvepoints)
'//////////it's a circle.
Dim rec1 as RectangleF = New RectangleF (10, 10, 100, 100)
G.drawellipse (Mypen, REC1)
'//////////This is an ellipse
Dim rec2 as RectangleF = New RectangleF (10, 10, 200, 100)
G.drawellipse (Mypen, REC2)
End Sub
These are my own test out, of course, there are many, I just opened a head, if you find anything good dongdong, don't forget to notice:
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