(Android) canvas movement and flip

Source: Internet
Author: User

(Android) canvas movement and flip

Android canvas flip is a powerful tool, especially in image processing. You can easily change the origin without having to reverse the array with a bunch of linear changes.

Just like the sauce purple, at the beginning, the canvas sister overlaps with the display area brother, tacit understanding is like a person, three views are consistent, the starting point is unified in the upper left corner. The images we draw are displayed on the canvas in the display area. This is the result of drawing a progress bar on the canvas.

If you want to get a vertical bar, we will flip the canvas, first Flip 90 ° counterclockwise, get

At this time, the world of the canvas sister and brother in the display area is no longer the same coordinate system.

Their world is different. In order to make the world they see the same world, the canvas sister will move the getHeight of a display area negatively relative to its coordinate origin.

After the canvas where the widget is located is converted, we get a vertical control. Code implementation:

Protected synchronized void onDraw (Canvas canvas) {canvas. rotate (-90); canvas. translate (-getHeight (), 0); super. onDraw (canvas );}

 

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.