[C #] Graphics Pan Zoom rotation

Source: Internet
Author: User

"Pan"

private void Btntranslate_click (object sender, EventArgs e)        {            Graphics graphics = this. CreateGraphics ();            Red Pen Pen Pen            = new Pen (color.red, 5);            Rectangle rect = new Rectangle (0, 0, N, a);            A rectangular graphics with a red stroke            . DrawRectangle (pen, rect);            Move 100 to pan left to translate the            graphics down. TranslateTransform (100,50);            Blue Pen pen            . Color = Color.Blue;            Redraw the translated rectangular graphics with a blue pen            . DrawRectangle (pen, rect);            Graphics. Dispose ();            Pen. Dispose ();        }


"Zoom"

private void Btnscale_click (object sender, EventArgs e)        {            Graphics graphics = this. CreateGraphics ();            Red Pen Pen Pen            = new Pen (color.red, 5);            Rectangle rect = new Rectangle (0, 0, N, a);            A rectangular graphics with a red stroke            . DrawRectangle (pen, rect);            Graphics. ScaleTransform (0.5f, 2);            Blue Pen pen            . Color = Color.Blue;            Redraw the translated rectangular graphics with a blue pen            . DrawRectangle (pen, rect);            Graphics. Dispose ();            Pen. Dispose ();        }


Zoom in half and zoom in one more times

"Rotate"

private void Btntraslate_click (object sender, EventArgs e)        {            Graphics graphics = this. CreateGraphics ();            Red Pen Pen Pen            = new Pen (color.red, 5);            Rectangle rect = new Rectangle (0, 0, N, a);            A rectangular graphics with a red stroke            . DrawRectangle (pen, rect);            Graphics. TranslateTransform (200,0);            Graphics. RotateTransform (+);            Blue Pen pen            . Color = Color.Blue;            Redraw the translated rectangular graphics with a blue pen            . DrawRectangle (pen, rect);            Graphics. Dispose ();            Pen. Dispose ();        }




The coordinate origin is the upper-left point of the rectangle.






[C #] Graphics translation Zoom rotation

Related Article

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.