Advertisement
Guest User

Graphics exercise3

a guest
Jun 15th, 2019
82
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)
  6.         Dim a, id As Integer
  7.         Dim x1, y1, angle As Single
  8.         Dim R As Single
  9.  
  10.         myGraphics.Clear(Me.BackColor)
  11.         myGraphics.DrawRectangle(myPen0, x1, y1, 499, 499)
  12.         a = 150
  13.  
  14.         myGraphics.TranslateTransform(500 / 2, 500 / 2)
  15.         For angle = 0 To 2 * Math.PI Step 0.01
  16.             R = 75 * (1 - 2 * Math.Sin(3 * angle))
  17.             'x1 = angle * Math.Cos(R) * 10
  18.            'y1 = angle * Math.Sin(R) * 10
  19.            x1 = R * Math.Cos(angle) * 1
  20.             y1 = R * Math.Sin(angle) * 1
  21.             myGraphics.DrawRectangle(myPen2, x1, y1, 1, 1)
  22.  
  23.         Next
  24.  
  25.  
  26.         'For id = 0 To 360 Step 2
  27.        'angle = id * Math.PI / 180
  28.        'x1 = a * Math.Cos(angle) : y1 = a * Math.Sin(angle)
  29.        'myGraphics.DrawRectangle(myPen2, x1, y1, 1, 1)
  30.        'Next id
  31.        myGraphics.Dispose()
  32.     End Sub
  33.     Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
  34.         Me.AutoSize = True
  35.         PictureBox1.Top = 0 : PictureBox1.Left = 0
  36.         PictureBox1.Width = 500 : PictureBox1.Height = 500
  37.         Button1.Left = PictureBox1.Width + 50 : Button1.Top = 150
  38.     End Sub
  39. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement