如何改变笔触样式? [英] How to change the stroke style ?

查看:110
本文介绍了如何改变笔触样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



考虑以下代码:

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);


我看到myCircle2位于myCircle的边缘.
如何定义myCircle的笔触样式,以使myCircle2位于myCircle 的中间?

谢谢!


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 !

推荐答案

简单的数学.厚度为25.因此,厚度的中间大约为13.因此,将12或13添加到较细圆的位置,以使其偏移到较粗的圆中.如果您的较薄厚度大于1,则将厚度的一半减去偏移量.
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.


这篇关于如何改变笔触样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆