Solved

Visual Basic 2008 Graphics - Drawing multiple circumscribed circles

Posted on 2009-05-07
3
1,576 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
ID: 24331011
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
ID: 24331232
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
ID: 31579222
Incredible! Nice work again!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
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…
A short film showing how OnPage and Connectwise integration works.

929 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

10 Experts available now in Live!

Get 1:1 Help Now