public: void DrawRectangle(Pen *pen, Rectangle rect); |
![]() 圖一、長方形說明圖示 |
private: System::Void Form1_Paint(System::Object * sender, System::Windows::Forms::PaintEventArgs * e) { Pen *penCurrent = new Pen(Color::Red); Rectangle Rect(20, 20, 248, 162); e->Graphics->DrawRectangle(penCurrent, Rect); } |
private: System::Void Form1_Paint(System::Object * sender, System::Windows::Forms::PaintEventArgs * e) { e->Graphics->DrawRectangle(new Pen(Color::Red), Rectangle(20, 20, 248, 162)); } |
![]() 圖二、繪制的長方形效果圖 |
public: void DrawRectangle(Pen *pen, int x, int y, int width, int height); public: void DrawRectangle(Pen *pen, float x, float y, float width, float height); |
![]() 圖三、Windows坐標系統 |
private: System::Void Form1_Paint(System::Object * sender, System::Windows::Forms::PaintEventArgs * e) { e->Graphics->DrawRectangle(new Pen(Color::Red), 20, 20, 248, 162); } |
public: void DrawRectangles(Pen *pen, Rectangle rects[]); public: void DrawRectangles(Pen *pen, RectangleF rects[]); |
private: System::Void Form1_Paint(System::Object * sender, System::Windows::Forms::PaintEventArgs * e) { Pen *penCurrent = new Pen(Color::Red); Rectangle Rect[] = { Rectangle(20, 20, 120, 20), Rectangle(20, 50, 120, 30), Rectangle(20, 90, 120, 40), Rectangle(20, 140, 120, 60) }; e->Graphics->DrawRectangles(penCurrent, Rect); } |
![]() 圖四、一系列長方形效果圖 |
![]() 圖五、直線示意圖 |
public: void DrawLine(Pen *pen, Point pt1, Point pt2); public: void DrawLine(Pen *pen, PointF pt1, PointF pt2); public: void DrawLine(Pen *pen, int x1, int y1, int x2, int y2); public: void DrawLine(Pen *pen, float x1, float y1, float x2, float y2); |
private: System::Void Form1_Paint(System::Object * sender, System::Windows::Forms::PaintEventArgs * e) { Pen *penCurrent = new Pen(Color::Red); e->Graphics->DrawLine(penCurrent, 20, 20, 205, 20); penCurrent = new Pen(Color::Green); e->Graphics->DrawLine(penCurrent, 40, 40, 225, 40); penCurrent = new Pen(Color::Blue); e->Graphics->DrawLine(penCurrent, 30, 60, 215, 60); } |
![]() 圖六:繪制三條直線 |
public: void DrawLines(Pen *pen, Point points[]); public: void DrawLines(Pen *pen, PointF points[]); |
private: System::Void Form1_Paint(System::Object * sender, System::Windows::Forms::PaintEventArgs * e) { Point Coordinates[] = { Point(20, 10), Point(205, 20), Point(40, 40), Point(225, 60), Point(30, 80), Point(215, 100) }; Pen *penCurrent = new Pen(Color::Red); e->Graphics->DrawLines(penCurrent, Coordinates); } |
![]() 圖七、系列直線效果圖 |
public: void DrawPolygon(Pen *pen, Point points[]); public: void DrawPolygon(Pen *pen, PointF points[]); |
private: System::Void Form1_Paint(System::Object * sender, System::Windows::Forms::PaintEventArgs * e) { Point Pt[] = { Point(20, 50), Point(180, 50), Point(180, 20), Point(230, 70), Point(180, 120), Point(180, 90), Point(20, 90) }; Pen *penCurrent = new Pen(Color::Red); e->Graphics->DrawPolygon(penCurrent, Pt); } |
![]() 圖八、多邊形效果圖 |
![]() 圖九、橢圓示意圖 |
public: void DrawEllipse(Pen *pen, Rectangle rect); public: void DrawEllipse(Pen *pen, RectangleF rect); public: void DrawEllipse(Pen *pen, int x, int y, int width, int height); public: void DrawEllipse(Pen *pen, float x, float y, float width, float height); |
![]() 圖十、函數參數示意圖 |
private: System::Void Form1_Paint(System::Object * sender, System::Windows::Forms::PaintEventArgs * e) { Pen *penCurrent = new Pen(Color::Red); e->Graphics->DrawEllipse(penCurrent, Rectangle(20, 20, 226, 144)); } |
![]() 圖十一、代碼運行效果圖 |
![]() 圖十二、餅圖示意圖 |
public: void DrawPie(Pen *pen, Rectangle rect,float startAngle,float sweepAngle); public: void DrawPie(Pen *pen, RectangleF rect, float startAngle,float sweepAngle); public: void DrawPie(Pen *pen,int x,int y,int width,int height, int startAngle, int sweepAngle); public: void DrawPie(Pen *pen, float x, float y, float width, float height, float startAngle, float sweepAngle); |
private: System::Void Form1_Paint(System::Object * sender, System::Windows::Forms::PaintEventArgs * e) { Pen *penCurrent = new Pen(Color::Red); e->Graphics->DrawPie(penCurrent, 20, 20, 200, 100, 45, 255); } |
![]() 圖十三、餅圖效果 |
![]() 圖十四、弧線示意圖 |
public: void DrawArc(Pen *pen, Rectangle rect, float startAngle, float sweepAngle); public: void DrawArc(Pen *pen, RectangleF rect, float startAngle, float sweepAngle); public: void DrawArc(Pen *pen, int x, int y, int width, int height, int startAngle, int sweepAngle); public: void DrawArc(Pen *pen, float x, float y, float width, float height, float startAngle, float sweepAngle); |
private: System::Void Form1_Paint(System::Object * sender, System::Windows::Forms::PaintEventArgs * e) { Pen *penCurrent = new Pen(Color::Red); e->Graphics->DrawArc(penCurrent, 20, 20, 200, 150, 225, 200); } |
![]() 圖十五、程序效果圖 |
![]() 圖十六、曲線示意圖 |
public: void DrawCurve(Pen *pen, Point points[]); public: void DrawCurve(Pen *pen, PointF points[]); |
private: System::Void Form1_Paint(System::Object * sender, System::Windows::Forms::PaintEventArgs * e) { Pen *penCurrent = new Pen(Color::Blue); Point pt[] = { Point( 40, 42), Point(188, 246), Point(484, 192), Point(350, 48) }; e->Graphics->DrawCurve(penCurrent, pt); } |
![]() 圖十七、曲線效果圖 |
public: void DrawCurve(Pen *pen, Point points[], float tension); public: void DrawCurve(Pen *pen, PointF points[], float tension); |
private: System::Void Form1_Paint(System::Object * sender, System::Windows::Forms::PaintEventArgs * e) { Pen *penCurrent = new Pen(Color::Blue); Point pt[] = { Point(40, 42), Point(188, 246),Point(484, 192), Point(350, 48) }; e->Graphics->DrawCurve(penCurrent, pt, 0.00F); } |
![]() 圖十八、代碼運行效果圖 |
private: System::Void Form1_Paint(System::Object * sender, System::Windows::Forms::PaintEventArgs * e) { Pen *penCurrent = new Pen(Color::Blue); Point pt[] = { Point(40, 42), Point(188, 246),Point(484, 192), Point(350, 48) }; e->Graphics->DrawCurve(penCurrent, pt, 2.15F); } |
![]() 圖十九、代碼運行效果圖 |
private: System::Void Form1_Paint(System::Object * sender, System::Windows::Forms::PaintEventArgs * e) { Pen *penCurrent = new Pen(Color::Blue); PointF pt[] = { PointF(20.00F, 322.00F), PointF(124, 24),PointF(214, 242), PointF(275, 28), PointF(380.00F, 322.00F) }; e->Graphics->DrawCurve(penCurrent, pt); } |
![]() 圖二十、代碼運行效果圖 |
public: void DrawCurve(Pen *pen, PointF[] points, int offset, int numberOfSegments); |
private: System::Void Form1_Paint(System::Object * sender, System::Windows::Forms::PaintEventArgs * e) { Pen *penCurrent = new Pen(Color::Blue); PointF pt[] = { PointF(20.00F, 322.00F), PointF(124, 24),PointF(214, 242), PointF(275, 28), PointF(380.00F, 322.00F) }; e->Graphics->DrawCurve(penCurrent, pt, 1, 2); } |
![]() 圖二十一、代碼運行效果圖 |
public: void DrawCurve(Pen *pen, Point[] points, int offset, int numberOfSegments, float tension); public: void DrawCurve(Pen *pen, PointF[] points, int offset, int numberOfSegments, float tension); |
private: System::Void Form1_Paint(System::Object * sender, System::Windows::Forms::PaintEventArgs * e) { Pen *penCurrent = new Pen(Color::Blue); PointF pt[] = { PointF(20.00F, 322.00F), PointF(124, 24),PointF(214, 242), PointF(275, 28),PointF(380.00F, 322.00F) }; e->Graphics->DrawCurve(penCurrent, pt, 0, 4, 0); } |
![]() 圖二十二、代碼運行效果圖 |
private: System::Void Form1_Paint(System::Object * sender, System::Windows::Forms::PaintEventArgs * e) { Pen *penCurrent = new Pen(Color::Blue); PointF pt[] = { PointF(20.00F, 322.00F), PointF(124, 24), PointF(214, 242), PointF(275, 28), PointF(380.00F, 322.00F) }; e->Graphics->DrawCurve(penCurrent, pt, 1, 3, 1.750F); } |
![]() 圖二十三、代碼運行效果圖 |
![]() 圖二十四、貝賽爾曲線 |
![]() 圖二十五、貝賽爾曲線繪制說明圖 |
public: void DrawBezier(Pen *pen, Point pt1, Point pt2, Point pt3, Point pt4); public: void DrawBezier(Pen *pen, PointF pt1, PointF pt2, PointF pt3, PointF pt4); public: void DrawBezier(Pen *pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4); |
private: System::Void Form1_Paint(System::Object * sender, System::Windows::Forms::PaintEventArgs * e) { Pen *penCurrent = new Pen(Color::Blue); Point pt1 = Point(20, 12), pt2 = Point(88, 246), pt3 = Point(364, 192), pt4 = Point(250, 48); e->Graphics->DrawBezier(penCurrent, pt1, pt2, pt3, pt4); } |
![]() 圖二十六、貝賽爾曲線效果圖 |
public: void DrawBeziers(Pen *pen, Point points[]); public: void DrawBeziers(Pen *pen, PointF points[]); |
private: System::Void Form1_Paint(System::Object * sender, System::Windows::Forms::PaintEventArgs * e) { Pen *penCurrent = new Pen(Color::Blue); Point pt[] = { Point(20, 12), Point(88, 246), Point(364, 192), Point(250, 48) }; e->Graphics->DrawBeziers(penCurrent, pt); } |
private: System::Void Form1_Paint(System::Object * sender, System::Windows::Forms::PaintEventArgs * e) { Pen *penCurrent = new Pen(Color::Blue); Point pt[] = { Point( 10, 5), Point(340, 60), Point(320, 148), Point(150, 120), Point(24, 220), Point(250, 150), Point(304, 240) }; e->Graphics->DrawBeziers(penCurrent, pt); } |
![]() 圖二十七、代碼運行效果圖 |
public: void DrawClosedCurve(Pen *pen, Point points[]); public: void DrawClosedCurve(Pen *pen, PointF points[]); |
private: System::Void Form1_Paint(System::Object * sender, System::Windows::Forms::PaintEventArgs * e) { Pen *penCurrent = new Pen(Color::Blue); Point pt[] = { Point(40, 42), Point(188, 246), Point(484, 192), Point(350, 48) }; e->Graphics->DrawClosedCurve(penCurrent, pt); } |
![]() 圖二十八、代碼運行效果圖 |
![]() 圖二十九、直線連接的封閉圖形 |
public: void DrawClosedCurve(Pen *pen, Point points[], float tension, FillMode fillmode); public: void DrawClosedCurve(Pen *pen, PointF points[], float tension, FillMode fillmode); |
private: System::Void Form1_Paint(System::Object * sender, System::Windows::Forms::PaintEventArgs * e) { using namespace System::Drawing::Drawing2D; Pen *penCurrent = new Pen(Color::Red); Point pt[] = { Point(40, 42), Point(188, 246), Point(484, 192), Point(350, 48) }; e->Graphics->DrawClosedCurve(penCurrent, pt, 0.75F, FillMode::Winding); } |
![]() 圖三十、代碼運行效果圖 |