{-# LANGUAGE BangPatterns #-}

module Vision.Primitive (
      module Vision.Primitive.Shape
    , Point, Size, Rect (..), RPoint (..)
    ) where

import Data.RatioInt (RatioInt)

import Vision.Primitive.Shape

-- | Coordinates inside the image.
--
-- Can be constructed using 'ix2'. The first parameter is the y coordinate while
-- the second is the x coordinate (i.e. @'ix2' y x@). Image origin (@'ix2' 0 0@)
-- is located in the upper left corner.
type Point = DIM2

-- | Size of an object.
--
-- Can be constructed using 'ix2'. The first parameter is the height while the
-- second is the width (i.e. @ix2 h w@).
type Size = DIM2

data Rect = Rect {
      Rect -> Int
rX     :: {-# UNPACK #-} !Int, Rect -> Int
rY      :: {-# UNPACK #-} !Int
    , Rect -> Int
rWidth :: {-# UNPACK #-} !Int, Rect -> Int
rHeight :: {-# UNPACK #-} !Int
    } deriving (Int -> Rect -> ShowS
[Rect] -> ShowS
Rect -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Rect] -> ShowS
$cshowList :: [Rect] -> ShowS
show :: Rect -> String
$cshow :: Rect -> String
showsPrec :: Int -> Rect -> ShowS
$cshowsPrec :: Int -> Rect -> ShowS
Show, ReadPrec [Rect]
ReadPrec Rect
Int -> ReadS Rect
ReadS [Rect]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Rect]
$creadListPrec :: ReadPrec [Rect]
readPrec :: ReadPrec Rect
$creadPrec :: ReadPrec Rect
readList :: ReadS [Rect]
$creadList :: ReadS [Rect]
readsPrec :: Int -> ReadS Rect
$creadsPrec :: Int -> ReadS Rect
Read, Rect -> Rect -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Rect -> Rect -> Bool
$c/= :: Rect -> Rect -> Bool
== :: Rect -> Rect -> Bool
$c== :: Rect -> Rect -> Bool
Eq, Eq Rect
Rect -> Rect -> Bool
Rect -> Rect -> Ordering
Rect -> Rect -> Rect
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Rect -> Rect -> Rect
$cmin :: Rect -> Rect -> Rect
max :: Rect -> Rect -> Rect
$cmax :: Rect -> Rect -> Rect
>= :: Rect -> Rect -> Bool
$c>= :: Rect -> Rect -> Bool
> :: Rect -> Rect -> Bool
$c> :: Rect -> Rect -> Bool
<= :: Rect -> Rect -> Bool
$c<= :: Rect -> Rect -> Bool
< :: Rect -> Rect -> Bool
$c< :: Rect -> Rect -> Bool
compare :: Rect -> Rect -> Ordering
$ccompare :: Rect -> Rect -> Ordering
Ord)

-- | Rational coordinates used for interpolations.
data RPoint = RPoint {
      RPoint -> RatioInt
rpX :: {-# UNPACK #-} !RatioInt, RPoint -> RatioInt
rpY :: {-# UNPACK #-} !RatioInt
    } deriving (Int -> RPoint -> ShowS
[RPoint] -> ShowS
RPoint -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RPoint] -> ShowS
$cshowList :: [RPoint] -> ShowS
show :: RPoint -> String
$cshow :: RPoint -> String
showsPrec :: Int -> RPoint -> ShowS
$cshowsPrec :: Int -> RPoint -> ShowS
Show, ReadPrec [RPoint]
ReadPrec RPoint
Int -> ReadS RPoint
ReadS [RPoint]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RPoint]
$creadListPrec :: ReadPrec [RPoint]
readPrec :: ReadPrec RPoint
$creadPrec :: ReadPrec RPoint
readList :: ReadS [RPoint]
$creadList :: ReadS [RPoint]
readsPrec :: Int -> ReadS RPoint
$creadsPrec :: Int -> ReadS RPoint
Read, RPoint -> RPoint -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RPoint -> RPoint -> Bool
$c/= :: RPoint -> RPoint -> Bool
== :: RPoint -> RPoint -> Bool
$c== :: RPoint -> RPoint -> Bool
Eq, Eq RPoint
RPoint -> RPoint -> Bool
RPoint -> RPoint -> Ordering
RPoint -> RPoint -> RPoint
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: RPoint -> RPoint -> RPoint
$cmin :: RPoint -> RPoint -> RPoint
max :: RPoint -> RPoint -> RPoint
$cmax :: RPoint -> RPoint -> RPoint
>= :: RPoint -> RPoint -> Bool
$c>= :: RPoint -> RPoint -> Bool
> :: RPoint -> RPoint -> Bool
$c> :: RPoint -> RPoint -> Bool
<= :: RPoint -> RPoint -> Bool
$c<= :: RPoint -> RPoint -> Bool
< :: RPoint -> RPoint -> Bool
$c< :: RPoint -> RPoint -> Bool
compare :: RPoint -> RPoint -> Ordering
$ccompare :: RPoint -> RPoint -> Ordering
Ord)