using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Point pt0 = new Point(10, 10);
int width = 5;
var g = pictureBox1.CreateGraphics();
g.Clear(Color.White);
var pen = new Pen(Color.Black);
var brush = new SolidBrush(Color.Black);
//五角星
var pen2 = new Pen(Color.Yellow);
int R = 50;
const double PI = Math.PI;
double ct1 = PI / 10.0;
var brush2 = new SolidBrush(Color.Red);
Point pt = new Point(105, 145);
Point[] pts = new Point[10];
double dct = PI / 5.0;
double r = R * Math.Cos(2 * ct1) / 2;
int i;
for (i = 0; i < 9; i += 2)
{
pts[i].X = (int)Math.Round(pt.X + R * Math.Cos(PI * 3 / 2 + i * dct));
pts[i].Y = (int)Math.Round(pt.Y + R * Math.Sin(PI * 3 / 2 + i * dct));
}
for (i = 1; i < 10; i += 2)
{
pts[i].X = (int)Math.Round(pt.X + r * Math.Cos(PI * 3 / 2 + i * dct));
pts[i].Y = (int)Math.Round(pt.Y + r * Math.Sin(PI * 3 / 2 + i * dct));
}
g.FillPolygon(brush2, pts);
}
}
}