Stroke class

Stroke class

Defines a stroke for a shape. To learn more, visit the Working with Shapes documentation article.

Remarks

Use the Shape.stroke property to access stroke properties of a shape. You do not create instances of the Stroke class directly.

Properties

NameDescription
back_colorGets or sets the background color of the stroke.
back_theme_colorGets or sets a ThemeColor object that represents the stroke background color.
back_tint_and_shadeGets or sets a double value that lightens or darkens the stroke background color.
base_fore_colorGets the base foreground color of the stroke without any modifiers.
colorDefines the color of a stroke.
color2Defines a second color for a stroke.
dash_styleSpecifies the dot and dash pattern for a stroke.
end_arrow_lengthDefines the arrowhead length for the end of a stroke.
end_arrow_typeDefines the arrowhead for the end of a stroke.
end_arrow_widthDefines the arrowhead width for the end of a stroke.
end_capDefines the cap style for the end of a stroke.
fillGets fill formatting for the Stroke.
fore_colorGets or sets the foreground color of the stroke.
fore_theme_colorGets or sets a ThemeColor object that represents the stroke foreground color.
fore_tint_and_shadeGets or sets a double value that lightens or darkens the stroke foreground color.
image_bytesDefines the image for a stroke image or pattern fill.
join_styleDefines the join style of a polyline.
line_styleDefines the line style of the stroke.
onDefines whether the path will be stroked.
opacityDefines the amount of transparency of a stroke. Valid range is from 0 to 1.
start_arrow_lengthDefines the arrowhead length for the start of a stroke.
start_arrow_typeDefines the arrowhead for the start of a stroke.
start_arrow_widthDefines the arrowhead width for the start of a stroke.
transparencyGets or sets a value between 0.0 (opaque) and 1.0 (clear) representing the degree of transparency of the stroke.
visibleGets or sets a flag indicating whether the stroke is visible.
weightDefines the brush thickness that strokes the path of a shape in points.

Examples

Shows how change stroke properties.

doc = aw.Document()
builder = aw.DocumentBuilder(doc)

shape = builder.insert_shape(aw.drawing.ShapeType.RECTANGLE, aw.drawing.RelativeHorizontalPosition.LEFT_MARGIN, 100,
    aw.drawing.RelativeVerticalPosition.TOP_MARGIN, 100, 200, 200, aw.drawing.WrapType.NONE)

# Basic shapes, such as the rectangle, have two visible parts.
# 1 -  The fill, which applies to the area within the outline of the shape:
shape.fill.fore_color = drawing.Color.white

# 2 -  The stroke, which marks the outline of the shape:
# Modify various properties of this shape's stroke.
stroke = shape.stroke
stroke.on = True
stroke.weight = 5
stroke.color = drawing.Color.red
stroke.dash_style = aw.drawing.DashStyle.SHORT_DASH_DOT_DOT
stroke.join_style = aw.drawing.JoinStyle.MITER
stroke.end_cap = aw.drawing.EndCap.SQUARE
stroke.line_style = aw.drawing.ShapeLineStyle.TRIPLE

stroke.fill.two_color_gradient(drawing.Color.red, drawing.Color.blue, awd.GradientStyle.VERTICAL, awd.GradientVariant.VARIANT1)

doc.save(ARTIFACTS_DIR + "Shape.stroke.docx")

See Also