Graphics draw_path interface¶
This page explains the Graphics
class draw_path
interface.
What interface is this?¶
The draw_path
interface draws vector graphics of a path.
Basic usage¶
The draw_path
interface requires the path_data_list
argument.
The path_data_list
argument is a list of path data, such as the PathLineTo
or PathBezier2D
.
import apysc as ap
ap.Stage(
background_color=ap.Color("#333"),
stage_width=300,
stage_height=150,
stage_elem_id="stage",
)
sprite: ap.Sprite = ap.Sprite()
sprite.graphics.line_style(color=ap.Color("#0af"), thickness=5)
path: ap.Path = sprite.graphics.draw_path(
path_data_list=[
ap.PathMoveTo(x=50, y=100),
ap.PathLineTo(x=100, y=100),
ap.PathLineTo(x=150, y=50),
ap.PathBezier2D(
control_x=200,
control_y=100,
dest_x=250,
dest_y=50,
),
],
)
ap.save_overall_html(dest_dir_path="graphics_draw_path_basic_usage/")
See also¶
draw_path 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_path(self, *, path_data_list: List[apysc._geom.path_data_base.PathDataBase], variable_name_suffix: str = '') -> '_path.Path'
[Interface summary]
Draw a path vector graphics.
[Parameters]
path_data_list
: list of PathDataBaseTarget path data settings, such as the ap.PathData.MoveTo.
variable_name_suffix
: str, default “”A JavaScript variable name suffix string. This setting is sometimes useful for JavaScript debugging.
[Returns]
path
: PathCreated path graphics instance.
[Examples]
>>> import apysc as ap
>>> stage: ap.Stage = ap.Stage()
>>> sprite: ap.Sprite = ap.Sprite()
>>> sprite.graphics.line_style(color=ap.Color("#fff"), thickness=3)
>>> path: ap.Path = sprite.graphics.draw_path(
... path_data_list=[
... ap.PathMoveTo(x=0, y=50),
... ap.PathBezier2D(control_x=50, control_y=0, dest_x=100, dest_y=50),
... ]
... )
[References]