Question draw circle

Akramselwe

New member
Joined
Nov 23, 2015
Messages
1
Programming Experience
Beginner
Hi

I want to create function to draw circle put using this :


nx = x + r *Math.Sin(th * 22 / 7 / 180);
ny = y + r2 *Math.Cos(th * 22 / 7 / 180);

and draw them in picture box using SetPixel method.
 

JuggaloBrotha

Staff member
Joined
Apr 23, 2011
Messages
177
Location
Lansing, MI; USA
Programming Experience
10+
Hi

I want to create function to draw circle put using this :


nx = x + r *Math.Sin(th * 22 / 7 / 180);
ny = y + r2 *Math.Cos(th * 22 / 7 / 180);

and draw them in picture box using SetPixel method.
For starters you'll need to put a PictureBox on a form, then handle the Paint event (be sure to use e.Graphics and not create your own) then you can do your drawing.
For circles it's easy as there's a DrawEllipse you can call to have it draw the circle for you, here's an article: How to: Draw Graphics on a Windows Form

Doing it using your own calculus math, I'm not sure how, but I'm sure it can be done.
 

Hawk

New member
Joined
Mar 8, 2016
Messages
3
Programming Experience
3-5
For starters you'll need to put a PictureBox on a form, then handle the Paint event (be sure to use e.Graphics and not create your own) then you can do your drawing.
For circles it's easy as there's a DrawEllipse you can call to have it draw the circle for you, here's an article: How to: Draw Graphics on a Windows Form

Doing it using your own calculus math, I'm not sure how, but I'm sure it can be done.

Why would you want to use a PictureBox here and not just draw on an existing control, or even create your own?

Drawing a circle is very easy. Just use the following method.
C#:
[Graphics].DrawEllipse([Pen], [Rectangle]);

https://msdn.microsoft.com/en-us/library/system.drawing.graphics.drawellipse(v=vs.110).aspx
 

JuggaloBrotha

Staff member
Joined
Apr 23, 2011
Messages
177
Location
Lansing, MI; USA
Programming Experience
10+
Why would you want to use a PictureBox here and not just draw on an existing control, or even create your own?

Drawing a circle is very easy. Just use the following method.
C#:
[Graphics].DrawEllipse([Pen], [Rectangle]);

https://msdn.microsoft.com/en-us/library/system.drawing.graphics.drawellipse(v=vs.110).aspx
Because the OP stated that he's using a PictureBox.

In reality you can draw on anything in .Net so long as you have a Graphics object to use, for Bitmap objects you can create the Graphics object yourself to use.
 
Top Bottom