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;
using System.Drawing.Drawing2D;

namespace ch13_3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Graphics graphicsObject = e.Graphics;
            Random random = new Random();
            SolidBrush brush = new SolidBrush(Color.DarkMagenta);
            // x and y points of the path
            int[] xPoints = { 55, 67, 109, 73, 83, 55, 27, 37, 1, 43 };
            int[] yPoints = { 0, 36, 36, 54, 96, 72, 96, 54, 36, 36 };
            // create graphics path for star;
            GraphicsPath star = new GraphicsPath();
            star.CloseFigure();
            // translate the origin to (150, 150)
            graphicsObject.TranslateTransform(150, 150);
            // create star from series of points
            for (int i = 0; i <= 8; i += 2)
                star.AddLine(xPoints[i], yPoints[i],
                xPoints[i + 1], yPoints[i + 1]);
            // close the shape
            star.CloseFigure();
            // rotate the origin and draw stars in random colors
            for (int i = 1; i <= 18; i++)
            {
                graphicsObject.RotateTransform(20);
                brush.Color = Color.FromArgb(random.Next(200, 255), random.Next(255), random.Next(255), random.Next(255));
                graphicsObject.FillPath(brush, star);

            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
    }
}
