We help IT Professionals succeed at work.

Plotting a circle with system.drawing including rotated labels

pixuk asked
Last Modified: 2008-02-01
I am trying to use system.drawing to draw a circle divided into a variable amount of points, with a text label at each of the points, preferably at an angle matching the current point on the circle (so the labels 'fan out' from the center).

Before I attempt to try and stitch this into my database backend, the first thing I'm trying to do is simply draw the circle as a series of connected points. Something along these lines

for t = 1 to 360 step 10
      x = cos(t)
      y = sin(t)
      pts(cpt) = New Point(x,y)
g.DrawCurve(New Pen(Color.Red), pts, 0.8F)

Although obviously with a bit more too it than that. However, I don't think my maths is quite up to the task, and the above method doesn't take into account the labels, so probably isn't the way to go anyway.

I should make it clear I'm not just trying to draw a circle - I'm trying to plot points and arrange them in a circle, if that makes sense.

Been searching Google, but can't really find anything about drawing a circle from scratch.
Watch Question

Point is for integer points only. You need PointF

You can do a debug.print(pts(cpt).x & " " & pts(cpt).y) to verify that


Thanks for the tip, but to be honest, at this stage I'm not actually that bothered about the accuracy of the point position - the first thing I need to do is draw a circle, and the snippet above didn't seem to do the trick.

Just to re-iterate the question; I want to draw a circle, and at a variable number of points around it, put text labels at an angle equivalent to that point on the circle.

yes, but the problem is 0<cos(x) <1, so putting it in a Point object will force it to round off to 0 or 1

How about you put 100cos(x) into the point?


I see what your saying. Do you have an example of code which draws a circle using PointF?

Do you know how to draw text at an angle?, assuming, of course, I can get that far!

PointF, just exactly the same as what you are doing :)

Just declare PointF instead of Point

Also, I think multiplying your co-ordinates will help, otherwise your circle will be too small??

Ummm.... drawing text at an angle
I would try drawing text on a Bitmap first, then apply a transform filter to it. Try googling for "rotating an image with VB.Net"
Unlock this solution and get a sample of our free trial.
(No credit card required)

Thanks, I think it's a bit mean to give a C though... I did answer the original question

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.