Draw Direct Shape Line Properties
The ooodev.format.draw.direct.line.LineProperties
class is used to modify the values seen in Fig. 855 of a shape.
Setup
from __future__ import annotations
import uno
from ooodev.draw import Draw, DrawDoc, ZoomKind
from ooodev.loader.lo import Lo
from ooodev.format.draw.direct.line import LineProperties, BorderLineKind
from ooodev.utils.color import StandardColor
def main() -> int:
with Lo.Loader(connector=Lo.ConnectSocket()):
doc = DrawDoc(Draw.create_draw_doc())
doc.set_visible()
Lo.delay(500)
doc.zoom(ZoomKind.ZOOM_75_PERCENT)
slide = doc.get_slide()
width = 36
height = 36
x = round(width / 2)
y = round(height / 2)
rect = slide.draw_rectangle(x=x, y=y, width=width, height=height)
style = LineProperties(
style=BorderLineKind.CONTINUOUS,
color=StandardColor.RED_DARK3,
width=0.7,
transparency=22
)
style.apply(rect.component)
f_style = LineProperties.from_obj(rect.component)
assert f_style is not None
assert f_style.prop_color == StandardColor.RED_DARK3
Lo.delay(1_000)
doc.close_doc()
return 0
if __name__ == "__main__":
raise SystemExit(main())
Add a Line Properties to the shape
Adding a Line Properties to the shape is done by using the LineProperties
class.
from ooodev.format.draw.direct.line import LineProperties, BorderLineKind
from ooodev.utils.color import StandardColor
# ... other code
rect = slide.draw_rectangle(x=x, y=y, width=width, height=height)
style = LineProperties(
style=BorderLineKind.CONTINUOUS,
color=StandardColor.RED_DARK3,
width=0.7,
transparency=22
)
style.apply(rect.component)
The results of the setting the shape line properties can be seen in Fig. 856.
Get Shape Line Properties
We can get the line properties of the shape by using the LineProperties.from_obj()
method.
from ooodev.format.draw.direct.line import LineProperties
# ... other code
# get the properties from the shape
f_style = LineProperties.from_obj(rect.component)
assert f_style.prop_color == StandardColor.RED_DARK3