引自:http://www.2cto.com/kf/201501/370215.html

网上查了很多资料,对paint的里面的枚举类cap join讲的不是很透彻。在这里自己做一个比较深入的研究。

首先说Cap,比较形象的解释就是 用来控制我们的画笔在离开画板时候留下的最后一点图形,比如矩形,圆形等。不懂?那接着往下看。

先看看源码

/**  * The Cap specifies the treatment for the beginning and ending of
* stroked lines and paths. The default is BUTT. */
public enum Cap {
/** * The stroke ends with the path, and does not project beyond it. */
BUTT (),
/** * The stroke projects out as a semicircle, with the center at the * end of the path. */
ROUND (),
/** * The stroke projects out as a square, with the center at the end * of the path. */
SQUARE ();
private Cap(int nativeInt) {
this.nativeInt = nativeInt;
}
final int nativeInt;
}

和Cap类似,看源码也就看出了默认是MITER,其他具体形状还是难以理解。接着看图:

MITER
ROUND
BEVEL

上表就是三种样式的区别,区别明显,在此不再赘述。

引用:

* setStrokeCap(Paint.Cap cap);   

    * 当画笔样式为STROKE或FILL_OR_STROKE时,设置笔刷的图形样式,如圆形样式   

    * Cap.ROUND,或方形样式Cap.SQUARE
* * setSrokeJoin(Paint.Join join); * 设置绘制时各图形的结合方式,如平滑效果等

paint 默认画笔为矩形,即如果要用圆形画笔,则在paint定义里面加上

    paint.setStrokeJoin(Paint.Join.ROUND);
paint.setStrokeCap(Paint.Cap.ROUND);

如果想要从圆形切换成矩形需要

paint.setStrokeJoin(Paint.Join.MITER);
paint.setStrokeCap(Paint.Cap.SQUARE);

主要是下面一句

最新文章

  1. 关于node的http模块
  2. cannot simultaneously fetch multiple bags
  3. JavaScript 随笔1
  4. Read/Write file in Android
  5. php使用位与运算符【&】或【|】实现权限管理
  6. css3 transform的基本用法和介绍
  7. C++学习25 纯虚函数和抽象类
  8. JDK各个版本下载页面
  9. Android View事件传递机制
  10. 使用Unity制作游戏关卡的教程(一)
  11. (转)失落的C语言结构体封装艺术
  12. mysql登录错误或者密码错误
  13. 101个Linq例子(40-60)
  14. Java经典编程题50道之十六
  15. C#开发APP,ToolBar控件在Smobiler中的使用方式【附案例源码】——Smobiler移动开发平台
  16. 关于在ROS kinetic下arbotix报错的问题
  17. 译:SQL Server的Missing index DMV的 bug可能会使你失去理智---慎重看待缺失索引DMV中的信息
  18. abp项目中无法使用HttpContext.Current.Session[""]的问题
  19. Selenium (4) —— Selenium是什么? WebDriver是什么?做什么?(101 Tutorial)
  20. 如何使用button在tab中新建打开一个链接页

热门文章

  1. oracle Database Link
  2. VirtualBox 不能为虚拟电脑打开一个新的任务 可能的解决方案
  3. 外部VBS的调用
  4. leetcode441(巧妙利用取整和解方程)
  5. Golang: pprof
  6. c# 快速验证代理IP是否有用
  7. 在Linux服务器上增加硬盘没那么简单【转】
  8. ubuntu 14.04安装postgresql最新版本
  9. Win32串口API
  10. 几个SQL语句笔试题