Flipping algorithms?

91 views Asked by At

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

There are 1 answers

2
eduyayo On

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.