GraphicsPath オブジェクトを、指定されたペンでこのパスを描画するときに塗りつぶされる領域を囲む曲線に置換します。
Overloads Public Sub Widen( _
ByVal pen As Pen, _ ByVal matrix As Matrix, _ ByVal flatness As Single _)
[C#]
public void Widen(Penpen,Matrixmatrix,floatflatness);
[C++]
public: void Widen(Pen* pen,Matrix* matrix,floatflatness);
[JScript]
public function Widen(
pen : Pen,matrix : Matrix,flatness : float);
パラメータ
- pen
パスの元のアウトラインと、このメソッドが作成する新しいアウトラインの間の幅を指定する Pen オブジェクト。 - matrix
幅の拡張前にパスに適用する変換を指定する Matrix オブジェクト。 - flatness
曲線の平坦度を指定する値。
解説
このメソッドは、 GraphicsPath オブジェクトの元の線の周りにアウトラインを作成します。既存の線と新しいアウトライン間の距離として、Widen の呼び出し時に使用される Pen オブジェクトの幅が使用されます。線の間の空間を塗りつぶす場合は、 DrawPath オブジェクトではなく FillPath オブジェクトを使用する必要があります。
使用例
[Visual Basic, C#] 次の例は、Windows フォームでの使用を意図してデザインされており、 OnPaint イベントのオブジェクトである PaintEventArgs e が必要です。このコードは次のアクションを実行します。
- パスを作成し、そのパスに 2 つの楕円を追加します。
- パスを黒で描画します。
- パスの幅を拡張します。
- パスを赤で描画します。
[Visual Basic, C#] 2 番目の描画では DrawPath ではなく FillPath が使用されるため、描画された図形はアウトラインが塗りつぶされます。
Public Sub WidenExample(e As PaintEventArgs)
Dim myPath As New GraphicsPath()
myPath.AddEllipse(0, 0, 100, 100)
myPath.AddEllipse(100, 0, 100, 100)
e.Graphics.DrawPath(Pens.Black, myPath)
Dim widenPen As New Pen(Color.Black, 10)
Dim widenMatrix As New Matrix()
widenMatrix.Translate(50, 50)
myPath.Widen(widenPen, widenMatrix, 1F) ' Sets tension for curves.
e.Graphics.FillPath(New SolidBrush(Color.Red), myPath)
End Sub
[C#]
private void WidenExample(PaintEventArgs e)
{
// Create a path and add two ellipses.
GraphicsPath myPath = new GraphicsPath();
myPath.AddEllipse(0, 0, 100, 100);
myPath.AddEllipse(100, 0, 100, 100);
// Draw the original ellipses to the screen in black.
e.Graphics.DrawPath(Pens.Black, myPath);
// Widen the path.
Pen widenPen = new Pen(Color.Black, 10);
Matrix widenMatrix = new Matrix();
widenMatrix.Translate(50, 50);
myPath.Widen(widenPen, widenMatrix, 1.0f);
// Draw the widened path to the screen in red.
e.Graphics.FillPath(new SolidBrush(Color.Red), myPath);
}
[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
参照
GraphicsPath クラス | GraphicsPath メンバ | System.Drawing.Drawing2D 名前空間 | GraphicsPath.Widen オーバーロードの一覧