GraphicsBase line_dash_dot_setting interface¶
This page explains the GraphicsBase
class line_dash_dot_setting
property interface.
What interface is this?¶
The line_dash_dot_setting
property interface updates or get the instance’s current line dash-dot setting.
Basic usage¶
The getter or setter interface value becomes (or requires) the LineDashDotSetting
instance value.
The following example sets the 10-pixel dash and 3-pixel dot to the line:
import apysc as ap
ap.Stage(
stage_width=250,
stage_height=100,
background_color=ap.Color("#333"),
stage_elem_id="stage",
)
sprite: ap.Sprite = ap.Sprite()
sprite.graphics.line_style(color=ap.Color("#0af"), thickness=5)
line: ap.Line = sprite.graphics.draw_line(x_start=50, y_start=50, x_end=200, y_end=50)
line.line_dash_dot_setting = ap.LineDashDotSetting(
dot_size=10, dash_size=3, space_size=3
)
ap.save_overall_html(dest_dir_path="./graphics_base_line_dash_dot_setting_basic_usage/")
Delete setting¶
The delete_line_dash_dot_setting
interface deletes this line setting.
In the following example, if you click the rectangle, the handler deletes the line setting:
import apysc as ap
def on_click(e: ap.MouseEvent[ap.Rectangle], options: dict) -> None:
"""
The handler for the click event.
Parameters
----------
e : ap.MouseEvent[ap.Rectangle]
Event instance.
options : dict
Optional argument dictionary.
"""
rectangle: ap.Rectangle = e.this
rectangle.delete_line_dash_dot_setting()
ap.Stage(
stage_width=150,
stage_height=150,
background_color=ap.Color("#333"),
stage_elem_id="stage",
)
rectangle: ap.Rectangle = ap.Rectangle(
x=50,
y=50,
width=50,
height=50,
fill_color=ap.Color("#666"),
line_color=ap.Color("#fff"),
line_thickness=2,
line_dash_dot_setting=ap.LineDashDotSetting(dot_size=2, dash_size=4, space_size=2),
)
rectangle.click(handler=on_click)
ap.save_overall_html(
dest_dir_path="./graphics_base_line_dash_dot_setting_delete_setting/"
)
line_dash_dot_setting API¶
Note: the document build script generates and updates this API document section automatically. Maybe this section is duplicated compared with previous sections.
[Interface summary]
Get a current dash-dot (1-dot chain) setting.
[Returns]
line_dash_dot_setting
: LineDashDotSetting or NoneDash-dot (1-dot chain) setting.
[Examples]
>>> import apysc as ap
>>> stage: ap.Stage = ap.Stage()
>>> sprite: ap.Sprite = ap.Sprite()
>>> sprite.graphics.line_style(color=ap.Color("#fff"), thickness=10)
>>> line: ap.Line = sprite.graphics.draw_line(
... x_start=50, y_start=50, x_end=150, y_end=50
... )
>>> line.line_dash_dot_setting = ap.LineDashDotSetting(
... dot_size=2, dash_size=5, space_size=3
... )
>>> line.line_dash_dot_setting.dot_size
Int(2)
>>> line.line_dash_dot_setting.dash_size
Int(5)
>>> line.line_dash_dot_setting.space_size
Int(3)
delete_line_dash_dot_setting 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] delete_line_dash_dot_setting(self) -> None
[Interface summary]
Delete a current line dash-dot (1-dot chain) setting.