Android -----paint cap join 理解 ,paint畫筆形狀設定

來源:互聯網
上載者:User

標籤:

引自: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畫筆形狀設定

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.