2016-08-17 82 views
0

如何繪製一個帶圓角的矩形並填充顏色?如何繪製一個圓角的矩形?

我試圖使用方法arcTo用下面的代碼:

this.bgGraphics.beginFill(0xFFCC00, 1); 
this.bgGraphics.moveTo(0, 0); 
this.bgGraphics.lineTo(45, 0); 
this.bgGraphics.arcTo(45, 0, 60, 15, 15); 
this.bgGraphics.lineTo(60, 60); 
this.bgGraphics.lineTo(0, 60); 
this.bgGraphics.endFill(); 

即我繪製了一個60 x 60的矩形,然後嘗試使用arcTo從點45, 045, 15,半徑爲15。但

而不是在右上圓角它砍下:

screenshot

回答

1

因爲它是一種顏色,怎麼樣繪製一個圓角的矩形與Graphics.drawRoundedRect,然後畫在圓部分是你不想要?你會畫一個圓角的矩形的全尺寸,然後掩飾要與正常rects廣場的角落,像這樣:

Example of drawing with rectangles

1

arcTo()方法是有點混亂。 (x1,y1)座標不是曲線的起點。想想它更像貝塞爾手柄的點。爲了得到你想要的弧線,你需要沿着x軸拉一個貝塞爾手柄。所以,你的方法實際上應該是這樣的:

this.bgGraphics.arcTo(60, 0, 60, 15, 15); 

enter image description here