Graphics hierarchy

Ashley Yakeley ashley@semantic.org
Wed, 27 Feb 2002 01:20:38 -0800


At 2002-02-27 01:07, Ketil Z. Malde wrote:

>-- probably elsewhere in the hierarchy
>class FileFormat a where
>        encode :: a -> [Word8]
>        decode :: [Word8] -> a
>
>
>instance FileFormat PNG where
>        encode = ...
>        decode = ..

I prefer ML-style structures/functors in this particular instance:

data FileFormat a = MkFileFormat
     {
     encodeFile :: a -> [Word8],
     decodeFile :: [Word8] -> Maybe a
     };

formatPNG :: (Image img) => FileFormat img;

formatJPEG :: (Image img) => JPEGCompressionFactor -> FileFormat img;

formatUTF8 :: FileFormat String;

>class Image a where
>        rotate :: a -> Int -> a
>        scale :: a -> Int -> Int -> a
>        
>Maybe compose/blend images?  Altering alpha and gamma, color
>manipulation?

Sounds like a serious project, with the possibility of plenty of 
complication.

-- 
Ashley Yakeley, Seattle WA