Draw Modify Gradient Transparency

The ooodev.format.draw.modify.transparency.Gradient, class is used to modify the values seen in Fig. 907 of a style.

Setting the Font Effects

from __future__ import annotations
import uno
from ooodev.draw import Draw, DrawDoc, ZoomKind
from ooodev.format.draw.modify import FamilyGraphics, DrawStyleFamilyKind
from ooodev.format.draw.modify.transparency import Gradient
from ooodev.format.draw.modify.transparency import GradientStyle, IntensityRange
from ooodev.format.draw.modify.area.color import Color as AreaColor
from ooodev.utils.color import StandardColor
from ooodev.loader.lo import Lo


def main() -> int:
    with Lo.Loader(connector=Lo.ConnectSocket()):
        doc = DrawDoc(Draw.create_draw_doc())
        doc.set_visible()
        Lo.delay(700)
        doc.zoom(ZoomKind.ZOOM_75_PERCENT)

        slide = doc.get_slide()

        width = 100
        height = 50
        x = 10
        y = 10

        rect = slide.draw_rectangle(x=x, y=y, width=width, height=height)
        rect.set_string("Hello World!")
        style_name_kind = FamilyGraphics.DEFAULT_DRAWING_STYLE
        style_family_kind = DrawStyleFamilyKind.GRAPHICS
        style_color = AreaColor(
            color=StandardColor.BLUE_LIGHT2, style_name=style_name_kind, style_family=style_family_kind
        )
        style = Gradient(
            style=GradientStyle.LINEAR,
            angle=45,
            border=22,
            grad_intensity=IntensityRange(0, 100),
            style_name=style_name_kind,
            style_family=style_family_kind,
        )
        doc.apply_styles(style_color, style)

        f_style = Gradient.from_style(
            doc=doc.component,
            style_name=style_name_kind,
            style_family=style_family_kind,
        )
        assert f_style.prop_style_name == str(style_name_kind)

        Lo.delay(1_000)
        doc.close_doc()
    return 0


if __name__ == "__main__":
    raise SystemExit(main())

Running the above code will produce the following results in the Draw dialog.

Draw dialog Gradient Transparency style changed

Fig. 905 Draw dialog Gradient Transparency style changed

Shape after applying style.

Shape after Style applied

Fig. 906 Shape after Style applied

Getting font effects from a style

# ... other code

f_style = Gradient.from_style(
    doc=doc.component,
    style_name=style_name_kind,
    style_family=style_family_kind,
)
assert f_style.prop_style_name == str(style_name_kind)