Solved

Visual Basic 2008 Graphics - Drawing multiple circumscribed circles

Posted on 2009-05-07
3
1,574 Views
Last Modified: 2013-11-27
Circle within a circle within a circle...etc...etc...down to 1 point

Circles must have a constant radius. No elipses please.

Please Include complete project (which includes form1) with screenshot.

0
Comment
Question by:NerdsOfTech
  • 2
3 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
Comment Utility
Here is the "opposite" approach...starting in the middle and working our way out:
Public Class Form1
 

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Me.DoubleBuffered = True

    End Sub
 

    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint

        Static R As New Random

        Dim C As Color

        Dim center As New Point(Me.ClientRectangle.Width / 2, Me.ClientRectangle.Height / 2)

        Dim rc As Rectangle = New Rectangle(center.X, center.Y, 1, 1)

        While rc.Width < Me.ClientRectangle.Width AndAlso rc.Height < Me.ClientRectangle.Height

            C = Color.FromArgb(255, R.Next(0, 256), R.Next(0, 256), R.Next(0, 256))

            Using P As New Pen(C, 2)

                e.Graphics.DrawEllipse(P, rc)

            End Using

            rc.Inflate(1, 1)

        End While

    End Sub
 

    Private Sub Form1_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SizeChanged

        Me.Refresh()

    End Sub
 

End Class

Open in new window

CircleDemo2.jpg
0
 
LVL 19

Author Comment

by:NerdsOfTech
Comment Utility
Nice! Is Inflate the only way to go about this?

Now if you were to start from the largest circle and go inward -- how would you approach this differently?

In other words is there a way to go from largest circle to smallest circle by using "square" retangle paths with smaller and smaller side lengths, etc. to guide the radius lengths downward until the path is 1 (and draw one point)?

Related Question: LINKED!
I am interested in how to do this without inflate going from outermost circle to the innermost point
0
 
LVL 19

Author Closing Comment

by:NerdsOfTech
Comment Utility
Incredible! Nice work again!
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video discusses moving either the default database or any database to a new volume.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now