Advertisement
Guest User

exercise 7

a guest
Jun 16th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. Public Class Form1
  2.  
  3. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  4. Me.AutoSize = True : Me.Text = "Graph by Your ID"
  5. PictureBox1.Top = 0 : PictureBox1.Left = 0
  6. PictureBox1.Width = 500 : PictureBox1.Height = 500
  7. Button1.Text = "Draw" : Button1.Font = New Font("Courier", 20)
  8. Button1.Width = 100 : Button1.Height = 50
  9. Button1.Top = 10 : Button1.Left = PictureBox1.Width + 50
  10. End Sub
  11.  
  12. Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
  13. Dim myGraph As Graphics = PictureBox1.CreateGraphics
  14. Dim myPen1, myPen2, myPen3 As Pen
  15. Dim id, ang, bigR, x1, y1, x2, y2 As Single
  16. myPen1 = New Pen(Color.Blue, 5) : myGraph.DrawRectangle(myPen1, 0, 0, 500, 500)
  17. myPen2 = New Pen(Color.Gray, 1)
  18. 'myGraph.DrawLine(myPen2, 0, 250, 500, 250)
  19. 'myGraph.DrawLine(myPen2, 250, 0, 250, 5000)
  20. 'myGraph.TranslateTransform(250, 250)
  21. myPen3 = New Pen(Color.cyan, 6)
  22. bigR = 400
  23. For id = 1 To 180
  24. ang = id * Math.PI / 45
  25. x1 = 0 : y1 = bigR * Math.Sin(ang)
  26. x2 = bigR * Math.Cos(ang) : y2 = y1
  27. myGraph.DrawLine(myPen3, x1, y1, x2, y2)
  28. Next
  29.  
  30. End Sub
  31. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement