Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

缩放(scale)我有一个疑问 #83

Open
NathansLiu opened this issue Nov 7, 2017 · 2 comments
Open

缩放(scale)我有一个疑问 #83

NathansLiu opened this issue Nov 7, 2017 · 2 comments

Comments

@NathansLiu
Copy link

  RectF rect1 = new RectF(0,-200,200,0);   // 矩形区域
 Paint paint1= new Paint();
 paint1.setColor(Color.BLACK);
 Paint paint2= new Paint();
 paint2.setColor(Color.BLUE);

 canvas.drawRect(rect1,paint1);
 canvas.scale(0.5f,0.5f,100,0);
//画一个缩放前 矩形蓝
 canvas.drawRect(rect1,paint2);

1

  RectF rect1 = new RectF(0,-200,200,0);   // 矩形区域
 Paint paint1= new Paint();
 paint1.setColor(Color.BLACK);
 Paint paint2= new Paint();
 paint2.setColor(Color.BLUE);

 canvas.drawRect(rect1,paint1);
 canvas.scale(0.5f,0.5f,200,0);
//画一个缩放前 矩形蓝
 canvas.drawRect(rect1,paint2);

2

我将蓝色矩形第一次移动100,缩放中心移动100,位于黑色矩形底部中心。
然而第二次移动200,缩放中心应该在黑色矩形右边线上,目测只是移动了50。
那么移动距离究竟从哪里测量才对?

@NathansLiu
Copy link
Author

不好意思,请忽视注释

@zqhead
Copy link

zqhead commented Feb 2, 2018

你可想象下,是画布的坐标系进行了缩放,在(200,0)的位置做缩放,相当于缩放后的坐标原点在原来(100,0)的位置,而(200,0)的位置是缩放中心不变,两者之间的距离是200,位置就是图2的效果

而在(100,0)的位置做做缩放,相当于缩放后的坐标原点是原来的(50,0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants