一。重要方法

1.translate
2.scale
3.rotate

 

二。注意

1.明确顺序

canvas.rotate(45);
canvas.drawRect(new Rect(50, 50, 100, 100), paint);

如果顺序调换,则没有旋转的效果

android自定义控件(二)Canvas

 

2.转换的时候,需要把转换的中心点移到shape自身的中心

int left=50,top=50, right = 100,bottom = 100;
canvas.translate(right/2, bottom/2);
canvas.rotate(45);
canvas.drawRect(new Rect(-right/2, -bottom/2, right/2, bottom/2), paint);

android自定义控件(二)Canvas

 

3.变换过程

android自定义控件(二)Canvas

android自定义控件(二)Canvas

 

 

相关文章:

  • 2021-08-01
  • 2021-11-05
  • 2021-04-09
  • 2021-07-27
  • 2017-12-14
  • 2022-01-22
猜你喜欢
  • 2021-07-13
  • 2021-12-18
  • 2021-11-04
  • 2022-12-23
  • 2021-12-07
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案