任务是使用curveTo
图形方法绘制自定义形状。
问题是路径连接不准确。
结果是:
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
protected function application1_creationCompleteHandler(event:FlexEvent):void
{
// TODO Auto-generated method stub
test.graphics.clear();
test.graphics.lineStyle(1);
drawBorder(test.graphics, 200, 200);
}
private function drawBorder(g: Graphics, width: Number, height: Number): void
{
var cornerRadius: int = 20;
var pointerWidth: int = 4;
var pointerHeight: int = 10;
var pointerBottomGap: int = 6;
width -= pointerWidth;
g.moveTo(0, height - cornerRadius);
g.lineTo(0, cornerRadius + 1);
g.curveTo(0, 0, cornerRadius, 0);
g.lineTo(width - cornerRadius, 0);
g.curveTo(width, 0, width, cornerRadius);
var pointerY: int = height - pointerHeight - pointerBottomGap;
g.lineTo(width, pointerY);
g.lineTo(width + pointerWidth, pointerY + pointerHeight);
g.lineTo(width - pointerWidth, pointerY + pointerHeight + 1);
g.curveTo(width - pointerWidth, height, width - cornerRadius, height);
g.lineTo(cornerRadius, height);
g.curveTo(0, height, 0, height - cornerRadius);
}
]]>
</fx:Script>
<mx:UIComponent
id="test"
x="100" y="100"/>
这个问题可以改写 - 如何使用方法绘制具有圆角半径的矩形curveTo
?