如何在 Windows 窗体中制作 Triangle 对象?
我想绘制/制作一个三角形图形,该图形将在运行程序后立即出现,但我无法找出正确的命令。这是我用来制作矩形对象的命令。
private void Form1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.FillRectangle(Brushes.Aquamarine, _x, _y, 100, 100);
}
因此,当我制作对象时,我将使其自动移动。
我搜索过教程但找不到任何合适的。请帮忙。
I want to draw/make a triangle graphic that will appear right after when I run the program but I can't figure out the right command. Here's the command I use to make a rectangle object.
private void Form1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.FillRectangle(Brushes.Aquamarine, _x, _y, 100, 100);
}
So when I make the object, I'll make it move automatically.
I've searched for tutorials but couldn't find anything suitable. Please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(2)
不及他2025-01-23 19:33:14
有 DrawPolygon
可能可以满足您的要求,您只需要指定三角形的三个顶点即可。
编辑: FillPolygon
可能更符合您的需要,抱歉。
~没有更多了~
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
您可以使用
FillPolygon
并指定3个三角形点。或者您可以创建一个
FillTriangle
扩展方法并像这样调用
对于直角三角形使用此
对于钝角此
此代码将输出此
You can use
FillPolygon
and specify 3 triangle points.Or you can create a
FillTriangle
extension methodAnd call like this
For right triangle use this
For obtuse this
This code will output this