drawing circles.
-
Have you hardcoded the parameters in the DrawEllipse method? Following code works fine:
gx.Clear(this.BackColor); gx = this.CreateGraphics(); gx.DrawEllipse(Pens.Red, (this.Width / 2 - 10), (this.Height / 2 - 10), 20, 20);
I don't hardcode the values. I get the center of the form and then try to draw the concentric circles
You need to google first, if you have "It's urgent please" mentioned in your question. ;-)_AnShUmAn_
-
I don't hardcode the values. I get the center of the form and then try to draw the concentric circles
You need to google first, if you have "It's urgent please" mentioned in your question. ;-)_AnShUmAn_
-
Of course! Based on the size of the form I have to draw concentric circles ( A user can resize the form). So the center of the circles should remain at the center of the form(assuming square shaped form) always. Also the circles should shrink/grow as the user resizes the form. I hope it's clearer now. In essence I have to create circles dynamically so that the center for two or more circles remain as the center of the form and the radius for each can be calculated in terms of a ratio.
You need to google first, if you have "It's urgent please" mentioned in your question. ;-)_AnShUmAn_
-
Of course! Based on the size of the form I have to draw concentric circles ( A user can resize the form). So the center of the circles should remain at the center of the form(assuming square shaped form) always. Also the circles should shrink/grow as the user resizes the form. I hope it's clearer now. In essence I have to create circles dynamically so that the center for two or more circles remain as the center of the form and the radius for each can be calculated in terms of a ratio.
You need to google first, if you have "It's urgent please" mentioned in your question. ;-)_AnShUmAn_
-
Your code only draws one circle at the center of the dialog. What if I want to draw two circles of different radius at the same center.
You need to google first, if you have "It's urgent please" mentioned in your question. ;-)_AnShUmAn_
-
Your code only draws one circle at the center of the dialog. What if I want to draw two circles of different radius at the same center.
You need to google first, if you have "It's urgent please" mentioned in your question. ;-)_AnShUmAn_
-
You didn't read the documentation of DrawEllipse probably. DrawEllipse - Draws an ellipse defined by a bounding rectangle specified by a pair of coordinates, a height, and a width. So we need to draw the bounding rectangle at the same center coordinates. Right? When I use your code it draws an ellipse starting at the coordinates(left top corner) you provide and with the width and height, and so the circles are not concentric. Anyways I have resolved the problem now. Thanks for your time and effort in helping me.
You need to google first, if you have "It's urgent please" mentioned in your question. ;-)_AnShUmAn_
-
You didn't read the documentation of DrawEllipse probably. DrawEllipse - Draws an ellipse defined by a bounding rectangle specified by a pair of coordinates, a height, and a width. So we need to draw the bounding rectangle at the same center coordinates. Right? When I use your code it draws an ellipse starting at the coordinates(left top corner) you provide and with the width and height, and so the circles are not concentric. Anyways I have resolved the problem now. Thanks for your time and effort in helping me.
You need to google first, if you have "It's urgent please" mentioned in your question. ;-)_AnShUmAn_
Somehow, these look concentric to me.
gx.Clear(this.BackColor);
gx = this.CreateGraphics();
gx.DrawEllipse(Pens.Red, (this.Width / 2 - 25), (this.Height / 2 - 25), 50, 50);
gx.DrawEllipse(Pens.Red, (this.Width / 2 - 50), (this.Height / 2 - 50), 100, 100);
gx.DrawEllipse(Pens.Red, (this.Width / 2 - 75), (this.Height / 2 - 75), 150, 150);
gx.DrawEllipse(Pens.Red, (this.Width / 2 - 100), (this.Height / 2 - 100), 200, 200); -
Somehow, these look concentric to me.
gx.Clear(this.BackColor);
gx = this.CreateGraphics();
gx.DrawEllipse(Pens.Red, (this.Width / 2 - 25), (this.Height / 2 - 25), 50, 50);
gx.DrawEllipse(Pens.Red, (this.Width / 2 - 50), (this.Height / 2 - 50), 100, 100);
gx.DrawEllipse(Pens.Red, (this.Width / 2 - 75), (this.Height / 2 - 75), 150, 150);
gx.DrawEllipse(Pens.Red, (this.Width / 2 - 100), (this.Height / 2 - 100), 200, 200);d@nish wrote:
gx.DrawEllipse(Pens.Red, (this.Width / 2 - 25
aren't you hardcoding the values for the rectangle. you are fixing the centers by subtracting some values based on the radius. isn't it? your circles won't get drawn with the same center when you increase or decrease forms size.
You need to google first, if you have "It's urgent please" mentioned in your question. ;-)_AnShUmAn_
-
d@nish wrote:
gx.DrawEllipse(Pens.Red, (this.Width / 2 - 25
aren't you hardcoding the values for the rectangle. you are fixing the centers by subtracting some values based on the radius. isn't it? your circles won't get drawn with the same center when you increase or decrease forms size.
You need to google first, if you have "It's urgent please" mentioned in your question. ;-)_AnShUmAn_
Only thing I have fixed is the radius of the circles, and that is because this is just some sample code. You need to handle the Resize event for the form as well and only then, no matter how you resize the form, the circles will be drawn with form's center as their center.
-
d@nish wrote:
gx.DrawEllipse(Pens.Red, (this.Width / 2 - 25
aren't you hardcoding the values for the rectangle. you are fixing the centers by subtracting some values based on the radius. isn't it? your circles won't get drawn with the same center when you increase or decrease forms size.
You need to google first, if you have "It's urgent please" mentioned in your question. ;-)_AnShUmAn_
Are you some sort of idiot?! How can you have fixed the problem when you cant even see the simple logic that is shown in the code provided by d@nish? If you put his code is the form's paint event then it will always draw in the centre of the form. And as for saying it only draws one circle - then no f%&^ing $^!t. you want two circles then you use DrawEllipse method two times! Guess how many times you call the method if you want three circles?!? 3 times!!!!!
Life goes very fast. Tomorrow, today is already yesterday.