Advertisement
punidota

Untitled

Sep 17th, 2015
407
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.68 KB | None | 0 0
  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 Lab3
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         public Form1()
  16.         {
  17.             InitializeComponent();
  18.         }
  19.         private void Form1_Load(object sender, EventArgs e)
  20.         {
  21.  
  22.         }
  23.         private void button1_Click(object sender, EventArgs e)
  24.         {
  25.  
  26.             Graphics myGraphics = this.CreateGraphics();
  27.  
  28.             Pen pen_red = new Pen(Color.Red, 2);
  29.            
  30.             float P = 0.08F;
  31.             float x1 = 50, y1 = 50, x2 = 50, y2 = 350, x3 = 350, y3 = 50, x4 = 350, y4 = 350, k;
  32.             myGraphics.DrawLine(pen_red, x1, y1, x2, y2);
  33.             myGraphics.DrawLine(pen_red, x2, y2, x4, y4);
  34.             myGraphics.DrawLine(pen_red, x4, y4, x3, y3);
  35.             myGraphics.DrawLine(pen_red, x3, y3, x1, y1);
  36.  
  37.  
  38.             for (k = 1; k <= 50; k++)
  39.             {
  40.                 x1 = x1 + (x2 - x1) * P;
  41.                 y1 = y1 + (y2 - y1) * P;
  42.                 x2 = x2 + (x4 - x2) * P;
  43.                 y2 = y2 + (y4 - y2) * P;
  44.                 x3 = x3 + (x1 - x3) * P;
  45.                 y3 = y3 + (y1 - y3) * P;
  46.                 x4 = x4 + (x3 - x4) * P;
  47.                 y4 = y4 + (y3 - y4) * P;
  48.  
  49.                 myGraphics.DrawLine(pen_red, x1, y1, x2, y2);
  50.                 myGraphics.DrawLine(pen_red, x2, y2, x4, y4);
  51.                 myGraphics.DrawLine(pen_red, x4, y4, x3, y3);
  52.                 myGraphics.DrawLine(pen_red, x3, y3, x1, y1);
  53.             }
  54.         }
  55.  
  56.  
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement