Results 1 to 2 of 2

Thread: circle method, forming arcs, small problem

  1. #1

    Thread Starter
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604

    circle method, forming arcs, small problem

    This is modified from an example I found in one of my books:

    For t = 1 To 10
    arc1 = arc2
    arc2 = arc1 + (2 * 3.14159) * (0.1)
    tColor = 20 * t
    Picture1.FillColor = RGB(Int(tColor) / 2, tColor, 255 - tColor)
    Picture1.Circle (Picture1.ScaleWidth / 2, Picture1.ScaleHeight / 2), (Picture1.ScaleHeight / 2.1), , -arc1, -arc2
    Next t

    If you follow that, it makes 10 arcs,each one 1/10 of a full circle
    and each one starting where the last one stopped.
    (Don't worry about the color, just for a clear picture of what's happening)

    I used this to make a pie chart where 10 is the number of groups form my database. Then 0.1 is actually the ratio of group value to total value. (not relevant to the problem)

    The problem, which is really just an annoyance, is that the first arc, beginning at zero, is not closed, and therefore does not hold color. It will remain the color of the background (picture or the form where it is drawn). I've tried to overlap it, but vb won't allow continuing past 2pi, I've tried putting a new arc of the same value at positions 0 and value 1 * 2pi (basically drawing the arc again on top of itself), but the arc that begins at zero has no line connecting it back to the center of the circle.

    I know I could do a line command to make a radius out to the circle, then use floodfill to color in the area, but that is risky as the values change, and also I believe there should be a mathematical (geometric) solution that I've overlooked. Anybody?

    PS, please don't suggest MS Chart control.
    I'm really trying to make add-on object-free apps.

    Thanks all.

    Wengang
    Wen Gang, Programmer
    VB6, QB, HTML, ASP, VBScript, Visual C++, Java

  2. #2

    Thread Starter
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604
    This is a temporary workaround that works pretty well,



    arc1 = 0
    arc2 = 0.001 '1/600 of circle
    Picture1.Circle (Picture1.ScaleWidth / 2, Picture1.ScaleHeight / 2), (Picture1.ScaleHeight / 2.1), , -arc1, -arc2


    For t = 1 To 10
    arc1 = arc2
    arc2 = arc1 + (2 * 3.14159) * (0.1)
    '/////////add this line
    If i = 1 Then arc2 = arc2 - 0.001
    '////////
    tColor = 20 * t
    Picture1.FillColor = RGB(Int(tColor) / 2, tColor, 255 - tColor)
    Picture1.Circle (Picture1.ScaleWidth / 2, Picture1.ScaleHeight / 2), (Picture1.ScaleHeight / 2.1), , -arc1, -arc2
    Next t


    adding the small slice has no visible impact on the pie, and it is compensated for in the largest slice of pie ( a piece of code I didn't include puts the groups in order largest to smallest, so that the 0.001 is taken from the largest piece)

    I may leave it at that
    Wen Gang, Programmer
    VB6, QB, HTML, ASP, VBScript, Visual C++, Java

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width