FillPolygonPointメソッドの方が便利な場合があります。
このように爆発のすべてのポイントを想像してみてください。

次に、それを描画するコードは、次の線に沿って何かに見えます。
Public Sub FillPolygonPoint(ByVal e As PaintEventArgs)
' Create solid brush.
Dim blueBrush As New SolidBrush(Color.Blue)
' Create points that define polygon.
Dim point1 As New Point(50, 50)
Dim point2 As New Point(100, 25)
Dim point3 As New Point(200, 5)
Dim point4 As New Point(250, 50)
Dim point5 As New Point(300, 100)
Dim point6 As New Point(350, 200)
Dim point7 As New Point(250, 250)
Dim curvePoints As Point() = {point1, point2, point3, point4, _
point5, point6, point7}
' Draw polygon to screen.
e.Graphics.FillPolygon(blueBrush, curvePoints)
End Sub
Microsoftが提供するドキュメントに概説されているように。
星のポイントを動的に作成するアルゴリズム(C#)は次のようになります。
using System;
using System.Drawing;
using System.Collections.Generic;
namespace Explosion
{
class Program
{
static void Main(string[] args)
{
foreach (Point point in CreatePointsForStarShape(15, 200, 100))
{
Console.WriteLine(point);
}
Console.ReadLine();
}
public static IEnumerable<Point> CreatePointsForStarShape
(int numberOfPoints, int maxRadius, int minRadius)
{
List<Point> points = new List<Point>(numberOfPoints);
for (
double angle = 0.0;
angle < 2* Math.PI;
angle += 2 * Math.PI / numberOfPoints
)
{
// add outer point
points.Add(CalculatePoint(angle, maxRadius));
// add inner point
points.Add(CalculatePoint
(angle + (Math.PI / numberOfPoints), minRadius));
}
return points;
}
public static Point CalculatePoint(double angle, int radius)
{
return new Point(
(int)(Math.Sin(angle) * radius),
(int)(Math.Cos(angle) * radius)
);
}
}
}
これが出力です...
{X=0,Y=200}
{X=20,Y=97}
{X=81,Y=182}
{X=58,Y=80}
{X=148,Y=133}
{X=86,Y=50}
{X=190,Y=61}
{X=99,Y=10}
{X=198,Y=-20}
{X=95,Y=-30}
{X=173,Y=-99}
{X=74,Y=-66}
{X=117,Y=-161}
{X=40,Y=-91}
{X=41,Y=-195}
{X=0,Y=-100}
{X=-41,Y=-195}
{X=-40,Y=-91}
{X=-117,Y=-161}
{X=-74,Y=-66}
{X=-173,Y=-99}
{X=-95,Y=-30}
{X=-198,Y=-20}
{X=-99,Y=10}
{X=-190,Y=61}
{X=-86,Y=50}
{X=-148,Y=133}
{X=-58,Y=80}
{X=-81,Y=182}
{X=-20,Y=97}
{X=0,Y=200}
{X=20,Y=97}
これをVisualBasicに変換し、ランダム化を追加して爆発的な外観にする必要があります。行列の乗算により、ポイントを転置(移動)およびスケーリングできます。