~alcinnz/Mondrian

a22a7f055c206193392f8adbb1dcea79eb7d2e20 — Adrian Cochrane 1 year, 5 months ago b81c9e6 master
Implement groove, ridge, inset, & outset border styles! Fix border-left-color
2 files changed, 12 insertions(+), 1 deletions(-)

M lib/Graphics/Rendering/Rect/Border.hs
M lib/Graphics/Rendering/Rect/CSS/Border.hs
M lib/Graphics/Rendering/Rect/Border.hs => lib/Graphics/Rendering/Rect/Border.hs +11 -0
@@ 59,6 59,9 @@ borderFragmentShader = B8.pack $ unlines [
    "   float width = widths[side];",
    "   vec2 dotCenter = vec2(segment*width*2 + width, width/2);",
    "   int stroke3 = int(floor(3*pos.y/widths[side]));",
    "   int stroke = int(floor(2*pos.y/widths[side]));",
    "   bool topleft = side == TOP || side == LEFT;",
    "   if (!topleft) stroke = abs(1 - stroke);",
    "   if (styles[side] == SOLID) fcolour = colours[side];",
    "   else if (styles[side] == DASHED)",
    "       fcolour = segment % 2 == 0 ? colours[side] : vec4(0);",


@@ 66,6 69,14 @@ borderFragmentShader = B8.pack $ unlines [
    "       fcolour = distance(pos, dotCenter) < widths[side]/2 ?",
    "               colours[side] : vec4(0);",
    "   else if (styles[side] == DOUBLE && stroke3 != 1) fcolour = colours[side];",
    "   else if (styles[side] == GROOVE)",
    "       fcolour = colours[side] + vec4(stroke == 0 ? -0.1 : +0.1);",
    "   else if (styles[side] == RIDGE)",
    "       fcolour = colours[side] + vec4(stroke == 0 ? +0.1 : -0.1);",
    "   else if (styles[side] == INSET)",
    "       fcolour = colours[side] + vec4(topleft ? -0.2 : +0.2);",
    "   else if (styles[side] == OUTSET)",
    "       fcolour = colours[side] + vec4(topleft ? +0.2 : -0.2);",
    "   else fcolour = vec4(0.0);",
    "}"
  ]

M lib/Graphics/Rendering/Rect/CSS/Border.hs => lib/Graphics/Rendering/Rect/CSS/Border.hs +1 -1
@@ 72,7 72,7 @@ instance PropertyParser Border where
    longhand _ self@Border { borderPallet = cc } "border-bottom-color" ts
        | Just ([], v) <- parseColour cc ts = Just self { bottomColour' = Just v }
    longhand _ self@Border { borderPallet = cc } "border-left-color" ts
        | Just ([], v) <- parseColour cc ts = Just self { bottomColour' = Just v }
        | Just ([], v) <- parseColour cc ts = Just self { leftColour' = Just v }

    -- Should be handled by caller, but for the sake of shorthands...
    longhand _ self "border-top-width" [Dimension _ _ "px"] = Just self