2011-10-01 3 views
0

저는 C++을 처음 사용합니다. 저는 Visual Studio Professional 2010을 사용하고 있습니다. 선을 그리는 법을 배웠으나 이번에는 채워진 다각형을 그릴 필요가 있습니다. 내가 그리는 방법은 아래와 같습니다 :C++을 사용하여 채워진 다각형을 그리는 방법은 무엇입니까?

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);} 

채워진 다각형을 지금까지 배운 것과 비슷한 기술을 사용하여 어떻게 그릴 수 있습니까?

+1

그 C주의 ++ 및 C++/CLI는 그것이 무엇을 할 수 있는지 알아내는 "그래픽"F1을 눌러 캐럿을 넣어 같은 언어 – Zharf

+0

하지 않습니다하세요 . –

답변

1

Graphics.FillPolygon()으로 전화하십시오. 펜이 아닌 브러시가 필요하며 점 배열을 Point[]에 넣어야합니다.

MSDN에서 샘플 코드는 다음과 같다 :

// Create solid brush. 
SolidBrush^ blueBrush = gcnew SolidBrush(Color::Blue); 

// Create points that define polygon. 
Point point1 = Point(50,50); 
Point point2 = Point(100,25); 
Point point3 = Point(200,5); 
Point point4 = Point(250,50); 
Point point5 = Point(300,100); 
Point point6 = Point(350,200); 
Point point7 = Point(250,250); 
array<Point>^ curvePoints = {point1,point2,point3,point4,point5,point6,point7}; 

// Draw polygon to screen. 
e->Graphics->FillPolygon(blueBrush, curvePoints); 
관련 문제