Class: Graphics

Graphics

Graphics クラスには、ベクターシェイプの作成に使用できる一連のメソッドがあります。
描画をサポートする表示オブジェクトには、Sprite および Shape オブジェクトがあります。
これらの各クラスには、Graphics オブジェクトである graphics プロパティがあります。
以下は、簡単に使用できるように用意されているヘルパー関数の一例です。
drawRect()、drawRoundRect()、drawCircle()、および drawEllipse()。

The Graphics class contains a set of methods that you can use to create a vector shape.
Display objects that support drawing include Sprite and Shape objects.
Each of these classes includes a graphics property that is a Graphics object.
The following are among those helper functions provided for ease of use:
drawRect(), drawRoundRect(), drawCircle(), and drawEllipse().

new next2d.display.Graphics (src)

NameTypeDefaultDescription
srcDisplayObjectnull

Members

next2d.display.Graphics.namespace staticconstant

指定されたクラスの空間名を返します。
Returns the space name of the specified class.

Default Value:
  • next2d.display.Bitmap

namespace constant

指定されたオブジェクトの空間名を返します。
Returns the space name of the specified object.

Default Value:
  • next2d.display.Graphics

Methods

next2d.display.Graphics.toString ()string static

指定されたクラスのストリングを返します。
Returns the string representation of the specified class.

Default Value:
  • [class Graphics]
Returns:
TypeDescription
string

beginBitmapFill (bitmap_data, matrix, repeat, smooth)Graphics

描画領域をビットマップイメージで塗りつぶします。
Fills a drawing area with a bitmap image.

NameTypeDefaultDescription
bitmap_dataBitmapData
matrixMatrixnulloptional
repeatbooleantrueoptional
smoothbooleanfalseoptional
Returns:
TypeDescription
Graphics

beginFill (color, alpha)Graphics

描画のときに他の Graphics メソッド(lineTo() や drawCircle() など)
に対する今後の呼び出しに使用する単純な一色塗りを指定します。
Specifies a simple one-color fill that subsequent calls
to other Graphics methods (such as lineTo() or drawCircle()) use when drawing.

NameTypeDefaultDescription
colorstring | number0optional
alphanumber1.0optional
Returns:
TypeDescription
Graphics

beginGradientFill (type, colors, alphas, ratios, matrix, spread_method, interpolation_method, focal_point_ratio)Graphics

Graphics の他のメソッド(lineTo()、drawCircle() など)に対する、
オブジェクトの後続の呼び出しに使用するグラデーション塗りを指定します。
Specifies a gradient fill used by subsequent calls
to other Graphics methods (such as lineTo() or drawCircle()) for the object.

NameTypeDefaultDescription
typestring
colorsarray
alphasarray
ratiosarray
matrixMatrixnulloptional
spread_methodstringSpreadMethod.PADoptional
interpolation_methodstringInterpolationMethod.RGBoptional
focal_point_rationumber0optional
Returns:
TypeDescription
Graphics

clear ()Graphics

この Graphics オブジェクトに描画されているグラフィックをクリアし、
塗りと線のスタイルの設定をリセットします。
Clears the graphics that were drawn to this Graphics object,
and resets fill and line style settings.

Returns:
TypeDescription
Graphics

clone ()Graphics

すべての描画コマンドをソース Graphics オブジェクトから、呼び出し Graphics オブジェクトにコピーします。
Copies all of drawing commands from the source Graphics object into the calling Graphics object.

Returns:
TypeDescription
Graphics

copyFrom (graphics)void

すべての描画コマンドをソース Graphics オブジェクトから、呼び出し Graphics オブジェクトにコピーします。
Copies all of drawing commands from the source Graphics object into the calling Graphics object.

NameTypeDescription
graphicsGraphics
Returns:
TypeDescription
void

cubicCurveTo (control_x1, control_y1, control_x2, control_y2, anchor_x, anchor_y)Graphics

現在の描画位置から指定されたアンカーポイントに 3 次ベジェ曲線を描画します。
Draws a cubic Bezier curve from the current drawing position to the specified anchor point.

NameTypeDescription
control_x1number
control_y1number
control_x2number
control_y2number
anchor_xnumber
anchor_ynumber
Returns:
TypeDescription
Graphics

curveTo (control_x, control_y, anchor_x, anchor_y)Graphics

(controlX, controlY) で指定されたコントロールポイントを使用し、
現在の描画位置から (anchorX, anchorY) まで、現在の線のスタイルで 2 次ベジェ曲線を描画します。
Draws a quadratic Bezier curve using the current line style from
the current drawing position to (anchorX, anchorY)
and using the control point that (controlX, controlY) specifies.

NameTypeDescription
control_xnumber
control_ynumber
anchor_xnumber
anchor_ynumber
Returns:
TypeDescription
Graphics

drawCircle (x, y, radius)Graphics

円を描画します。
Draws a circle.

NameTypeDescription
xnumber
ynumber
radiusnumber
Returns:
TypeDescription
Graphics

drawEllipse (x, y, width, height)Graphics

楕円を描画します。
Draws an ellipse.

NameTypeDescription
xnumber
ynumber
widthnumber
heightnumber
Returns:
TypeDescription
Graphics

drawRect (x, y, width, height)Graphics

矩形を描画します。
Draws a rectangle.

NameTypeDescription
xnumber
ynumber
widthnumber
heightnumber
Returns:
TypeDescription
Graphics

drawRoundRect (x, y, width, height, ellipse_width, ellipse_height)Graphics

角丸矩形を描画します。
Draws a rounded rectangle.

NameTypeDefaultDescription
xnumber
ynumber
widthnumber
heightnumber
ellipse_widthnumber
ellipse_heightnumberNaNoptional
Returns:
TypeDescription
Graphics

endFill ()Graphics

beginFill()、beginGradientFill()、または beginBitmapFill() メソッドへの
最後の呼び出し以降に追加された線と曲線に塗りを適用します。
Applies a fill to the lines and curves that were added since
the last call to the beginFill(), beginGradientFill(),
or beginBitmapFill() method.

Returns:
TypeDescription
Graphics

endLine ()Graphics

lineStyle()、または lineGradientStyle() メソッドへの
最後の呼び出し以降に追加された線と曲線に塗りを適用します。
Applies a fill to the lines and curves that were added since
the last call to the beginFill() or beginGradientFill() method.

Returns:
TypeDescription
Graphics

lineBitmapStyle (bitmap_data, matrix, repeat, smooth)Graphics

線の描画で、線として使用するビットマップを指定します。
Specifies a bitmap to use for the line stroke when drawing lines.

NameTypeDefaultDescription
bitmap_dataBitmapData
matrixMatrixnulloptional
repeatbooleantrueoptional
smoothbooleanfalseoptional
Returns:
TypeDescription
Graphics

lineGradientStyle (type, colors, alphas, ratios, matrix, spread_method, interpolation_method, focal_point_ratio)Graphics

線の描画で使用するグラデーションを指定します。
Specifies a gradient to use for the stroke when drawing lines.

NameTypeDefaultDescription
typestring
colorsarray
alphasarray
ratiosarray
matrixMatrixnulloptional
spread_methodstringSpreadMethod.PADoptional
interpolation_methodstringInterpolationMethod.RGBoptional
focal_point_rationumber0optional
Returns:
TypeDescription
Graphics

lineStyle (thickness, color, alpha, caps, joints, miter_limit)Graphics

lineTo() メソッドや drawCircle() メソッドなど、
Graphics のメソッドの後続の呼び出しに使用する線スタイルを指定します。
Specifies a line style used for subsequent calls
to Graphics methods such as the lineTo() method
or the drawCircle() method.

NameTypeDefaultDescription
thicknessnumberNaNoptional
colornumber | string0optional
alphanumber1optional
capsstringCapsStyle.NONEoptional
jointsstringJointStyle.ROUNDoptional
miter_limitnumber3optional
Returns:
TypeDescription
Graphics

lineTo (x, y)Graphics

現在の描画位置から (x, y) まで、現在の線のスタイルを使用して線を描画します。
その後で、現在の描画位置は (x, y) に設定されます。
Draws a line using the current line style from the current drawing position to (x, y);
the current drawing position is then set to (x, y).

NameTypeDescription
xnumber
ynumber
Returns:
TypeDescription
Graphics

moveTo (x, y)Graphics

現在の描画位置を (x, y) に移動します。
Moves the current drawing position to (x, y).

NameTypeDescription
xnumber
ynumber
Returns:
TypeDescription
Graphics

toString ()string

指定されたオブジェクトのストリングを返します。
Returns the string representation of the specified object.

Default Value:
  • [object Graphics]
Returns:
TypeDescription
string