1. Introducing Channels - a new way to chat with other Android users!
    Dismiss Notice

Android 2.x + 2D objects + transformations


Last Updated:

  1. ocampesato

    ocampesato New Member This Topic's Starter

    Joined:
    Feb 17, 2010
    Messages:
    2
    Likes Received:
    0
    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)"/>
     

    Advertisement

Share This Page

Loading...