locTopleft :: (Axis a) => LocSpec a -> (a, a) -> Point a
locTopleft loc (w, h) =
  case loc of
    LocTopleft p -> p
    LocTopright (Point x y) -> Point (x - w) y
    LocMidleft (Point x y) -> Point x (y - half h)
    LocCenter (Point x y) -> Point (x - half w) (y - half h)
    LocMidright (Point x y) -> Point (x - w) (y - half h)
    LocBottomleft (Point x y) -> Point x (y - h)
    LocBottomright (Point x y) -> Point (x - w) (y - h)
locTopleft :: (Axis a) => LocSpec a -> (a, a) -> Point a
locTopleft loc (w, h) =
  case loc of
    LocTopleft p -> p
    LocTopright (Point x y) -> Point (x - w) y
    LocMidleft (Point x y) -> Point x (y - half h)
    LocCenter (Point x y) -> Point (x - half w) (y - half h)
    LocMidright (Point x y) -> Point (x - w) (y - half h)
    LocBottomleft (Point x y) -> Point x (y - h)
    LocBottomright (Point x y) -> Point (x - w) (y - h)
locTopleft loc (w, h) =
  case loc of
    LocTopleft p -> p
    LocTopright (Point x y) -> Point (x - w) y
    LocMidleft (Point x y) -> Point x (y - half h)
    LocCenter (Point x y) -> Point (x - half w) (y - half h)
    LocMidright (Point x y) -> Point (x - w) (y - half h)
    LocBottomleft (Point x y) -> Point x (y - h)
    LocBottomright (Point x y) -> Point (x - w) (y - h)