Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. Imports System.Math
  2. Public Class Formdriehoeken
  3. Private driehoek As driehoek
  4. Private driehoeken(2) As driehoek
  5. Private x As Integer = 120
  6. Private y As Integer = 10
  7. Private z As Integer
  8.  
  9.  
  10. Public Sub New()
  11.  
  12. ' This call is required by the designer.
  13. InitializeComponent()
  14.  
  15. ' Add any initialization after the InitializeComponent() call.
  16. driehoeken(0) = New driehoek(x, y, z)
  17. driehoeken(1) = New driehoek(CInt((x - (z / 2))), CInt((Sqrt(z ^ 2 - (z / 2) ^ 2)) + y), z)
  18. driehoeken(2) = New driehoek(CInt((x + (z / 2))), CInt((Sqrt(z ^ 2 - (z / 2) ^ 2)) + y), z)
  19.  
  20. End Sub
  21.  
  22.  
  23. Private Sub BtnDraw_Click(sender As System.Object, e As System.EventArgs) Handles BtnDraw.Click
  24. z = CInt(TxtZwaarde.Text)
  25. Dim drawarea As Graphics
  26. drawarea = PictureBoxDriehoek.CreateGraphics
  27. Dim pen As Pen = New Pen(Color.Red)
  28. For index As Integer = 0 To 2
  29. driehoeken(index).Display(drawarea, pen)
  30. Next
  31.  
  32. End Sub
  33.  
  34. End Class
  35.  
  36.  
  37.  
  38. Imports System.Math
  39. Public Class driehoek
  40. Private x As Integer
  41. Private y As Integer
  42. Private z As Integer
  43.  
  44. Public Sub New(ByVal initialx As Integer, ByVal initialy As Integer, ByVal initialz As Integer)
  45. x = initialx
  46. y = initialy
  47. z = initialz
  48. End Sub
  49.  
  50. Public Sub Display(ByVal drawarea As Graphics, ByVal pen As Pen)
  51. ' hier wordt de driehoek in elkaar gezet
  52. drawarea.DrawLine(pen, x, y, CInt((x + (z / 2))), CInt((Sqrt(z ^ 2 - (z / 2) ^ 2)) + y))
  53. drawarea.DrawLine(pen, x, y, CInt((x - (z / 2))), CInt((Sqrt(z ^ 2 - (z / 2) ^ 2)) + y))
  54. drawarea.DrawLine(pen, CInt((x - (z / 2))), CInt((Sqrt(z ^ 2 - (z / 2) ^ 2)) + y), CInt((x + (z / 2))), CInt((Sqrt(z ^ 2 - (z / 2) ^ 2)) + y))
  55.  
  56. End Sub
  57.  
  58. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement