SetDashStyle 選擇預定義樣式;SetDashPattern 接受 Single 陣列,奇數索引為實線長度,偶數索引為空白長度 (單位:筆寬倍數),長度任意。
p.SetDashStyle(DashStyleDashDot); // -·-·-·
g.DrawLine(p, 11, 33, 333, 33);
const dash: array[0..3] of Single = (5, 2, 15, 10); // 實5 空2 實15 空10 (筆寬倍數)
p.SetDashPattern(@dash, Length(dash));
g.DrawLine(p, 11, 33, 333, 33);
| Delphi | 微軟 | 圖案 |
|---|---|---|
| DashStyleSolid | Solid | 實線 |
| DashStyleDash | Dash | ─ ─ ─ |
| DashStyleDot | Dot | · · · |
| DashStyleDashDot | DashDot | ─ · ─ · |
| DashStyleDashDotDot | DashDotDot | ─ · · ─ · · |
| DashStyleCustom | Custom | 自訂 (需 SetDashPattern) |
虛線畫筆是工程繪圖、地圖標註、圖表圖例、UI 分隔線的標準視覺語言。