0 | module Web.MVC.Canvas.Style
3 | import Text.CSS.Color
9 | data Style : Type where
10 | Fill : Color -> Style
11 | Stroke : Color -> Style
12 | LineWidth : Double -> Style
13 | SetLineDash : List Double -> Style
14 | LineDashOffset : Double -> Style
15 | Font : String -> Style
16 | Direction : CanvasDirection -> Style
17 | TextAlign : CanvasTextAlign -> Style
18 | TextBaseline : CanvasTextBaseline -> Style
25 | apply : CanvasRenderingContext2D -> Style -> JSIO ()
26 | apply ctxt (Fill c) = fillStyle ctxt .= inject (interpolate c)
27 | apply ctxt (Stroke c) = strokeStyle ctxt .= inject (interpolate c)
28 | apply ctxt (LineWidth v) = lineWidth ctxt .= v
29 | apply ctxt (SetLineDash vs) = fromListIO vs >>= setLineDash ctxt
30 | apply ctxt (LineDashOffset v) = lineDashOffset ctxt .= v
31 | apply ctxt (Font v) = font ctxt .= v
32 | apply ctxt (Direction v) = direction ctxt .= v
33 | apply ctxt (TextAlign v) = textAlign ctxt .= v
34 | apply ctxt (TextBaseline v) = textBaseline ctxt .= v