首页 > 移动平台 > 详细

android paint cap join 理解 图示

时间:2015-01-14 11:06:56      阅读:229      评论:0      收藏:0      [点我收藏+]

Lee出品,本文属个人所有,转载请声明出处。

网上查了很多资料,对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的源码,从源码我们看到BUTT是默认的设置,但是我们看不出BUTT、ROUND、SQUARE的区别。

下面看几张图片,我想足以理解Cap的用途。

BUTT 技术分享
ROUND 技术分享
SQUARE 技术分享

上表就是三种样式的区别,竖线处即为画笔结束处,图中区别明显,在此不再赘述。


接着我们看Join,Join的理解也很容易,他是用来控制画的图形接触时候的样式的。

看源码:

    /**
     * The Join specifies the treatment where lines and curve segments
     * join on a stroked path. The default is MITER.
     */
    public enum Join {
        /**
         * The outer edges of a join meet at a sharp angle
         */
        MITER   (0),
        /**
         * The outer edges of a join meet in a circular arc.
         */
        ROUND   (1),
        /**
         * The outer edges of a join meet with a straight line
         */
        BEVEL   (2);
        
        private Join(int nativeInt) {
            this.nativeInt = nativeInt;
        }
        final int nativeInt;
    }

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

MITER 技术分享
ROUND 技术分享
BEVEL 技术分享

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

android paint cap join 理解 图示

原文:http://blog.csdn.net/hnulwt/article/details/42705895

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!