GraphicsBase fill_alpha interface¶
This page explains the GraphicsBase
class fill_alpha
property interface.
What interface is this?¶
The fill_alpha
property interface updates or gets the instance’s fill alpha (opacity).
Basic usage¶
The getter or setter interface value becomes (or requires) the Number
value (0.0 to 1.0).
The following example sets the 0.5 fill alpha to the second rectangle and 0.25 to the third rectangle:
import apysc as ap
ap.Stage(
stage_width=350,
stage_height=150,
background_color=ap.Color("#333"),
stage_elem_id="stage",
)
sprite: ap.Sprite = ap.Sprite()
sprite.graphics.begin_fill(color=ap.Color("#0af"))
rectangle_1: ap.Rectangle = sprite.graphics.draw_rect(x=50, y=50, width=50, height=50)
rectangle_2: ap.Rectangle = sprite.graphics.draw_rect(x=150, y=50, width=50, height=50)
rectangle_2.fill_alpha = ap.Number(0.5)
rectangle_3: ap.Rectangle = sprite.graphics.draw_rect(x=250, y=50, width=50, height=50)
rectangle_3.fill_alpha = ap.Number(0.25)
ap.save_overall_html(dest_dir_path="./graphics_base_fill_alpha_basic_usage/")
fill_alpha property 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 this instance’s fill opacity.
[Returns]
fill_alpha
: NumberCurrent fill opacity (0.0 to 1.0).
[Examples]
>>> import apysc as ap
>>> stage: ap.Stage = ap.Stage()
>>> sprite: ap.Sprite = ap.Sprite()
>>> sprite.graphics.begin_fill(color=ap.Color("#0af"))
>>> rectangle: ap.Rectangle = sprite.graphics.draw_rect(
... x=50, y=50, width=50, height=50
... )
>>> rectangle.fill_alpha = ap.Number(0.5)
>>> rectangle.fill_alpha
Number(0.5)