Advertisement
Guest User

Untitled

a guest
Apr 24th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 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. using System.Threading;
  11.  
  12. namespace Pyramid
  13. {
  14. public partial class Form1 : Form
  15. {
  16. public Form1()
  17. {
  18. InitializeComponent();
  19. }
  20.  
  21. private void pictureBox1_Click(object sender, EventArgs e)
  22. {
  23. Thread firNegru = new Thread (() => deseneaza(Color.Black, 200, 100));
  24. firNegru.Start();
  25. }
  26.  
  27. private void deseneaza(Color culoare, Int16 Rx, Int16 Ry)
  28. {
  29. Graphics g = pictureBox1.CreateGraphics();
  30. Pen creion = new Pen(culoare);
  31. Pen guma = new Pen(Color.DodgerBlue);
  32. //int x, y;
  33. int x1, x2, x3, y1, y2, y3, height = 200;
  34. double alpha;
  35.  
  36. g.DrawEllipse(creion, 130, 230, 400, 200);
  37. for (alpha = -3.14; alpha <= 3.14; alpha += 0.02)
  38. {
  39. x1 = (int)(330 + Rx * Math.Cos(alpha));
  40. y1 = (int)(330 + Ry * Math.Sin(alpha));
  41. x2 = (int)(330 + Rx * Math.Cos(alpha + 2));
  42. y2 = (int)(330 + Ry * Math.Sin(alpha + 2));
  43. x3 = (int)(330 + Rx * Math.Cos(alpha - 2));
  44. y3 = (int)(330 + Ry * Math.Sin(alpha - 2));
  45.  
  46. g.DrawLine(creion, x1, y1, x2, y2);
  47. g.DrawLine(creion, x1, y1, x3, y3);
  48. g.DrawLine(creion, x3, y3, x2, y2);
  49.  
  50. g.DrawLine(creion, x1, y1 - height, x2, y2 - height);
  51. g.DrawLine(creion, x1, y1 - height, x3, y3 - height);
  52. g.DrawLine(creion, x3, y3 - height, x2, y2 - height);
  53.  
  54. g.DrawLine(creion, x1, y1, x1, y1 - height);
  55. g.DrawLine(creion, x3, y3, x3, y3 - height);
  56. g.DrawLine(creion, x2, y2 - height, x2, y2);
  57.  
  58. Thread.Sleep(10);
  59.  
  60. g.DrawLine(guma, x1, y1, x2, y2);
  61. g.DrawLine(guma, x1, y1, x3, y3);
  62. g.DrawLine(guma, x3, y3, x2, y2);
  63.  
  64. g.DrawLine(guma, x1, y1 - height, x2, y2 - height);
  65. g.DrawLine(guma, x1, y1 - height, x3, y3 - height);
  66. g.DrawLine(guma, x3, y3 - height, x2, y2 - height);
  67.  
  68. g.DrawLine(guma, x1, y1, x1, y1 - height);
  69. g.DrawLine(guma, x3, y3, x3, y3 - height);
  70. g.DrawLine(guma, x2, y2 - height, x2, y2);
  71. }
  72. }
  73. }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement