Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. private void Form1_Paint(object sender, PaintEventArgs e)
  2. {
  3. Graphics g = e.Graphics;
  4. Pen whitePen = new Pen(Color.White, 1);
  5. float height = 50.0f;
  6. float width = (float)(4 * (height / 2 / Math.Sqrt(3)));
  7. float y = height / 2;
  8. float x = 0;
  9. float row = 0.0f;
  10. y += row * height;
  11. float col = 1.0f;
  12. if (col % 2 == 1)
  13. {
  14. y += height / 2;
  15. }
  16. x += col * (width * 0.75f);
  17. PointF pt1 = new PointF(x, y);
  18. PointF pt2 = new PointF(x + width * 0.25f, y - height / 2);
  19. PointF pt3 = new PointF(x + width * 0.75f, y - height / 2);
  20. PointF pt4 = new PointF(x + width, y);
  21. PointF pt5 = new PointF(x + width * 0.75f, y + height / 2);
  22. PointF pt6 = new PointF(x + width * 0.25f, y + height / 2);
  23. g.DrawLine(whitePen, pt1, pt2);
  24. g.DrawLine(whitePen, pt2, pt3);
  25. g.DrawLine(whitePen, pt3, pt4);
  26. g.DrawLine(whitePen, pt4, pt5);
  27. g.DrawLine(whitePen, pt5, pt6);
  28. g.DrawLine(whitePen, pt6, pt1);
  29. whitePen.Dispose();
  30. g.Dispose();
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement