Click here to Skip to main content
15,894,343 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Consider this code:
Ellipse myCircle = new Ellipse();
myCircle.Width = 400;
myCircle.Height = 400;
myCircle.Stroke = Brushes.PeachPuff;
myCircle.StrokeThickness = 25;
myCircle.ToolTip = "Bold Circle";
Canvas.SetTop(myCircle, 0);
Canvas.SetLeft(myCircle, 0);
canvas.Children.Add(myCircle);

Ellipse myCircle2 = new Ellipse();
myCircle2.Width = 400;
myCircle2.Height = 400;
myCircle2.Stroke = Brushes.Black;
myCircle2.StrokeThickness = 1;
Canvas.SetTop(myCircle2, 0);
Canvas.SetLeft(myCircle2, 0);
canvas.Children.Add(myCircle2);

I see that myCircle2 lying at the edge of myCircle.
How can I define the stroke style of myCircle such that myCircle2 will lie in the middle of myCircle ?

Thanks !
Posted

1 solution

Simple math. The thickness is 25. So, the middle of the thickness is about 13. So, add 12 or 13 to the location of the thinner circle, to offset it into the thicker one. If your thinner thickness was more than 1, you would take half of that thickness, and subtract it from the offset.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900