Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.Windows.Forms;
- namespace LabSenyshyn6
- {
- public partial class FormGaltel : Form
- {
- Graphics graphics;
- const int radius = 150;
- Pen penGray = new Pen(Color.Black, 0);
- Pen penShadow = new Pen(Color.Black, 30);
- List<PointF> pointsCircled = new List<PointF>();
- List<PointF> pointsNormal = new List<PointF>();
- public FormGaltel()
- {
- InitializeComponent();
- }
- private void FormGaltel_Paint(object sender, PaintEventArgs e)
- {
- graphics = CreateGraphics();
- }
- private void numericUpDown1_ValueChanged(object sender, EventArgs e)
- {
- graphics.Clear(Color.Silver);
- label1.Text = "";
- pointsCircled.Clear();
- pointsNormal.Clear();
- int n = (int)numericUpDown1.Value;
- if(n != 1)
- {
- label1.Text = " →";
- penGray.LineJoin = LineJoin.Round;
- penShadow.LineJoin = LineJoin.Round;
- double circledX;
- double circledY;
- for (int i = 0; i < n; i++)
- {
- circledX = radius * Math.Cos(2 * Math.PI / (float)n * i);
- circledY = radius * Math.Sin(2 * Math.PI / (float)n * i);
- PointF figureCircled = new PointF((float)(((600 + radius) + circledX)), (float)(((33 + radius) + circledY)));
- PointF figureNormal = new PointF((float)(((40 + radius) + circledX)), (float)(((33 + radius) + circledY)));
- pointsCircled.Add(figureCircled);
- pointsNormal.Add(figureNormal);
- }
- graphics.DrawPolygon(penShadow, pointsCircled.ToArray());
- graphics.FillPolygon(new SolidBrush(penShadow.Color), pointsCircled.ToArray());
- graphics.DrawPolygon(penGray, pointsNormal.ToArray());
- graphics.FillPolygon(new SolidBrush(penGray.Color), pointsNormal.ToArray());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement