在canvas上绘制单个点的有效方法
我正在寻找一种在C#canvas上绘制单点(带颜色)的方法。 在android中我会做类似的事情
paint.Color = Color.Rgb (10, 10, 10); canvas.DrawPoint (x, y, paint);
所以我认为我可以在Shape类中找到它,但它不存在。 我错过了什么或者没有办法画出一点吗?
在第二种情况下,推荐的绘制点的方法是什么? 在HTML5canvas中存在类似的问题,人们使用矩形/圆形绘制点。
PS一个类似标题的问题Add Point to Canvas没有回答它并进入“如何绘制形状”。
我刚刚为UWP运行了同样的问题,我最终决定使用Ellipse:
int dotSize = 10; Ellipse currentDot = new Ellipse(); currentDot.Stroke = new SolidColorBrush(Colors.Green); currentDot.StrokeThickness = 3; Canvas.SetZIndex(currentDot, 3); currentDot.Height = dotSize; currentDot.Width = dotSize; currentDot.Fill = new SolidColorBrush(Colors.Green); currentDot.Margin = new Thickness(100, 200, 0, 0); // Sets the position. myGrid.Children.Add(currentDot);
折线怎么样?
XAML:
C#:
上述就是C#学习教程:在canvas上绘制单个点的有效方法分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—猴子技术宅(www.ssfiction.com)
private void ButtonBase_OnClick(object sender, RoutedEventArgs e) { polyline.Points.Add(new Point(0,0)); polyline.Points.Add(new Point(0, 1)); polyline.Points.Add(new Point(1, 0)); polyline.Points.Add(new Point(1, 1)); }
本文来自网络收集,不代表猴子技术宅立场,如涉及侵权请点击右边联系管理员删除。
如若转载,请注明出处:https://www.ssfiction.com/ckf/1301189.html