Android Canvas Coordinate System

Posted by Mitch on Stack Overflow See other posts from Stack Overflow or by Mitch
Published on 2010-05-28T17:45:17Z Indexed on 2010/06/01 17:43 UTC
Read the original article Hit count: 1287

I'm trying to find information on how to change the coordinate system for the canvas. I have some vector data I'd like to draw to a canvas using things like circles and lines, but the data's coordinate system doesn't match the canvas coordinate system.

Is there a way to map the units I'm using to the screen's units?

I'm drawing to an ImageView which isn't taking up the entire display.

If I have to do my own calculations prior to each drawing call, how to I find the width and height of my ImageView?

The getWidth() and getHeight() calls I tried seem to be returning the entire canvas size and not the size of the ImageView which isn't helpful.

I see some matrix stuff, is that something that will work for me?

I tried to use the "public void scale(float sx, float sy)", but that works more like a pixel level zoom rather than a vector scale function by expanding each pixel. This means if the dimensions are increased to fit the screen, the line thickness is also increased.


Update:

After some research I'm starting to think there's no way to change coordinate systems to something else. I'll need to map all my coordinates to the screen's pixel coordinates and do so by modifying each vector. The getWidth() and getHeight() seem to be working better for me now. I can say what was wrong, but I suspect I can't use these methods inside the constructor.

© Stack Overflow or respective owner

Related posts about android

Related posts about beginner