Bokeh-specialized-curves

提供:Dev Guides
移動先:案内検索

ボケ-特殊な曲線

*bokeh.plotting* APIは、特殊な曲線に従ってレンダリングするためのメソッドをサポートしています-

beizer()

このメソッドは、Figureオブジェクトにベジェ曲線を追加します。 ベジエ曲線は、コンピュータグラフィックスで使用されるパラメトリック曲線です。 その他の用途には、コンピューターフォントとアニメーションのデザイン、ユーザーインターフェイスのデザイン、カーソルの軌跡の平滑化などがあります。

ベクトルグラフィックスでは、ベジエ曲線を使用して、無制限にスケーリングできる滑らかな曲線をモデル化します。 「パス」は、リンクされたベジエ曲線の組み合わせです。

beizer()メソッドには、定義されている次のパラメータがあります-

1 x0 The x-coordinates of the starting points.
2 y0 The y-coordinates of the starting points..
3 x1 The x-coordinates of the ending points.
4 y1 The y-coordinates of the ending points.
5 cx0 The x-coordinates of first control points.
6 cy0 The y-coordinates of first control points.
7 cx1 The x-coordinates of second control points.
8 cy1 The y-coordinates of second control points.

すべてのパラメーターのデフォルト値はNoneです。

次のコードは、ボケプロットにベジエ曲線と放物線を示すHTMLページを生成します-

x = 2
y = 4
xp02 = x+0.4
xp01 = x+0.1
xm01 = x-0.1
yp01 = y+0.2
ym01 = y-0.2
fig = figure(plot_width = 300, plot_height = 300)
fig.bezier(x0 = x, y0 = y, x1 = xp02, y1 = y, cx0 = xp01, cy0 = yp01,
cx1 = xm01, cy1 = ym01, line_color = "red", line_width = 2)

出力

beizer

quadratic()

このメソッドは、放物線グリフ*をボケの図に追加します。 この関数のパラメーターは、 *cx0cx1 を除いてbeizer()と同じです。

以下のコードは、2次曲線を生成します。

x = 2
y = 4
xp02 = x + 0.3
xp01 = x + 0.2
xm01 = x - 0.4
yp01 = y + 0.1
ym01 = y - 0.2
x = x,
y = y,
xp02 = x + 0.4,
xp01 = x + 0.1,
yp01 = y + 0.2,
fig.quadratic(x0 = x, y0 = y, x1 = x + 0.4, y1 = y + 0.01, cx = x + 0.1,
cy = y + 0.2, line_color = "blue", line_width = 3)

出力

quadratic