安卓:绘画帆布,道尽左下角对应于(0,0)? [英] Android: Drawing to canvas, way to make bottom left correspond to (0,0)?

查看:116
本文介绍了安卓:绘画帆布,道尽左下角对应于(0,0)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写一个图类,我可以在Android中使用(我知道pre-做那些存在),而是将我所有的坐标将是一个痛苦。有一个简单的方法,使屏幕坐标左下角开始?

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?

推荐答案

没有,我不知道的方式来移动 0,0 来左下方得到你所通常认为的正常的坐标。

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

这篇关于安卓:绘画帆布,道尽左下角对应于(0,0)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆