FillFormat object provides access to fill properties for shapes and other objects. It supports solid fills, gradient fills, pattern fills, picture fills, and background (no fill).
Usage
Properties
Read-only. The type of this fill.Values from
MSO_FILL enumeration:MSO_FILL.SOLID- Solid color fillMSO_FILL.GRADIENT- Gradient fillMSO_FILL.PATTERNED- Pattern fillMSO_FILL.PICTURE- Picture (image) fillMSO_FILL.BACKGROUND- No fill (transparent)MSO_FILL.GROUP- Inherited from groupNone- No fill defined
ColorFormat instance representing the foreground color of this fill.For solid fills, this is the fill color. For gradient and pattern fills, this is the primary color.Raises
TypeError if fill type does not support foreground color. Call .solid() or .patterned() first.ColorFormat instance representing the background color.This property is only applicable to pattern fills.Raises
TypeError if fill type is not patterned. Call .patterned() first.Read/write. Angle in degrees of a linear gradient.
0.0= left-to-right gradient90.0= bottom-to-top gradient180.0= right-to-left gradient270.0= top-to-bottom gradient
None, indicating the angle is inherited from the style hierarchy.Raises TypeError if fill type is not MSO_FILL.GRADIENT. Call .gradient() first.Raises ValueError for non-linear gradients (e.g., radial gradients).Read-only. GradientStops collection providing access to the gradient color stops.Each stop represents a color between which the gradient smoothly transitions. Gradients must have at least two stops.Raises
TypeError if fill type is not MSO_FILL.GRADIENT. Call .gradient() first.Read/write. Member of
MSO_PATTERN_TYPE enumeration indicating the fill pattern.Returns None if no pattern has been set. PowerPoint may display the default PERCENT_5 pattern in this case.Assigning None removes any explicit pattern setting.Raises TypeError if fill type is not patterned. Call .patterned() first.Methods
solid()
Sets the fill type to solid color.fore_color.
gradient()
Sets the fill type to gradient.patterned()
Sets the fill type to pattern.pattern, fore_color, and back_color.
background()
Sets the fill type to no fill (transparent).MSO_FILL.BACKGROUND and makes the shape transparent.
GradientStops
A sequence of gradient stops defining the colors in a gradient fill. Access viafill.gradient_stops.
GradientStop Properties
ColorFormat instance controlling the color of this gradient stop.
Read/write. Location of the stop in the gradient path as a float between 0.0 and 1.0.
0.0(0%) = start of the gradient path1.0(100%) = end of the gradient path