Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- usingSystem;
- usingSystem.Collections.Generic;
- usingSystem.ComponentModel;
- usingSystem.Data;
- usingSystem.Drawing;
- usingSystem.Linq;
- usingSystem.Text;
- usingSystem.Threading.Tasks;
- usingSystem.Windows.Forms;
- namespace OKGL5
- {
- publicpartialclassFormSnow : Form
- {
- publicFormSnow()
- {
- InitializeComponent();
- }
- Void Snow(PointF A, PointF B, PointF C, int n, Graphics g, PenPen, PenRubber)
- {
- if (n > 0)
- {
- --n;
- PointF a = newPointF(A.X + (B.X - A.X) / 3, A.Y + (B.Y - A.Y) / 3);
- PointF b = newPointF(A.X + 2 * (B.X - A.X) / 3, A.Y + 2 * (B.Y - A.Y) / 3);
- PointF c = newPointF((B.X + A.X) / 2, (B.Y + A.Y) / 2);
- PointFan = newPointF(A.X + (C.X - A.X) / 3, A.Y + (C.Y - A.Y) / 3);
- PointFbn = newPointF(C.X + 2 * (B.X - C.X) / 3, C.Y + 2 * (B.Y - C.Y) / 3);
- PointFcn = newPointF(c.X - (C.X - c.X) / 3, c.Y + (c.Y - C.Y) / 3);
- g.DrawLine(Pen, a, cn);
- g.DrawLine(Pen, b, cn);
- g.DrawLine(Rubber, a, b);
- Snow(a, cn, b, n, g, Pen, Rubber);
- Snow(cn, b, a, n, g, Pen, Rubber);
- Snow(A, a, an, n, g, Pen, Rubber);
- Snow(B, b, bn, n, g, Pen, Rubber);
- }
- }
- privatevoidbtnDraw_Click(objectsender, EventArgs e)
- {
- Graphics g = CreateGraphics();
- PenPen = newPen(Color.Blue, 2);
- PenRubber = newPen(Color.Yellow, 2);
- PointF A = newPointF(450, 400);
- PointF B = newPointF(50, 400);
- PointF C = newPointF(250, 50);
- g.DrawLine(Pen, A, B);
- g.DrawLine(Pen, B, C);
- g.DrawLine(Pen, C, A);
- try
- {
- int n = Convert.ToInt32(txbGlub.Text);
- Snow(A, B, C, n, g, Pen, Rubber);
- Snow(B, C, A, n, g, Pen, Rubber);
- Snow(C, A, B, n, g, Pen, Rubber);
- }
- catch (Exception)
- {
- int n = 1;
- }
- }
- Privatevoid btnClear_Click(objectsender, EventArgs e)
- {
- Graphics g = CreateGraphics();
- g.Clear(Color.Yellow);
- txbGlub.Text = "";
- }
- privatevoidbtnClose_Click(objectsender, EventArgs e)
- {
- Application.Exit();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement