码迷,mamicode.com
首页 > 移动开发 > 详细

Android -----paint cap join 理解 ,paint画笔形状设置

时间:2015-01-23 17:58:06      阅读:297      评论:0      收藏:0      [点我收藏+]

标签:

引自: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    (0),  
        /**      * The stroke projects out as a semicircle, with the center at the      * end of the path.      */ 
          ROUND   (1),  
             /**      * The stroke projects out as a square, with the center at the end      * of the path.      */  
               SQUARE  (2);    
                 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.setStrokeJoin(Paint.Join.ROUND);    
        paint.setStrokeCap(Paint.Cap.ROUND);

 

Android -----paint cap join 理解 ,paint画笔形状设置

标签:

原文地址:http://www.cnblogs.com/Anita9002/p/4244587.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!