Colors¶
- class img_gen.ColorKind¶
An enum to describe the possible kinds of colors used when rendering various [
Layer](struct@crate::Layer) attributes/properties.- SolidColor : Callable[[Color], ColorKind]¶
Pass an instance of
Colorto the parameter of this constructor.
- LinearGradient : Callable[[LinearGradient], ColorKind]¶
Pass an instance of
LinearGradientto the parameter of this constructor.
- RadialGradient : Callable[[RadialGradient], ColorKind]¶
Pass an instance of
RadialGradientto the parameter of this constructor.
- ConicalGradient : Callable[[ConicalGradient], ColorKind]¶
Pass an instance of
ConicalGradientto the parameter of this constructor.
Solid color¶
-
class img_gen.SolidColor(r: int =
0, g: int =0, b: int =0, a: int =0)¶ –
A class to represent a solid color.
Instantiate a
Colorfrom a 4 unsigned integers in range [0, 255]. Each parameter corresponds to theColorattributes:- a¶
The color’s alpha component (AKA opacity).
- as_json_str()¶
Serialize the
SolidColorobject to a JSON string.
- as_yaml_str()¶
Serialize the
SolidColorobject to a YAML string.
- b¶
The color’s blue component.
- static from_json_str(json_str)¶
Deserialize a
SolidColorobject from a JSON string.
- static from_string(val: str) Color¶
–
Instantiate a
SolidColorfrom an string typically used in CSS.Valid color values include
named colors (see CSS specifications)
hexadecimal color codes (
#f00or#ff0000or#ff0000ff)RGB or RGBA strings (
"rgb(255, 0, 0)"or"rgba(255, 0, 0, 1.0")HSL or HSLA string (
"hsl(0, 1.0, 1.0)"or"hsla(0, 1.0, 1.0, 1.0)")HWB or HWBA string (
"hwb(0, 1.0, 1.0)"or"hwba(0, 1.0, 1.0, 1.0)")HSV or HSVA string (
"hsv(0, 1.0, 1.0)"or"hsva(0, 1.0, 1.0, 1.0)")
- Throws:¶
A
ValueErroris raised if the given value is not a proper CSS color value.
- static from_yaml_str(yaml_str)¶
Deserialize a
SolidColorobject from a YAML string.
- g¶
The color’s green component.
- r¶
The color’s red component.
Gradient colors¶
-
class img_gen.ColorGradient(spec: list[tuple[float, str]] | None =
None, preset: Preset | None =Presets.MonoChrome)¶ –
A class to represent a gradient of colors.
- as_json_str()¶
Serialize the
ColorGradientobject to a JSON string.
- as_yaml_str()¶
Serialize the
ColorGradientobject to a YAML string.
- static from_json_str(json_str)¶
Deserialize a
ColorGradientobject from a JSON string.
- static from_yaml_str(yaml_str)¶
Deserialize a
ColorGradientobject from a YAML string.
- class img_gen.Spread¶
A enumeration to describe gradient spread behavior at the bounds of the gradient.
This only applies to
LinearGradientandRadialGradient, notConicalGradient.-
Pad =
Spread.Pad¶
-
Reflect =
Spread.Reflect¶
-
Repeat =
Spread.Repeat¶
-
Pad =