之前对于canvas.translate(x,y)的理解有的错误,之前一直以原点(0,0)为基准点,作用就是移动原点,默认的原点(0,0)是在屏幕左上角的,你可以通过translate(x,y)把点(x,y)作为原点,就一直以为这个(x,y)就是新的坐标原点。但看一下API就会知道,这种理解是不对的,不过API上面讲解的也不太清楚:
- public void translate (float dx, float dy)
- Since: API Level 1
- Preconcat the current matrix with the specified translation
- Parameters
- dx The distance to translate in X
- dy The distance to translate in Y
本文澄清了canvas.translate(x,y)在绘图中的误解,详细解释了该函数如何改变原点的位置,实际上是将原点沿x轴和y轴方向偏移指定距离,而非直接设置新的原点位置。
4880

被折叠的 条评论
为什么被折叠?



