wpf 在canvas绘制圆,怎么绘制出的圆不同心,在放大后可以明显看出,求帮助
Canvas_canvas=newCanvas();Ellipseellipse=newEllipse();ellipse.Fill=fillColor;ellipse....
Canvas _canvas = new Canvas();
Ellipse ellipse = new Ellipse();
ellipse.Fill = fillColor;
ellipse.StrokeThickness = lineWidth;
ellipse.Stroke = lineColor;
ellipse.Width = (double)width;
ellipse.Height = (double)height;
//椭圆对象相对于父容器对象Canvas的位置,左边距、上边距
Canvas.SetLeft(ellipse, 0);
Canvas.SetTop(ellipse, 0);
_canvas.Children.Add(ellipse);
ellipse = new Ellipse();//定义椭圆对象
//属性设置,填充颜色、边粗细、边颜色、宽、高等
ellipse.Fill = System.Windows.Media.Brushes.Transparent;
ellipse.StrokeThickness = 1;
ellipse.Stroke = lineColor; //边,金黄色
ellipse.Width = (double)width * 2 / 4;
ellipse.Height = (double)height * 2 / 4;
//椭圆对象相对于父容器对象Canvas的位置,左边距、上边距
Canvas.SetLeft(ellipse, (double)width / 4 );
Canvas.SetTop(ellipse, (double)height / 4 );
_canvas.Children.Add(ellipse);
从代码看明明应该是同心圆啊,谁能帮我改改或者使用其他方法来绘制,要求最后必须是同心圆,不管放大还是缩小不能有偏移 展开
Ellipse ellipse = new Ellipse();
ellipse.Fill = fillColor;
ellipse.StrokeThickness = lineWidth;
ellipse.Stroke = lineColor;
ellipse.Width = (double)width;
ellipse.Height = (double)height;
//椭圆对象相对于父容器对象Canvas的位置,左边距、上边距
Canvas.SetLeft(ellipse, 0);
Canvas.SetTop(ellipse, 0);
_canvas.Children.Add(ellipse);
ellipse = new Ellipse();//定义椭圆对象
//属性设置,填充颜色、边粗细、边颜色、宽、高等
ellipse.Fill = System.Windows.Media.Brushes.Transparent;
ellipse.StrokeThickness = 1;
ellipse.Stroke = lineColor; //边,金黄色
ellipse.Width = (double)width * 2 / 4;
ellipse.Height = (double)height * 2 / 4;
//椭圆对象相对于父容器对象Canvas的位置,左边距、上边距
Canvas.SetLeft(ellipse, (double)width / 4 );
Canvas.SetTop(ellipse, (double)height / 4 );
_canvas.Children.Add(ellipse);
从代码看明明应该是同心圆啊,谁能帮我改改或者使用其他方法来绘制,要求最后必须是同心圆,不管放大还是缩小不能有偏移 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询