Radial Gradient

class img_gen.RadialGradient(colors: ColorGradient, center: Offset, radius: float, focal_point: Offset | None = None, focal_radius: float | None = None, spread: Spread = Spread.Pad)

A data structure to represent a radial gradient.

as_json_str()

Serialize the RadialGradient object to a JSON string.

as_yaml_str()

Serialize the RadialGradient object to a YAML string.

center

The center (Offset) of the gradient (relative to the Layer.offset).

focal_point

The focal point (Offset) of the gradient (relative to the Layer.offset).

focal_radius

Returns the focal radius.

static from_json_str(json_str)

Deserialize a RadialGradient object from a JSON string.

static from_yaml_str(yaml_str)

Deserialize a RadialGradient object from a YAML string.

get_color_at(x: int, y: int) SolidColor

A helper function to Generator.render() behavior.

The given x and y values (unsigned) are the coordinate of the pixel in the Layer (relative to Layer.offset).

radius

The radius of the gradient.

spread

The gradient Spread