Flipping algorithms?

谁说我不能喝 提交于 2019-12-24 15:04:07

问题


I am new in android canvas. I was created custom shape on "L Shaped Rectangle, Rectangle and some shapes" and using android canvas. It was working fine. In my question is Flipping custom Shape? previously i was used scale

canvas.scale(-1.0f, 1.0f);

it's working. after flip, that shape do some action such as( rotate, resize). But i didn't get any points. So i searched flip algorithm for basic. i didn't get it. If you know pls share your comments.


回答1:


Matrix is your friend. The truth is that it is kind of a messy thing to use because it is applied to the canvas and it is a weird way to look at things but it will be your friend once you notice the calculations.

First put it down on paper and know what to do to the canvas to place your shape where you want. Maybe you need to translate the center to the center of you shape, then rotate and, finally, draw. Then go back to the original transformation.

If you follow the API you´ve got canvas.save(), canvas.rotate(), canvas.scale()... And they go as "adds a rotation to the current matrix" or so. Even you can give a matrix you´ve built yourself.



来源:https://stackoverflow.com/questions/30869993/flipping-algorithms

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!