|
|
Title | Draw an Apollonian gasket with circles filled by random colors in Visual Basic 6 |
Description | This example shows how to draw an Apollonian gasket with circles filled by random colors in Visual Basic 6. |
Keywords | random colors, mathematics, algorithms, graphics, Apollonian gasket, Apollonian packing, Apollonius' Problem, Apollonius, Apollonian circles, tangent cicles, geometry, example, example program, Windows Forms programming, Visual Basic 6, VB 6 |
Categories | Algorithms, Graphics |
|
|
This example is similar to the example Draw an Apollonian gasket (or Apollonian packing) in Visual Basic 6 except it fills the circles it draws with random colors. The program uses the following code to generate random colors.
|
|
' Return a random color.
Private Function RandomColor() As OLE_COLOR
Dim i As Integer
i = Int(Rnd * 16)
RandomColor = QBColor(i)
End Function
|
|
This code uses Rnd to generate a random number between 0 and 15. It uses that number as an index into the QBColor function, which returns a color.
The program uses the RandomColor function to create brushes for filling the circles that it draws. For example, the following code shows how the program draws the large enclosing circle.
|
|
' Find the circle that contains them all.
Set big_circle = FindApollonianCircle( _
circle0, circle1, circle2, -1, -1, -1)
big_circle.Draw pic, RandomColor
|
|
|
|
|
|
|
|
|