我正在寻找一种在 C# Canvas 上绘制单个点(带有颜色)的方法。 在android中我会做类似的事情
paint.Color = Color.Rgb (10, 10, 10);
canvas.DrawPoint (x, y, paint);
所以我想我可以在 Shape class 中找到它, 但它不在那里。我是不是遗漏了什么或者没有办法画出一个点?
在第二种情况下,推荐的画点方式是什么?在 HTML5 canvas 中存在类似的问题,人们使用 rectangles/circles 绘制点。 .
P.S. 一个类似标题的问题 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);
关于c# - 在 Canvas 上绘制单个点的有效方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19850291/