~alcinnz/Mondrian

b81c9e69d221df1bada189ac34d2bb8e95fa49d7 — Adrian Cochrane 1 year, 5 months ago 7564554
Add dashed, dotted, & double border styles!
1 files changed, 11 insertions(+), 1 deletions(-)

M lib/Graphics/Rendering/Rect/Border.hs
M lib/Graphics/Rendering/Rect/Border.hs => lib/Graphics/Rendering/Rect/Border.hs +11 -1
@@ 53,9 53,19 @@ borderFragmentShader = B8.pack $ unlines [
    "",
    "   vec2 pos = coord;",
    "   if (side == RIGHT || side == BOTTOM) pos = boxSize - coord;",
    "   if (side == TOP || side == BOTTOM) pos = pos.xy;",
    "   if (side == LEFT || side == RIGHT) pos = pos.yx;",
    "",
    "   int segment = int(floor(pos.x/widths[side]/2));",
    "   float width = widths[side];",
    "   vec2 dotCenter = vec2(segment*width*2 + width, width/2);",
    "   int stroke3 = int(floor(3*pos.y/widths[side]));",
    "   if (styles[side] == SOLID) fcolour = colours[side];",
    "   else if (styles[side] == DASHED)",
    "       fcolour = segment % 2 == 0 ? colours[side] : vec4(0);",
    "   else if (styles[side] == DOTTED)",
    "       fcolour = distance(pos, dotCenter) < widths[side]/2 ?",
    "               colours[side] : vec4(0);",
    "   else if (styles[side] == DOUBLE && stroke3 != 1) fcolour = colours[side];",
    "   else fcolour = vec4(0.0);",
    "}"
  ]