GDI + basic knowledge-alignment of paint brushes

Source: Internet
Author: User

Effect:

 

Code:

Private void pen_align_click (Object sender, system. eventargs E)
{
Graphics graphics = This. creategraphics ();
Graphics. Clear (color. White );
Graphics. smoothingmode = smoothingmode. highquality;

Pen = new pen (color. Gray, 1.0f );

Pen pen1 = new pen (color. fromargb (255, color. Green), 12 );
Pen pen2 = new pen (color. fromargb (155, color. Red), 20 );

For (INT I = 0; I <5; I ++)
{
Pen1.alignment = (penalignment) I;
For (Int J = 0; j <5; j ++)
{
Pen2.alignment = (penalignment) J;
Graphics. translatetransform (20, 0 );
// Graphics. drawline (pen2, new point (), new point (60, 30 ));
// Graphics. drawline (pen1, new point (0, 30), new point (60, 30 ));
Graphics. drawellipse (pen1, 0, 30, 80, 80 );
Graphics. drawellipse (pen2, 0, 30, 80, 80 );

Graphics. drawstring ("Green:" + pen1.alignment. tostring () + "\ n red:" + pen2.alignment. tostring (), new font ("Arial", 12, fontstyle. bold), new solidbrush (color. yellow), 0f, 30f );
Graphics. drawstring ("Green:" + pen1.alignment. tostring () + "\ n red:" + pen2.alignment. tostring (), new font ("Arial", 12), new solidbrush (color. black), 0f, 30f );

Graphics. translatetransform (110,0 );
}
Graphics. resettransform ();
Graphics. translatetransform (0,100 * (I + 1 ));
}

Graphics. resettransform ();
// Graphics. drawline (pen, 0,30, 600,30 );
Graphics. Dispose ();
}

 

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.