using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Drawing.Drawing2D; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void pictureBox1_Click(object sender, EventArgs e) { int halfparts = 9; pictureBox1.Image = new Bitmap(pictureBox1.Width, pictureBox1.Height); Bitmap b = (pictureBox1.Image as Bitmap); Graphics g = Graphics.FromImage(b); g.SmoothingMode = SmoothingMode.AntiAlias; g.FillRectangle(Brushes.Black, 0, 0, pictureBox1.Width, pictureBox1.Height); List topPoints = new List(); List bottomPoints = new List(); Pen greenPen = new Pen(Brushes.Green, 2); Matrix m = new Matrix(); m.RotateAt(15, new PointF(100, 100)); for (int i = 0; i < (2*halfparts)+1; i++) { double theta = 17 + i * 2.0 * Math.PI / (2 * halfparts); PointF p = new PointF((float)Math.Cos(theta), (float)Math.Sin(theta)); PointF topP = new PointF(); topP.X = (float)((p.X + 2) * 100.0); topP.Y = (float)((p.Y + 1.25) * 40.0); topPoints.Add(topP); PointF bottomP = new PointF(); bottomP.X = (float)((p.X * 85.0) + 200); bottomP.Y = (float)((p.Y + 3.5) * 50.0); bottomPoints.Add(bottomP); } PointF[] top = topPoints.ToArray(); m.TransformPoints(top); topPoints.Clear(); topPoints.AddRange(top); PointF[] bottom = bottomPoints.ToArray(); m.TransformPoints(bottom); bottomPoints.Clear(); bottomPoints.AddRange(bottom); for (int i = 1; i < (2 * halfparts) + 1; i++) { g.DrawLine(greenPen, topPoints[i - 1], topPoints[i]); g.DrawLine(greenPen, bottomPoints[i - 1], bottomPoints[i]); g.DrawLine(greenPen, bottomPoints[i], topPoints[i]); } for (int i = 0; i < halfparts; i++) { g.DrawLine(greenPen, topPoints[i], topPoints[i + halfparts]); g.DrawLine(greenPen, bottomPoints[i], bottomPoints[i + halfparts]); } } } }