Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
500MB 27GB Web Hosting - $9.95/Month
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
TitleDraw ellipses by specifying their bounding boxes
Keywordsellipse, bound, box, bounding box
CategoriesGraphics
 
Drawing ellipses with the Circle method is a bit counterintuitive. You need to specify the center of the ellipse, the longer of its two radii, and its aspect ratio (ratio of height to width).

Subroutine DrawEllipse lets you specify an ellipse by giving its bounding box. It calculates the center of the ellipse, the radius it needs to specify, and the aspect ratio needed to place the ellipse inside the bounding box.

 
' Draw an ellipse in the indicated rectangle.
Private Sub DrawEllipse(ByVal obj As Object, ByVal xmin As _
    Single, ByVal ymin As Single, ByVal xmax As Single, _
    ByVal ymax As Single)
Dim dx As Single
Dim dy As Single
Dim r As Single

    dx = xmax - xmin
    dy = ymax - ymin
    If dx > dy Then
        r = dx / 2
    Else
        r = dy / 2
    End If
    obj.Circle ((xmin + xmax) / 2, (ymin + ymax) / 2), r, , _
        , , dy / dx
End Sub
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated