Facebook
From Bulky Earthworm, 5 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 226
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace _11._03._19
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         private System.Drawing.Graphics g;
  16.         private System.Drawing.Pen pen1 = new System.Drawing.Pen(Color.Red, 3);
  17.  
  18.         public Form1()
  19.         {
  20.  
  21.             InitializeComponent();
  22.             g = pictureBox1.CreateGraphics();
  23.  
  24.         }
  25.  
  26.     private void button1_Click(object sender, EventArgs e)
  27.         {
  28.             double x=0;
  29.             double y=0;
  30.             double r;
  31.             double n;
  32.             double alfa = 0;
  33.             Double.TryParse(textBox1.Text, out n);
  34.             Double.TryParse(textBox2.Text, out r);
  35.             double przyrost_alfa=(2*Math.PI)/n;
  36.  
  37.             double x0 = r * Math.Cos(przyrost_alfa);
  38.             double y0 = r * Math.Sin(przyrost_alfa);
  39.  
  40.             pictureBox1.Refresh();
  41.             for (int i = 0; i <= n; i++)
  42.             {
  43.  
  44.                 alfa = alfa + przyrost_alfa;
  45.  
  46.                 x = r * Math.Cos(alfa);
  47.                 y = r * Math.Sin(alfa);
  48.                 g.DrawLine(pen1, (float)x0+pictureBox1.Width/2, (float)y0+pictureBox1.Height / 2, (float)x + pictureBox1.Width / 2, (float)y + pictureBox1.Height / 2);
  49.  
  50.                 x0 = x;
  51.                 y0 = y;
  52.  
  53.             }
  54.            
  55.         }
  56.  
  57.         private void label2_Click(object sender, EventArgs e)
  58.         {
  59.  
  60.         }
  61.  
  62.         private void textBox1_TextChanged(object sender, EventArgs e)
  63.         {
  64.  
  65.         }
  66.  
  67.         private void textBox2_TextChanged(object sender, EventArgs e)
  68.         {
  69.  
  70.         }
  71.  
  72.         private void pictureBox1_Click(object sender, EventArgs e)
  73.         {
  74.  
  75.         }
  76.  
  77.         private void button2_Click(object sender, EventArgs e)
  78.         {
  79.             double x = 0;
  80.             double y = 0;
  81.             double r;
  82.             double n;
  83.             double alfa=0;
  84.             Double.TryParse(textBox1.Text, out n);
  85.             Double.TryParse(textBox2.Text, out r);
  86.            
  87.             double przyrost_alfa;
  88.             Double.TryParse(textBox1.Text, out przyrost_alfa);
  89.             double x0 = r * Math.Cos(przyrost_alfa);
  90.             double y0 = r * Math.Sin(przyrost_alfa);
  91.  
  92.             pictureBox1.Refresh();
  93.             for (int i = 0; i <= n; i++)
  94.             {
  95.  
  96.                 alfa = alfa + przyrost_alfa;
  97.  
  98.                 x = r * Math.Cos(alfa);
  99.                 y = r * Math.Sin(alfa);
  100.                 g.DrawLine(pen1, (float)x0 + pictureBox1.Width / 2, (float)y0 + pictureBox1.Height / 2, (float)x + pictureBox1.Width / 2, (float)y + pictureBox1.Height / 2);
  101.  
  102.                 x0 = x;
  103.                 y0 = y;
  104.  
  105.             }
  106.         }
  107.  
  108.         private void button3_Click(object sender, EventArgs e)
  109.         {
  110.             double x = 0;
  111.             double y = 0;
  112.             double r;
  113.             double n;
  114.             double alfa = 0;
  115.             Double.TryParse(textBox1.Text, out n);
  116.             Double.TryParse(textBox2.Text, out r);
  117.             double przyrost_alfa = (2 * Math.PI) / n;
  118.  
  119.             double x0 = r * Math.Cos(przyrost_alfa);
  120.             double y0 = r * Math.Sin(przyrost_alfa);
  121.  
  122.             pictureBox1.Refresh();
  123.             for (int i = 0; i <=7* n; i++)
  124.             {
  125.  
  126.                 alfa = alfa + przyrost_alfa;
  127.  
  128.                 x = r * Math.Cos(alfa);
  129.                 y = r * Math.Sin(alfa);
  130.                 g.DrawLine(pen1, (float)x0 + pictureBox1.Width / 2, (float)y0 + pictureBox1.Height / 2, (float)x + pictureBox1.Width / 2, (float)y + pictureBox1.Height / 2);
  131.  
  132.                 x0 = x;
  133.                 y0 = y;
  134.                 r = r - 0.5;
  135.  
  136.             }
  137.         }
  138.     }
  139. }
  140.