/**
* 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
test.jsp
ROUND
test.jsp    
SQUARE
test.jsp

上表就是三種樣式的區別,分隔號處即為畫筆結束處,圖中區別明顯,在此不再贅述。


接著我們看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
test.jsp  
ROUND
test.jsp  
BEVEL
test.jsp  
創作者介紹
創作者 shadow 的頭像
shadow

資訊園

shadow 發表在 痞客邦 留言(0) 人氣()