Radial Gradients¶
- class Radial_Gradient¶
A specification for linear gradients of colors.
- preset : str | int | None¶
An optional preset gradient that has a pre-defined mapping of
colors
. Each preset is referenced by name (string) or by index (integer). See the Preset Gradients document for a complete list of supported values (with generated examples).
- colors : Dict[Annotated[float, FieldInfo(annotation=NoneType, required=True, metadata=[Ge(ge=0.0), Le(le=1.0)])], Color]¶
A mapping of colors to their corresponding positions in the gradient. Each item in this mapping is composed of
key: value
pairs in which:The
key:
is a position at which the color will occur in the gradient. Thisfloat
must be in the range0
to1
inclusively. More detail about how these positional values are used is described incenter
andradius
.The
value
is a solid color to use at the specified point in the gradient.
This mapping’s color positions does not have to be in any specific order. If using a
preset
, then this mapping will override colors in the preset’s mapping of colors. When neither thepreset
orcolors
is specified, this defaults to0.0: black
and1.0: white
.
- spread : Literal['pad', 'reflect', 'repeat']¶
This attribute controls the colors’ behavior outside the gradient’s specified area. By default this is set to
pad
.
- center : Offset¶
The starting position (
offset
) relative to the layout’soffset
(the absolute top-left corner of the card). This offset corresponds to the minimum0.0
position in the mapping ofcolors
.
- radius : Annotated[float, FieldInfo(annotation=NoneType, required=True, metadata=[Gt(gt=0)])]¶
The radius represents the ending position as a distance (in pixels) from the specified
center
offset
. The resulting circumference corresponds to the maximum1.0
position in the mapping ofcolors
.Warning
This radius must be a greater than 0.
- focal_point : Offset | None¶
The focal point (
offset
) used to give the gradient a perspective. By default, the value ofcenter
is used. If the specifiedoffset
is outside the circumference defined viaradius
, then thisoffset
will be moved to the outer-most point on the circle that would be formed by theradius
from thecenter
.
- focal_radius : float | None¶
The radius from the
focal_point
defines the aperture width of the gradient’s perspective. This is highly relative to thecenter
’sradius
. Furthermore, if thefocal_radius
forms a circumference than extends beyond thecenter
’sradius
, then the gradient is effectively nullified and treated like a solid color (which coincides with thecolors
list maximum position, 1.0).Using
spread: repeat
as a proofThe following example uses the
repeat
spread
to show thefocal_radius
area. Remember that therepeat
spread
effectively repeats the gradient outside the gradient’s effected area (using the same order ofcolors
).