Skip to content

colors

prairielearn.colors

Custom colors for the PrairieLearn project based on Coloraide.

Based on https://gist.github.com/facelessuser/0b129c1faf7f3f59c0de40eeaaab5691/.

PrairieLearnColor

Custom sRGB class to handle custom PrairieLearn colors, via Coloraide.

match

match(
    string: str, start: int = 0, fullmatch: bool = True
) -> tuple[tuple[Vector, float], int] | None

Match a color string, first trying PrairieLearn. If no match is found, defaults to sRGB class' implementation.

to_string

to_string(
    parent: Color,
    *,
    alpha: bool | None = None,
    fit: bool | str | dict[str, Any] = True,
    names: bool = False,
    **kwargs: Any,
) -> str

Convert to string.

get_css_color

get_css_color(name: str) -> str | None

Try to look up a hex code value from a named css color, otherwise return None if not a valid color.