Head first C # Chinese Version chapter 13th controls and graphics page595

Source: Internet
Author: User

 

Half-minute introduction GDI +



Graphics created
After the object, you can draw various images and images. You only need to call its method, you can draw to create
Graphics
.




Step 1 always gets a graphics
Object. You can use
Creategraphics
() Method. Remember,
Graphics
Implemented
Idisposable
Interface, so if you create
Graphics
Object, use
Using
Statement.



 


If you want to draw a line, call drawline
() Method. The parameter is
X
And
Y
Coordinates indicate the start and end points:



 

Or use two
It can also be used as a parameter:



 


The following code draws a gray rectangle of the filled stone and draws a sky-blue border for it. It uses a rectangle
To define the drawing Area
--
Here, the upper left corner is (
150
,
15
), Width is
140
, High
90.



 


Drawcircle can be used
() Or
Fillcircle
() Method to draw an elliptic or circle. The two methods also use
Rectangle
To specify the image size. The following code draws two ovans, which are slightly staggered to render the shadow effect:



 


Use drawstring
() Method can draw text of any font and color. To use this method, you must create
Font
Object. It implements
Idisposable
To use
Using
Statement:



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.