Graphics draw_circle interface

This page explains the Graphics class draw_circle method interface.

What interface is this?

draw_circle interface draws the vector circle graphics.

Basic usage

The draw_circle interface has the x, y, and radius arguments.

The x and y arguments are the circle center coordinates, and the radius argument determines the circle size. The width and height become twice the radius value.

import apysc as ap

ap.Stage(
    background_color="#333", stage_width=350, stage_height=200, stage_elem_id="stage"
)

sprite: ap.Sprite = ap.Sprite()

# Set the cyan color and draw the circle.
sprite.graphics.begin_fill(color="#0af")
sprite.graphics.draw_circle(x=100, y=100, radius=50)

# Set the dotted-line style and draw the circle.
sprite.graphics.begin_fill(color="")
sprite.graphics.line_style(
    color="#fff", thickness=3, dot_setting=ap.LineDotSetting(dot_size=3)
)
sprite.graphics.draw_circle(x=250, y=100, radius=50)

# Draw the inner circle.
sprite.graphics.draw_circle(x=250, y=100, radius=25)

ap.save_overall_html(dest_dir_path="graphics_draw_circle_basic_usage/")

Return value

The return value of the draw_circle interface is the instance of the Circle class.

It has the radius attribute or other basic interfaces and you can change these settings.

import apysc as ap

ap.Stage(
    background_color="#333", stage_width=400, stage_height=400, stage_elem_id="stage"
)

sprite: ap.Sprite = ap.Sprite()

# Draw the small radius circle.
sprite.graphics.begin_fill(color="#0af")
circle: ap.Circle = sprite.graphics.draw_circle(x=200, y=200, radius=25)

# Update circle radius to become the bigger one.
circle.radius = ap.Int(100)

ap.save_overall_html(dest_dir_path="graphics_draw_circle_return_value/")

draw_circle API

Note: the document build script generates and updates this API document section automatically. Maybe this section is duplicated compared with previous sections.

[Interface signature] draw_circle(self, *, x: Union[int, apysc._type.int.Int], y: Union[int, apysc._type.int.Int], radius: Union[int, apysc._type.int.Int], variable_name_suffix: str = '') -> '_circle.Circle'


[Interface summary]

Draw a circle vector graphics.


[Parameters]

  • x: Int or int

    • X-coordinate of the circle center.

  • y: Int or int

    • Y-coordinate of the circle center.

  • radius: Int or int

    • Circle radius.

  • variable_name_suffix: str, default ‘’

    • A JavaScript variable name suffix string. This setting is sometimes useful for JavaScript’s debugging.


[Returns]

  • circle: Circle

    • Created circle graphics instance.


[Examples]

>>> import apysc as ap
>>> stage: ap.Stage = ap.Stage()
>>> sprite: ap.Sprite = ap.Sprite()
>>> sprite.graphics.begin_fill(color="#0af")
>>> circle: ap.Circle = sprite.graphics.draw_circle(x=100, y=100, radius=50)
>>> circle.x
Int(100)

>>> circle.y
Int(100)

>>> circle.radius
Int(50)

>>> circle.fill_color
String('#00aaff')