Mirroring

One particularly useful pair is setScale and postTranslate, which allow you to flip the image across a single axis (or both if you desire). If you scale by a negative number, the image will draw in the negative space of the coordinate system. Since the 0, 0 point is the top left, using a negative number on the x axis would cause the image to draw to the left. Therefore we need to use the postTranslate method to move it over to the right as displayed in Figure 3-12.

matrix.setScale(-1, 1); matrix.postTranslate(bmp.getWidth(),0);

Figure 3-12. Mirrored

Was this article helpful?

0 0

Post a comment