4.4.3. undulate.skin module

This define the style of the drawing it follows the principle of the css but accept only a subset: font: size, style, variant, weight, stretch, align, family fill: color, opacity stroke: color, width, opacity, linecap, linejoin, mitterlimit, dasharray, opacity

colors should always be in rgba with value from 0—255

class undulate.skin.Engine(value)

Bases: enum.Enum

An enumeration.

class undulate.skin.SizeUnit(value)

Bases: enum.Enum

An enumeration.

class undulate.skin.LineCap(value)

Bases: enum.Enum

An enumeration.

class undulate.skin.LineJoin(value)

Bases: enum.Enum

An enumeration.

class undulate.skin.TextAlign(value)

Bases: enum.Enum

An enumeration.

class undulate.skin.CSSTokenType(value)

Bases: enum.Enum

An enumeration.

undulate.skin.css_tokenizer(stream)

read a character stream and gather them to provide a token to the css parser :param character line stream: :type character line stream: FileStream/StringIO

Returns

line_number (int) token_type (CSSTokenType) token (str)

Return type

Tuple(int,CSSTokenType,str)

undulate.skin.parse_css_size(S: str) tuple

convert a css valid representation of a size into a value unit tuple

undulate.skin.hsl_to_rgb(h, s, l)

convert hsl([0-359] deg, [0-1] float, [0-1] float) into rgb([0-255] int, [0-255] int, [0-255] int)

undulate.skin.parse_css_color(S: str) tuple

convert a css valid representation of a color into rgba tuple from 0 to 255

undulate.skin.css_parser(token_iter)

construct the style dictionnary from an iterator of tokens

undulate.skin.apply_cairo_style(context, name: str, overload: dict)

read the style and apply via cairo functions

undulate.skin.apply_cairo_fill(context, style: dict, overload: dict)

set the fill color found in the style

undulate.skin.apply_cairo_stroke(context, style: dict, overload: dict)

support width, color, linecap, linejoin, dash

undulate.skin.cairo_text_align(context, style: dict, text: str)

offset calculation for text alignment

undulate.skin.cairo_text_bbox(context, style: dict, text: str)

return size of the text for a given font

undulate.skin.apply_cairo_font(context, style: dict, overload: dict)

get font information from the style and apply support font family, bold, italic, normal, size

undulate.skin.apply_fill(context, name: str, engine: undulate.skin.Engine, overload: dict = {})

apply fill from ‘name’ of the selector for the supported engine

undulate.skin.apply_stroke(context, name: str, engine: undulate.skin.Engine, overload: dict = {})

apply stroke from ‘name’ of the selector for the supported engine

undulate.skin.apply_font(context, name: str, engine: undulate.skin.Engine, overload: dict = {})

apply font from ‘name’ of the selector for the supported engine

undulate.skin.get_style(name: str, overload: dict = {}) dict

get the style from the selector rules and fallback to a closest match in the default style

undulate.skin.text_align(context, name: str, text: str, engine: undulate.skin.Engine)

calculate the offset to apply for the text alignment

undulate.skin.text_bbox(context, name: str, text: str, engine: undulate.skin.Engine, overload: dict = {})

calculate the bounding box of the text

undulate.skin.css_from_style(style: dict)

generate an equivalent string for only one rule of the style

undulate.skin.css_from_rule(rule: str, style: dict, with_rule: bool = True)

generate an equivalent string for only one rule of the style