Advertisement
punidota

Untitled

Sep 23rd, 2015
526
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.96 KB | None | 0 0
  1. usingSystem;
  2. usingSystem.Collections.Generic;
  3. usingSystem.ComponentModel;
  4. usingSystem.Data;
  5. usingSystem.Drawing;
  6. usingSystem.Linq;
  7. usingSystem.Text;
  8. usingSystem.Threading.Tasks;
  9. usingSystem.Windows.Forms;
  10.  
  11. namespace OKGL5
  12. {
  13. publicpartialclassFormSnow : Form
  14.     {
  15. publicFormSnow()
  16.         {
  17. InitializeComponent();
  18.         }
  19.  
  20. Void Snow(PointF A, PointF B, PointF C, int n, Graphics g, PenPen, PenRubber)
  21.         {
  22. if (n > 0)
  23.             {
  24.                 --n;
  25. PointF a = newPointF(A.X + (B.X - A.X) / 3, A.Y + (B.Y - A.Y) / 3);
  26. PointF b = newPointF(A.X + 2 * (B.X - A.X) / 3, A.Y + 2 * (B.Y - A.Y) / 3);
  27. PointF c = newPointF((B.X + A.X) / 2, (B.Y + A.Y) / 2);
  28.  
  29. PointFan = newPointF(A.X + (C.X - A.X) / 3, A.Y + (C.Y - A.Y) / 3);
  30. PointFbn = newPointF(C.X + 2 * (B.X - C.X) / 3, C.Y + 2 * (B.Y - C.Y) / 3);
  31. PointFcn = newPointF(c.X - (C.X - c.X) / 3, c.Y + (c.Y - C.Y) / 3);
  32.  
  33. g.DrawLine(Pen, a, cn);
  34. g.DrawLine(Pen, b, cn);
  35. g.DrawLine(Rubber, a, b);
  36.  
  37. Snow(a, cn, b, n, g, Pen, Rubber);
  38. Snow(cn, b, a, n, g, Pen, Rubber);
  39. Snow(A, a, an, n, g, Pen, Rubber);
  40. Snow(B, b, bn, n, g, Pen, Rubber);
  41.             }
  42.         }
  43.  
  44. privatevoidbtnDraw_Click(objectsender, EventArgs e)
  45.         {
  46. Graphics g = CreateGraphics();
  47. PenPen = newPen(Color.Blue, 2);
  48. PenRubber = newPen(Color.Yellow, 2);
  49.  
  50. PointF A = newPointF(450, 400);
  51. PointF B = newPointF(50, 400);
  52. PointF C = newPointF(250, 50);
  53.  
  54. g.DrawLine(Pen, A, B);
  55. g.DrawLine(Pen, B, C);
  56. g.DrawLine(Pen, C, A);
  57. try
  58.             {
  59. int n = Convert.ToInt32(txbGlub.Text);
  60. Snow(A, B, C, n, g, Pen, Rubber);
  61. Snow(B, C, A, n, g, Pen, Rubber);
  62. Snow(C, A, B, n, g, Pen, Rubber);
  63.             }
  64. catch (Exception)
  65.             {
  66. int n = 1;
  67.             }
  68.         }
  69.  
  70. Privatevoid btnClear_Click(objectsender, EventArgs e)
  71.         {
  72. Graphics g = CreateGraphics();
  73. g.Clear(Color.Yellow);
  74. txbGlub.Text = "";
  75.         }
  76.  
  77. privatevoidbtnClose_Click(objectsender, EventArgs e)
  78.         {
  79. Application.Exit();
  80.         }
  81.     }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement