Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Visual Basic 2008 Graphics - Drawing multiple circumscribed circles

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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

715 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