svgen.color package
svgen.color.alpha module
svgen - A module for working with alpha channels for colors.
-
class svgen.color.alpha.Alpha(val: float | int | str)[source]
Bases: float
A class describing the transparency of a color.
-
property hex_str: str
Convert this alpha value to a hex string.
svgen.color.conversion module
svgen - A module for converting colors from some form to some other.
-
svgen.color.conversion.hsl_to_rgb(color: Hsl) → Rgb[source]
Convert an hsl color to rgb.
-
svgen.color.conversion.rgb_to_hsl(color: Rgb) → Hsl[source]
Convert an rgb color to an hsl color.
svgen.color.hsl module
svgen - Common interfaces for hsl colors. See also:
-
class svgen.color.hsl.Hsl(hue: DegreePrimitive, saturation: PercentPrimitive, lightness: PercentPrimitive, alpha: Alpha = 1.0)[source]
Bases: NamedTuple
A definition of an hsl color.
-
alpha: Alpha
Alias for field number 3
-
arc(hue_count: int = 1, hue_divisor: int = 1, saturation_count: int = 1, saturation_divisor: int = 1, lightness_count: int = 1, lightness_divisor: int = 1) → Hsl[source]
Rotate this angle around the circle.
-
static from_ctor(value: str) → Hsl[source]
Get an hsl color from a constructor string.
-
hue: DegreePrimitive
Alias for field number 0
-
lightness: PercentPrimitive
Alias for field number 2
-
saturation: PercentPrimitive
Alias for field number 1
-
class svgen.color.hsl.PercentPrimitive(val: int)[source]
Bases: int
, Rotatable
A class for integer percentages.
-
arc(count: int = 1, divisor: int = 2) → PercentPrimitive[source]
Rotate this angle around the circle.
-
property ratio: float
Get this percentage as a ratio between 0 and 1.
-
svgen.color.hsl.hsl(hue: int, saturation: float, lightness: float) → Hsl[source]
Create a new hsl color.
-
svgen.color.hsl.hsla(hue: int, saturation: float, lightness: float, alpha: float) → Hsl[source]
Create a new hsl color with a transparency value.
svgen.color.numbers module
svgen - A module for working with number primitives.
-
svgen.color.numbers.css_number_to_ratio(val: float | int | str) → float[source]
Given a few possible types of input, return a ratio between 0.0 and 1.0.
-
svgen.color.numbers.parse_ctor(value: str, prefix: str, suffix: str = None, sep: str = ',') → List[str][source]
Parse individual arguments out of some color constructor.
svgen.color.resolve module
A module for resolving colors.
-
svgen.color.resolve.get_color(key: str | Hsl | Rgb | Color, manager: ColorThemeManager = None) → Color[source]
Resolve a color using the theme manager.
svgen.color.rgb module
svgen - Common interfaces for rgb colors. See also:
-
class svgen.color.rgb.Rgb(red: RgbPrimitive, green: RgbPrimitive, blue: RgbPrimitive, alpha: Alpha = 1.0)[source]
Bases: NamedTuple
A definition of an rgb color.
-
alpha: Alpha
Alias for field number 3
-
blue: RgbPrimitive
Alias for field number 2
-
static from_ctor(value: str) → Rgb[source]
Get an rgb color from a constructor string.
-
static from_hex(value: str) → Rgb[source]
Get an rgb color from a hex string.
-
green: RgbPrimitive
Alias for field number 1
-
red: RgbPrimitive
Alias for field number 0
-
property rgb: str
Get this color as an ‘rgb’ constructor.
-
property rgba: str
Get this color as an ‘rgba’ constructor.
-
class svgen.color.rgb.RgbPrimitive(val: int)[source]
Bases: int
An integer type for rgb values.
-
property ratio: float
Get this color as a ratio between 0 and 1.
-
svgen.color.rgb.rgb(red: int, green: int, blue: int) → Rgb[source]
Create a new RGB color.
-
svgen.color.rgb.rgba(red: int, green: int, blue: int, alpha: float | int | str) → Rgb[source]
Create a new RGB color with a transparency value.
Module contents
svgen - A module for working with colors.
-
class svgen.color.Color(rgb: Rgb, hsl: Hsl)[source]
Bases: NamedTuple
A definition of a color.
-
classmethod create(value: str | Hsl | Rgb | Color) → Color[source]
Create a color from a variety of possible sources.
-
classmethod from_ctor(value: str) → Color[source]
Create a color from an hsl or rgb constructor string.
-
classmethod from_hex(value: str) → Color[source]
Create a color from a hex value.
-
classmethod from_hsl(color: Hsl) → Color[source]
Create a color from an hsl object.
-
classmethod from_rgb(color: Rgb) → Color[source]
Create a color from an rgb object.
-
hsl: Hsl
Alias for field number 1
-
hsl_arc(**kwargs) → Color[source]
Get a new color based on some rotation in HSL space.
-
rgb: Rgb
Alias for field number 0