Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleDraw an Apollonian gasket with circles filled by random colors in Visual Basic 6
DescriptionThis example shows how to draw an Apollonian gasket with circles filled by random colors in Visual Basic 6.
Keywordsrandom 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
CategoriesAlgorithms, 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
 
 
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated