Skip to content

Annotations

keyed.annotations

underline

underline(obj, offset=20, color=(1, 1, 1), alpha=1, dash=None, operator=OPERATOR_OVER, line_width=1)

Add an underline effect.

Parameters:

Name Type Description Default
offset float

Distance below baseline.

20
color HasValue[Color] | tuple[float, float, float]

Color of the line.

(1, 1, 1)
alpha HasValue[float]

Transparency.

1
dash tuple[Sequence[float], float] | None

Dash specification.

None
operator Operator

Cairo composition operator.

OPERATOR_OVER
line_width HasValue[float]

Strike width of underline.

1

Returns:

Type Description
Line

Line object representing the underline.

Source code in src/keyed/annotations.py
def underline(
    obj: Base,
    offset: float = 20,
    color: HasValue[Color] | tuple[float, float, float] = (1, 1, 1),
    alpha: HasValue[float] = 1,
    dash: tuple[Sequence[float], float] | None = None,
    operator: cairo.Operator = cairo.OPERATOR_OVER,
    line_width: HasValue[float] = 1,
) -> Line:
    """Add an underline effect.

    Args:
        offset: Distance below baseline.
        color: Color of the line.
        alpha: Transparency.
        dash: Dash specification.
        operator: Cairo composition operator.
        line_width: Strike width of underline.

    Returns:
        Line object representing the underline.
    """
    x0 = obj.left.value
    x1 = obj.right.value
    y = obj.down.value + offset
    return Line(
        obj.scene,
        x0=x0,
        y0=y,
        x1=x1,
        y1=y,
        color=color,
        alpha=alpha,
        dash=dash,
        operator=operator,
        line_width=line_width,
    )