Advertisement
Java_Volume1 Miscellaneous #93005

Circle Drawing Example

This code is simply to illustrate the mathematical operations necessary to draw a circle. Of course I realize VB has built in functions for this, but thought this might be useful for some to understand. In my example, I use a picture box with the PSet method to do the drawing.

AI

Riepilogo AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Codice sorgente
original-source
Private Sub Command1_Click()
  Dim intRadius, intDegree As Integer
  Dim sngX, sngY As Single
  
  If IsNumeric(Text1.Text) Then
    intRadius = Text1.Text
    For intDegree = 1 To 360
      sngX = (Cos(intDegree) * intRadius) + intRadius
      sngY = intRadius - (Sin(intDegree) * intRadius)
      Picture1.PSet (sngX, sngY), vbBlack
    Next
  Else
    MsgBox "Please enter a numeric value for the radius."
    Text1.SetFocus
  End If
End Sub
Private Sub Command2_Click()
  Unload Form1
End Sub
Commenti originali (3)
Recuperato da Wayback Machine