共用方式為


繪製基數曲線

基數曲線是一種曲線,可順暢地通過一組指定的點。 若要繪製基數曲線,請建立 Graphics 物件,並將點陣列的位址傳遞至 Graphics::D rawCurve 方法。 下列範例會繪製通過五個指定點的鐘形基數曲線:

Point points[] = {Point(0, 100),
                  Point(50, 80),
                  Point(100, 20),
                  Point(150, 80),
                  Point(200, 100)};

Pen pen(Color(255, 0, 0, 255));
graphics.DrawCurve(&pen, points, 5);

下圖顯示曲線和五點。

通過一組五點的基數曲線圖例

您可以使用Graphics 類別的 Graphics::D rawClosedCurve方法,繪製封閉的基數曲線。 在封閉的基數曲線中,曲線會繼續到陣列的最後一個點,並與陣列中的第一個點連接。

下列範例會繪製通過六個指定點的封閉基數曲線。

Point points[] = {Point(60, 60),
   Point(150, 80),
   Point(200, 40),
   Point(180, 120),
   Point(120, 100),
   Point(80, 160)};

Pen pen(Color(255, 0, 0, 255));
graphics.DrawClosedCurve(&pen, points, 6);

下圖顯示封閉曲線以及六點:

通過一組六點的封閉基數曲線圖例

您可以將基數曲線彎曲的方式變更為將:D rawCurve 方法的引數傳遞至 Graphics::D rawCurve 方法。 下列範例會繪製三個通過相同點集的基數曲線:

Point points[] = {Point(20, 50),
                  Point(100, 10),
                  Point(200, 100),
                  Point(300, 50),
                  Point(400, 80)};

Pen pen(Color(255, 0, 0, 255));
graphics.DrawCurve(&pen, points, 5, 0.0f);  // tension 0.0
graphics.DrawCurve(&pen, points, 5, 0.6f);  // tension 0.6
graphics.DrawCurve(&pen, points, 5, 1.0f);  // tension 1.0

下圖顯示三個曲線及其鬆開值。 請注意,當壓力為 0 時,點會以直線連接。

三個基數曲線的圖例,這些曲線會通過相同的點集,但在不同口處