Advertisement
Guest User

Graphics exercise2

a guest
Jun 15th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Public Class Form1
  2.     Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
  3.         Dim myGraphics As Graphics = PictureBox1.CreateGraphics
  4.         Dim myPen0 As New Pen(Color.Blue, 5)
  5.         Dim myPen1 As New Pen(Color.Gray, 0.5) : Dim myPen2 As New Pen(Color.Red, 2) : Dim myPen3 As New Pen(Color.Black, 2)
  6.         Dim a, id As Integer
  7.         Dim x1, y1, y2, angle As Single
  8.         myGraphics.Clear(Me.BackColor)
  9.         myGraphics.DrawRectangle(myPen0, x1, y1, 499, 499)
  10.  
  11.         myGraphics.DrawLine(myPen1, 50, 0, 50, 500)
  12.         myGraphics.DrawLine(myPen1, 0, 250, 500, 250)
  13.         a = 150
  14.        
  15.         myGraphics.TranslateTransform(50, 250)
  16.         'For id = 0 To 360 Step 2
  17.        'angle = id * Math.PI / 180
  18.        'x1 = a * Math.Cos(angle) : y1 = a * Math.Sin(angle)
  19.        'myGraphics.DrawLine(myPen2, 50, 100, 1, 1)
  20.        'Next id
  21.  
  22.         For x1 = -50 To 450 Step 1
  23.             y1 = -1 * Math.Cos(x1 * 7 * Math.PI / 500) * 100
  24.             y2 = -1 * Math.Sin(x1 * 7 * Math.PI / 500) * 100
  25.             myGraphics.DrawRectangle(myPen2, x1, y1, 1, 1)
  26.             myGraphics.DrawRectangle(myPen3, x1, y2, 1, 1)
  27.         Next
  28.         myGraphics.Dispose()
  29.     End Sub
  30.     Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
  31.         Me.AutoSize = True
  32.         PictureBox1.Top = 0 : PictureBox1.Left = 0
  33.         PictureBox1.Width = 500 : PictureBox1.Height = 500
  34.         Button1.Left = PictureBox1.Width + 50 : Button1.Top = 150
  35.     End Sub
  36. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement