Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.19 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Drawing;
  4. using System.Drawing.Drawing2D;
  5. using System.Windows.Forms;
  6.  
  7. namespace LabSenyshyn6
  8. {
  9.     public partial class FormGaltel : Form
  10.     {
  11.         Graphics graphics;
  12.         const int radius = 150;
  13.         Pen penGray = new Pen(Color.Black, 0);
  14.         Pen penShadow = new Pen(Color.Black, 30);
  15.         List<PointF> pointsCircled = new List<PointF>();
  16.         List<PointF> pointsNormal = new List<PointF>();
  17.  
  18.         public FormGaltel()
  19.         {
  20.             InitializeComponent();
  21.         }
  22.  
  23.         private void FormGaltel_Paint(object sender, PaintEventArgs e)
  24.         {
  25.             graphics = CreateGraphics();
  26.         }
  27.  
  28.         private void numericUpDown1_ValueChanged(object sender, EventArgs e)
  29.         {
  30.             graphics.Clear(Color.Silver);
  31.             label1.Text = "";
  32.             pointsCircled.Clear();
  33.             pointsNormal.Clear();
  34.             int n = (int)numericUpDown1.Value;
  35.             if(n != 1)
  36.             {
  37.                 label1.Text = " →";
  38.                 penGray.LineJoin = LineJoin.Round;
  39.                 penShadow.LineJoin = LineJoin.Round;
  40.                 double circledX;
  41.                 double circledY;
  42.                 for (int i = 0; i < n; i++)
  43.                 {
  44.                     circledX = radius * Math.Cos(2 * Math.PI / (float)n * i);
  45.                     circledY = radius * Math.Sin(2 * Math.PI / (float)n * i);
  46.                     PointF figureCircled = new PointF((float)(((600 + radius) + circledX)), (float)(((33 + radius) + circledY)));
  47.                     PointF figureNormal = new PointF((float)(((40 + radius) + circledX)), (float)(((33 + radius) + circledY)));
  48.                     pointsCircled.Add(figureCircled);
  49.                     pointsNormal.Add(figureNormal);
  50.                 }
  51.  
  52.                 graphics.DrawPolygon(penShadow, pointsCircled.ToArray());
  53.                 graphics.FillPolygon(new SolidBrush(penShadow.Color), pointsCircled.ToArray());
  54.  
  55.                 graphics.DrawPolygon(penGray, pointsNormal.ToArray());
  56.                 graphics.FillPolygon(new SolidBrush(penGray.Color), pointsNormal.ToArray());
  57.             }
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement