Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Math
- Public Class Formdriehoeken
- Private driehoek As driehoek
- Private driehoeken(2) As driehoek
- Private x As Integer = 120
- Private y As Integer = 10
- Private z As Integer
- Public Sub New()
- ' This call is required by the designer.
- InitializeComponent()
- ' Add any initialization after the InitializeComponent() call.
- driehoeken(0) = New driehoek(x, y, z)
- driehoeken(1) = New driehoek(CInt((x - (z / 2))), CInt((Sqrt(z ^ 2 - (z / 2) ^ 2)) + y), z)
- driehoeken(2) = New driehoek(CInt((x + (z / 2))), CInt((Sqrt(z ^ 2 - (z / 2) ^ 2)) + y), z)
- End Sub
- Private Sub BtnDraw_Click(sender As System.Object, e As System.EventArgs) Handles BtnDraw.Click
- z = CInt(TxtZwaarde.Text)
- Dim drawarea As Graphics
- drawarea = PictureBoxDriehoek.CreateGraphics
- Dim pen As Pen = New Pen(Color.Red)
- For index As Integer = 0 To 2
- driehoeken(index).Display(drawarea, pen)
- Next
- End Sub
- End Class
- Imports System.Math
- Public Class driehoek
- Private x As Integer
- Private y As Integer
- Private z As Integer
- Public Sub New(ByVal initialx As Integer, ByVal initialy As Integer, ByVal initialz As Integer)
- x = initialx
- y = initialy
- z = initialz
- End Sub
- Public Sub Display(ByVal drawarea As Graphics, ByVal pen As Pen)
- ' hier wordt de driehoek in elkaar gezet
- drawarea.DrawLine(pen, x, y, CInt((x + (z / 2))), CInt((Sqrt(z ^ 2 - (z / 2) ^ 2)) + y))
- drawarea.DrawLine(pen, x, y, CInt((x - (z / 2))), CInt((Sqrt(z ^ 2 - (z / 2) ^ 2)) + y))
- 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))
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement