Graphics draw_round_dotted_line interface¶
This page explains the Graphics
class draw_round_dotted_line
method interface.
What interface is this?¶
draw_round_dotted_line
interface draws the simple straight round dotted-line graphics. This interface ignores dot_setting
, dash_setting
, round_dot_setting
, dash_dot_setting
, and cap
settings (this interface is using round cap setting so cap setting will also be ignored).
Basic usage¶
draw_round_dotted_line
interface has basic coordinates arguments of x_start
, y_start
, x_end
and y_end
. That also has round_size
and space_size
arguments to determine the round style (line round size and the space size between each round).
import apysc as ap
ap.Stage(
background_color=ap.Color("#333"),
stage_width=250,
stage_height=130,
stage_elem_id="stage",
)
sprite: ap.Sprite = ap.Sprite()
# Set 5-pixel round size and draw the line.
sprite.graphics.line_style(color=ap.Color("#0af"))
sprite.graphics.draw_round_dotted_line(
x_start=50, y_start=50, x_end=200, y_end=50, round_size=5, space_size=5
)
# Set 10-pixel round size and draw the line.
sprite.graphics.draw_round_dotted_line(
x_start=50, y_start=80, x_end=200, y_end=80, round_size=10, space_size=5
)
ap.save_overall_html(dest_dir_path="graphics_draw_round_dotted_line_basic_usage/")
Notes¶
Since this interface uses the round cap setting, the line length becomes longer by the size of the cap.
If you want to align the left line position with other lines, subtract half-round size from the x_start
argument.
import apysc as ap
ap.Stage(
background_color=ap.Color("#333"),
stage_width=270,
stage_height=130,
stage_elem_id="stage",
)
sprite: ap.Sprite = ap.Sprite()
# Set 5-pixel round size and draw the line.
sprite.graphics.line_style(color=ap.Color("#0af"))
sprite.graphics.draw_round_dotted_line(
x_start=50, y_start=50, x_end=220, y_end=50, round_size=10, space_size=5
)
# Set 45-pixel (50 - half-round size) to x_start argument
# and draw the normal line.
sprite.graphics.draw_line(x_start=45, y_start=80, x_end=225, y_end=80)
ap.save_overall_html(dest_dir_path="graphics_draw_round_dotted_line_notes/")
draw_round_dotted_line 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_round_dotted_line(self, *, x_start: Union[float, apysc._type.number.Number], y_start: Union[float, apysc._type.number.Number], x_end: Union[float, apysc._type.number.Number], y_end: Union[float, apysc._type.number.Number], round_size: Union[int, apysc._type.int.Int], space_size: Union[int, apysc._type.int.Int], variable_name_suffix: str = '') -> '_line.Line'
[Interface summary]
Draw a round-dotted line vector graphics.
[Parameters]
x_start
: float or NumberLine start x-coordinate.
y_start
: float or NumberLine start y-coordinate.
x_end
: float or NumberLine end x-coordinate.
y_end
: float or NumberLine end y-coordinate.
round_size
: Int or intDot round size.
space_size
: Int or intBlank space size between dots.
variable_name_suffix
: str, default “”A JavaScript variable name suffix string. This setting is sometimes useful for JavaScript debugging.
[Returns]
line
: LineCreated line graphics instance.
[Notes]
This interface ignores line settings, like the LineDotSetting
, except LineRoundDotSetting
.
[Examples]
>>> import apysc as ap
>>> stage: ap.Stage = ap.Stage()
>>> sprite: ap.Sprite = ap.Sprite()
>>> sprite.graphics.line_style(color=ap.Color("#fff"), thickness=5)
>>> line: ap.Line = sprite.graphics.draw_round_dotted_line(
... x_start=50, y_start=50, x_end=150, y_end=50, round_size=6, space_size=3
... )
>>> line.line_color
Color("#ffffff")
>>> line.line_round_dot_setting.round_size
Int(6)
>>> line.line_round_dot_setting.space_size
Int(3)