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