Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Visual Basic 2008 Graphics - Drawing multiple circumscribed circles

Posted on 2009-05-07
3
Medium Priority
?
1,592 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 86

Accepted Solution

by:
Mike Tomlinson earned 2000 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 20

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 20

Author Closing Comment

by:NerdsOfTech
ID: 31579222
Incredible! Nice work again!
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

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

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…

916 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