GraphicsPathでdrawEllipse()する

GraphicsPathでdrawRoundRect()する前に、こっちが先だったかも。GraphicsPathでGraphics.drawEllipse()と同様のことができるとどっかで使えそう。QuadraticBezierSegment.createEllipseSegments()をほぼコピペで実装できる。
例によって青い線がGraphics.drawEllipse()で、黒い線がGraphicsPathUtil.createEllipse()で作成したGraphicsPathをGraphics.drawGraphicsData()で描画した線。

GraphicsPathでdrawEllipse()する – wonderfl build flash online

ポイントは、楕円や円は二次ベジェだと4セグメントじゃ近似しきれないから8セグメントで近似するってことと、π/4の倍数でアンカーをとることにすると計算が簡単ってこと。


About this entry