 {-#LANGUAGE ForeignFunctionInterface, TypeFamilies, MultiParamTypeClasses, TypeSynonymInstances#-}
 #include "cvWrapLEO.h"
+-- | Module for exposing opencv drawing functions. These are meant for quick and dirty marking
+--   and not for anything presentable. For any real drawing
+--   you should figure out how to use cairo or related package, such as diagrams. They are
+--   way better.
+--
+--   Consult the "CV.ImageOp" module for functions to apply the operations in this module to images.
 
-module CV.Drawing(ShapeStyle(Filled,Stroked),circle
-              ,Drawable(..)
-              ,floodfill,drawLinesOp,drawLines,rectangle
-              ,rectOpS,fillPoly) where
+module CV.Drawing(
+                -- * Drawable class
+                 ShapeStyle(Filled,Stroked)
+                ,Drawable(..)
+                -- * Extra drawing operations
+                ,drawLinesOp
+                ,rectOpS
+                -- * Floodfill operations
+                ,fillOp
+                ,floodfill
+                -- * Shorthand for drawing single shapes
+                ,circle
+                ,drawLines
+                ,rectangle
+                ,fillPoly) where
 
 import Foreign.Ptr
 import Foreign.C.Types


import CV.ImageOp

data ShapeStyle = Filled | Stroked Int
    deriving(Eq,Show)

styleToCV Filled = -1
styleToCV (Stroked w) = fromIntegral w

-- TODO: Add fillstyle for rectOp


-- TODO: The instances in here could be significantly smaller..
class Drawable a b where
    type Color a b :: * 
    putTextOp :: (Color a b) -> Float -> String -> (Int,Int) -> ImageOperation a b
    lineOp :: (Color a b)   -> Int -> (Int,Int) -> (Int,Int) -> ImageOperation a b
    circleOp :: (Color a b) -> (Int,Int) -> Int -> ShapeStyle -> ImageOperation a b
    rectOp   :: (Color a b) -> Int -> (Int,Int) -> (Int,Int)  -> ImageOperation a b
    fillPolyOp :: (Color a b) -> [(Int,Int)] -> ImageOperation a b

instance Drawable RGB D32 where

                                  free ys'


-- | Draw a rectangle by giving top left corner and size.
rectOpS :: Drawable a b => Color a b -> Int -> (Int, Int) -> (Int, Int) 
            -> ImageOperation a b
rectOpS c t pos@(x,y) (w,h) = rectOp c t pos (x+w,y+h)

-- | Flood fill a region of the image
fillOp :: (Int,Int) -> D32 -> D32 -> D32 -> Bool -> ImageOperation GrayScale D32
fillOp (x,y) color low high floats = 
    ImgOp $ \i -> do
