def paint.keyword.head

gralha-svg-render@0.1.0.1 · svg.bend:2445

import gralha-svg-render@0.1.0.1/svg.bend as Svg
import Base
import gralha-text-scan@0.1.0.1/scan.bend as U

2445# A paint's keyword, decided from its first letter: 1 currentcolor,
2446# 2 context-fill, 3 context-stroke, 0 a color or none.
2447def paint.keyword.head(s: String) -> U32:
2448  match s:
2449    case SNil{}: 0
2450    case SCon{Chr{c}, t}:
2451      +ch = c
2452      +rest = t
2453      U.choose(U32, U32.is_eq(U32.or(ch, 32), 99), U.choose(U32, keyword.rest("urrentcolor", rest), 1, U.choose(U32, keyword.rest("ontext-fill", rest), 2, U.choose(U32, keyword.rest("ontext-stroke", rest), 3, 0))), 0)

Uses (7)

Used by (1)