Solved

Visual Basic 2008 Graphics - Drawing multiple circumscribed circles

Posted on 2009-05-07
3
1,580 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 86

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

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…
This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
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…

739 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