• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Android 2.x + 2D objects + transformations

Hello,

My Android application renders a number of 2D shapes (such as rectangles and ellipses), and whenever users click on a particular rectangle, I rotate that rectangle manually by applying a rotation to the coordinates of the vertices of that rectangle and then rendering the rotated rectangle.

Are there simple Canvas-based APIs (i.e., outside of OpenGL) available that I can invoke in order to apply transformations (such as rotations) to individual 2D shapes (such as rectangles) and also to 3D shapes without having to use save/restore?

The Canvas element has the following rotate method:
canvas.rotate(some-angle);

The ideal API for a rectangle would be essentially the same:
myRect.rotate(some-angle);

Oswald

ps: here's a declarative-based example of rotating a rectangle in SVG:
<rect x = "25" y = "50" width = "150" height = "100"
fill = "red" stroke = "green" stroke-width = "2"
transform = "rotate(-45 100 100)"/>
 
Back
Top Bottom