Draw interfaces abstract¶
This page would explain the drawing interfaces abstract.
What apysc can do in its drawing interfaces¶
You can set the fill-color, fill-alpha (opacity), line-color, line-alpha, line-thickness values and draw each SVG graphic with these.
Supported graphics: The rectangle, circle, ellipse, polygon, line, polyline, and path.
Fill settings¶
The begin_fill
interface sets the fill-color and fill-alpha (opacity).
import apysc as ap
ap.Stage(
background_color=ap.Color("#333"),
stage_width=150,
stage_height=150,
stage_elem_id="stage",
)
sprite: ap.Sprite = ap.Sprite()
sprite.graphics.begin_fill(color=ap.Color("#0af"), alpha=0.5)
sprite.graphics.draw_rect(x=50, y=50, width=50, height=50)
ap.save_overall_html(dest_dir_path="draw_interfaces_abstract_begin_fill/")
For more details, please see:
Line style settings¶
The line_style
interface sets the line-color, line-alpha (opacity), line-thickness.
import apysc as ap
ap.Stage(
background_color=ap.Color("#333"),
stage_width=200,
stage_height=100,
stage_elem_id="stage",
)
sprite: ap.Sprite = ap.Sprite()
sprite.graphics.line_style(color=ap.Color("#fff"), thickness=5, alpha=0.5)
sprite.graphics.draw_line(x_start=50, y_start=50, x_end=150, y_end=50)
ap.save_overall_html(dest_dir_path="draw_interfaces_abstract_line_style/")
For more details, please see:
Each drawing interface¶
Each drawing interface has the draw_
prefix draw SVG graphics (e.g., draw_rect, draw_circle).
import apysc as ap
ap.Stage(
background_color=ap.Color("#333"),
stage_width=250,
stage_height=150,
stage_elem_id="stage",
)
sprite: ap.Sprite = ap.Sprite()
sprite.graphics.begin_fill(color=ap.Color("#0af"))
sprite.graphics.draw_rect(x=50, y=50, width=50, height=50)
sprite.graphics.draw_circle(x=175, y=75, radius=25)
ap.save_overall_html(dest_dir_path="draw_interfaces_abstract_each_drawing_interface/")
For more details, please see the following: