module GEGL.Color
( FFI.GeglColor
, Color(..)
, gegl_color_new
, gegl_color_set_rgba
) where
import Foreign.C.Types (CInt, CDouble(..))
import Foreign.C.String (withCString)
import Foreign.Ptr (Ptr)
import qualified GEGL.FFI.Color as FFI
data Color = RGB Double Double Double
| RGBA Double Double Double Double
instance Show Color where
show (RGB r g b) = "rgb(" ++ show r ++ "," ++ show g ++ "," ++ show b ++ ")"
show (RGBA r g b a) = "rgba(" ++ show r ++ "," ++ show g ++ "," ++ show b ++ "," ++ show a ++ ")"
gegl_color_new :: Color -> IO FFI.GeglColor
gegl_color_new (RGB r g b) = FFI.GeglColor <$> withCString
(show $ RGB r g b) FFI.c_gegl_color_new
gegl_color_new (RGBA r g b a) = FFI.GeglColor <$> withCString
(show $ RGBA r g b a) FFI.c_gegl_color_new
gegl_color_set_rgba :: FFI.GeglColor -> Color -> IO ()
gegl_color_set_rgba (FFI.GeglColor col) (RGBA r g b a) =
FFI.c_gegl_color_set_rgba col (CDouble r) (CDouble g) (CDouble b) (CDouble a)