Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Drawing to canvas, way to make bottom left correspond to (0,0)?

I'm trying to write a graph class I can use in Android(I'm aware pre-made ones exist), but converting all of my coordinates would be a pain. Is there an easy way to make the screen coordinates start at the bottom left?

like image 890
John Lotacs Avatar asked Jul 13 '11 16:07

John Lotacs


1 Answers

No, I don't know of a way to move 0,0 to the bottom left and get what you would typically think of as "normal" coordinates.

But combining scale() and translate() might do the trick to achieve the same effect.

canvas.translate(0,canvas.getHeight());   // reset where 0,0 is located
canvas.scale(1,-1);    // invert
like image 126
dustmachine Avatar answered Sep 28 '22 01:09

dustmachine