Advertisement
Guest User

NO.9

a guest
Jun 14th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
  2.         Me.AutoSize = True : Me.Text = "Graph by Your ID"
  3.         PictureBox1.Top = 0 : PictureBox1.Left = 0
  4.         PictureBox1.Width = 500 : PictureBox1.Height = 500
  5.         Button1.Text = "Draw" : Button1.Font = New Font("Courier", 20)
  6.         Button1.Width = 100 : Button1.Height = 50
  7.         Button1.Top = 10 : Button1.Left = PictureBox1.Width + 50
  8.  
  9.     End Sub
  10.  
  11.     Private Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
  12.         Dim myGraph As Graphics = PictureBox1.CreateGraphics
  13.         Dim myPen1, myPen2, myPen3 As Pen
  14.         Dim id, ang, bigR, x1, y1 As Single
  15.  
  16.  
  17.         myPen1 = New Pen(Color.Blue, 5) : myGraph.DrawRectangle(myPen1, 0, 0, 500, 500)
  18.         myPen2 = New Pen(Color.Gray, 1)
  19.         myPen3 = New Pen(Color.DarkMagenta, 3)
  20.  
  21.         myGraph.DrawLine(myPen2, 0, 250, 500, 250)
  22.         myGraph.DrawLine(myPen2, 250, 0, 250, 500)
  23.  
  24.         bigR = 200
  25.  
  26.         myGraph.TranslateTransform(0, 0)
  27.         For id = 0 To 90 Step 6
  28.             ang = id * Math.PI / 180
  29.             x1 = bigR * Math.Cos(ang) : y1 = bigR * Math.Sin(ang)
  30.             myGraph.DrawLine(myPen3, 0, 0, x1, y1)
  31.  
  32.         Next
  33.  
  34.         myGraph.TranslateTransform(500, 0)
  35.         For id = 90 To 180 Step 6
  36.             ang = id * Math.PI / 180
  37.             x1 = bigR * Math.Cos(ang) : y1 = bigR * Math.Sin(ang)
  38.             myGraph.DrawLine(myPen3, 0, 0, x1, y1)
  39.  
  40.         Next
  41.         myGraph.TranslateTransform(-500, 500)
  42.         For id = 270 To 360 Step 6
  43.             ang = id * Math.PI / 180
  44.             x1 = bigR * Math.Cos(ang) : y1 = bigR * Math.Sin(ang)
  45.             myGraph.DrawLine(myPen3, 0, 0, x1, y1)
  46.  
  47.         Next
  48.  
  49.         myGraph.TranslateTransform(500, 0)
  50.  
  51.         For id = 180 To 270 Step 6
  52.             ang = id * Math.PI / 180
  53.             x1 = bigR * Math.Cos(ang) : y1 = bigR * Math.Sin(ang)
  54.             myGraph.DrawLine(myPen3, 0, 0, x1, y1)
  55.  
  56.         Next
  57.  
  58.  
  59.  
  60.     End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement