Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- namespace Lab3
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- private void button1_Click(object sender, EventArgs e)
- {
- Graphics myGraphics = this.CreateGraphics();
- Pen pen_red = new Pen(Color.Red, 2);
- float P = 0.08F;
- float x1 = 50, y1 = 50, x2 = 50, y2 = 350, x3 = 350, y3 = 50, x4 = 350, y4 = 350, k;
- myGraphics.DrawLine(pen_red, x1, y1, x2, y2);
- myGraphics.DrawLine(pen_red, x2, y2, x4, y4);
- myGraphics.DrawLine(pen_red, x4, y4, x3, y3);
- myGraphics.DrawLine(pen_red, x3, y3, x1, y1);
- for (k = 1; k <= 50; k++)
- {
- x1 = x1 + (x2 - x1) * P;
- y1 = y1 + (y2 - y1) * P;
- x2 = x2 + (x4 - x2) * P;
- y2 = y2 + (y4 - y2) * P;
- x3 = x3 + (x1 - x3) * P;
- y3 = y3 + (y1 - y3) * P;
- x4 = x4 + (x3 - x4) * P;
- y4 = y4 + (y3 - y4) * P;
- myGraphics.DrawLine(pen_red, x1, y1, x2, y2);
- myGraphics.DrawLine(pen_red, x2, y2, x4, y4);
- myGraphics.DrawLine(pen_red, x4, y4, x3, y3);
- myGraphics.DrawLine(pen_red, x3, y3, x1, y1);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement