如何使用c++绘制填充多边形?
我是 C++ 新手。我使用的是Visual studio Professional 2010。我学会了画线,但是这次我需要画填充多边形。我绘制线条的方式如下:
private: System::Void Form1_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e) {
Graphics ^g = e->Graphics; //require for drawing
g->DrawArc(Pens::Black, i-the_size/2, j-the_size/2, the_size, the_size, 0, 90 );
g->DrawArc(Pens::Black, i+the_size/2, j+the_size/2, the_size, the_size, 180, 90 );}
如何使用与我迄今为止学到的类似的技术绘制填充多边形?
I'm new to C++. I am using Visual studio Professional 2010. I learned to draw lines, but I need to draw filled polygon this time. The way that I drew lines is below:
private: System::Void Form1_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e) {
Graphics ^g = e->Graphics; //require for drawing
g->DrawArc(Pens::Black, i-the_size/2, j-the_size/2, the_size, the_size, 0, 90 );
g->DrawArc(Pens::Black, i+the_size/2, j+the_size/2, the_size, the_size, 180, 90 );}
How can I draw filled polygons using techniques similar to what I have learned so far?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
调用
Graphics.FillPolygon()
。您将需要画笔而不是笔,并且必须将点放入点数组Point[]
中。来自MSDN的示例代码是这样的:
Call
Graphics.FillPolygon()
. You will need a brush rather than a pen and you must put your points into a point arrayPoint[]
.The sample code from MSDN is like this: