Add Pictures in a circle..

DreamKid
02-02-2004, 12:11 PM
I'm trying to add a few same pictures into the form in a circle.
I try to use loop & adding it but it just don't comes out right.

Please give me some hint here.. my brain is jam now :confused:

Machaira
02-05-2004, 10:16 AM
Maybe if you posted the code you're using....

passel
02-06-2004, 06:28 AM
The Sine and Cosine of an angle are the ratio of the two sides of a
right triangle to it's hypoteneuse. So for a given hypoteneuse (used as
the radius of a circle), if you multiply hypoteneuse by the Sine of an Angle, and the
Cosine of the same angle, you will get the relative X and Y values of the
point on the perimeter of the circle at that angle.

Angles are measured in Radians in most computer languages.
There are 2pi radians in a full circle.
So decide what your desired radius is, and how many points you want on
your circle, and where you want the center of your circle to be.

i.e.

'6 points around a circle with a radius of 100 pixels, centered on pixel(120,120)

Const pi As Single = 3.1415926 '180 degrees
Const pi2 As Single = 2 * pi '360 degrees
Const DegtoRad As Single = pi / 180 'Multiply degrees by this to get Radians
Const RadtoDeg As Single = 180 / pi 'Multiply Radians by this to get Degrees

Private Sub Command1_Click()
Dim inc As Single, i As Integer, ang As Single
Dim x As Single, y As Single

inc = pi2 / 6 '(360 degress / 6) 'six points
Picture1.DrawWidth = 5
Picture1.ScaleMode = vbPixels
For i = 1 To 6 ' For the six points
x = 100 * Sin(ang) 'radius = 100
y = 100 * Cos(ang) 'radius = 100
Picture1.PSet (120 + x, 120 + y) 'centered on 120,120
ang = ang + inc 'the angle to the next point
Next
End Sub

There are other methods to plot a circle, some more efficient, but this
is a common way of doing it.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum