1 / 46

第十六章 繪圖

第十六章 繪圖. Image 類別: Image 類別是屬於一種抽象基礎類別,為 Bitmap 及 Metafile 子類別提供存取圖形的功能。. 第十六章 繪圖. Image 類別的屬性:. 第十六章 繪圖. Image 類別的方法:. 第十六章 繪圖. Graphics 類別: 使用圖形的兩個步驟如下: 步驟一、建立 Graphics 物件。 步驟二、使用 Graphics 物件來描繪線條和形狀、呈現文字或顯示和管理影像。. 第十六章 繪圖. Graphics 類別: 使用下列幾種方法來建立圖形物件:

joylyn
Download Presentation

第十六章 繪圖

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 第十六章 繪圖 Image類別: Image類別是屬於一種抽象基礎類別,為Bitmap及Metafile子類別提供存取圖形的功能。

  2. 第十六章 繪圖 Image類別的屬性:

  3. 第十六章 繪圖 Image類別的方法:

  4. 第十六章 繪圖 Graphics類別: 使用圖形的兩個步驟如下: 步驟一、建立Graphics 物件。 步驟二、使用Graphics 物件來描繪線條和形狀、呈現文字或顯示和管理影像。

  5. 第十六章 繪圖 Graphics類別: 使用下列幾種方法來建立圖形物件: 一、在表單或控制項的 Paint 事件中,將圖形物件的參考當作 PaintEventArgs 的一部份接收。 二、藉由呼叫控制項或表單的CreateGraphics方法來取得表示該控制項或表單描繪介面的Graphics物件參考。 三、藉由從繼承自 Image 的任何物件建立Graphics物件。

  6. 第十六章 繪圖 Graphics類別的屬性:

  7. 第十六章 繪圖 Graphics類別的方法:

  8. 第十六章 繪圖 Graphics類別的方法:

  9. 第十六章 繪圖 Graphics類別的方法:

  10. 第十六章 繪圖 Graphics類別的方法:

  11. 第十六章 繪圖 Graphics類別: e.Graphics.DrawLine(blackPen, point1, point2) DrawLine繪製由point1、point2連接而成的黑色直線。 DrawLine語法如下:

  12. 第十六章 繪圖 Graphics類別: e.Graphics.DrawLine(blackPen, point1, point2) DrawLine繪製由point1、point2連接而成的黑色直線。 DrawLine語法如下:

  13. 第十六章 繪圖 Graphics類別: e.Graphics.DrawString("直線", fon, Brushes.Black, 40, 25) DrawString使用Brush和Font物件,將"直線"繪製於40, 25的位置上。 DrawString語法如下:

  14. 第十六章 繪圖 Graphics類別: e.Graphics.DrawLines(blackPen, points) DrawLines繪製Point陣列的一系列直線線段。 DrawLines語法如下:

  15. 第十六章 繪圖 Graphics類別: e.Graphics.DrawArc(bluePen, rect, startAngle, sweepAngle) DrawArc繪製弧形。 DrawArc語法如下:

  16. 第十六章 繪圖 Graphics類別: e.Graphics.DrawRectangle(bluePen, rect1) DrawRectangle繪製一個矩形。 DrawRectangle語法如下:

  17. 第十六章 繪圖 Graphics類別: e.Graphics.DrawEllipse(redPen, rect1) DrawEllipse繪製橢圓形。 DrawEllipse語法如下:

  18. 第十六章 繪圖 Graphics類別: e.Graphics.FillRectangle(Brushes.Red, rect2) FillRectangle繪製一個填滿顏色的矩形。 FillRectangle語法如下:

  19. 第十六章 繪圖 Graphics類別: e.Graphics.FillEllipse(Brushes.Green, rect3) FillEllipse填滿橢圓形內部。 FillEllipse語法如下:

  20. 第十六章 繪圖 Graphics類別: e.Graphics.DrawCurve(redPen, curvePoints) DrawCurve繪製曲線。 DrawCurve語法如下:

  21. 第十六章 繪圖 Graphics類別: e.Graphics.DrawClosedCurve(New Pen(Color.Green), curvePoints) DrawClosedCurve繪製封閉的曲線。 DrawClosedCurve語法如下:

  22. 第十六章 繪圖 Graphics類別: e.Graphics.DrawPie(blackPen, rect1, startAngle, sweepAngle) DrawPie繪製派形圖形。 DrawPie語法如下:

  23. 第十六章 繪圖 Graphics類別: e.Graphics.FillPie(redBrush, rect2, startAngle, sweepAngle) FillPie繪製填滿派形圖形。 FillPie語法如下:

  24. 第十六章 繪圖 Pen類別: Pen類別用來描繪線條、繪製形狀或是呈現其他的幾何圖形。 Pen類別的Width屬性和Color屬性會影響線條的外觀。

  25. 第十六章 繪圖 Pen類別的屬性:

  26. 第十六章 繪圖 Pen類別的屬性:

  27. 第十六章 繪圖 Pen類別的方法:

  28. 第十六章 繪圖 Pen類別: redPen.StartCap = Drawing2D.LineCap.RoundAnchor StartCap用於設定直線開端帽緣樣式。 LineCap列舉型態成員如下:

  29. 第十六章 繪圖 Brush類別: Brush類別用來填滿圖形的區域、例如實心形狀、影像或文字。 筆刷有下列幾種不同的類型:

  30. 第十六章 繪圖 Brush類別: SolidBrush筆刷 Dim slbBrush As New SolidBrush(Color.Silver) 宣告slbBrush為SolidBrush筆刷,且為銀色。

  31. 第十六章 繪圖 Brush類別: TextureBrush物件 Dim txtBrush As New TextureBrush(img) 宣告txtBrush一個TextureBrush物件,在封閉幾何圖形中填入img圖像。

  32. 第十六章 繪圖 Brush類別: HatchBrush物件 HatchBrush有三個參數:HatchStyle(htStyle)、前景顏色(Color.White)及背景顏色(Color.Black)。其語法如下:

  33. 第十六章 繪圖 Brush類別: LinearGradientBrush物件 LinearGradientBrush繪製線性漸層雙色的線條。其語法如下:

  34. 第十六章 繪圖 Brush類別: PathGradientBrush物件 PathGradientBrush根據定義的路徑,使用漸層進行內部填滿顏色繪製圖形。

  35. 第十六章 繪圖 Color結構: Color結構是用來表示不同的ARGB顏色。Color是與畫筆和筆刷一起用來指定要呈現的色彩。

  36. 第十六章 繪圖 Color結構: ARGB顏色代表Alpha、Red、Green及Blue;Alpha用來產生各種陰影與透明度的圖形。通常,Alpha用於Color.FromArgb 方法中四個引數的第一個,而且必須是介於 0 至 255 之間的整數。

  37. 第十六章 繪圖 Color結構的方法:

  38. 第十六章 繪圖 Color結構的方法: FromArgb方法有下列幾種語法:

  39. 第十六章 繪圖 Color結構的方法: FromArgb方法有下列幾種語法:

  40. 第十六章 繪圖 Color結構的方法: FromArgb方法有下列幾種語法:

  41. 第十六章 繪圖 Color結構的方法: FromArgb方法有下列幾種語法:

  42. 第十六章 繪圖 Font類別: Font類別用來設定字型的字體、樣式、大小及顏色。

  43. 第十六章 繪圖 Font類別的屬性:

  44. 第十六章 繪圖 Font類別的方法:

  45. 第十六章 繪圖 Font類別: 使用Font建構式來執行Label元件上字型的設定。Font的建構式語法如下:

  46. 第十六章 繪圖 Font類別: FontFamily的屬性有Families、GenericMonospace、GenericSansSerif、GenericSerif、Name五種。

More Related