Am Montag, 6. August 2007 00:48 schrieb Frank Buss:
> I've created a small program to compose images with combinators:
> 
> http://www.frank-buss.de/haskell/OlympicRings.hs.txt
> 
...
> look very smooth. And it is very slow, it needs about 40 seconds on my
>computer to calculate the image. Using parametrized combinators sounds like
...


in that source file, you define Size and Pixel as structs of "Integer"s. that 
are neither unsigned chars (8_bit) nor ints (32-64_bit) nor floats (32_bit) but 
an artificial oo_bit int (1 int + list of bytes).
i'm sure you will gain a speedup by redefining these structs. i.e. use Float or 
Int instead of Integer; see Data.Int and Data.Word for more alternatives.

- marc


>
[code snippet from source file]
-- image size
data Size = Size { width :: Integer, height :: Integer }
        deriving (Eq, Ord, Show, Read)

-- RGB components for an image pixel
data Pixel = Pixel { r :: Integer, g :: Integer, b :: Integer }
        deriving (Eq, Ord, Show, Read)

-- helper functions for saving bytes
writeByte byte = putWord8 (fromIntegral byte)
writeBytes bytes = mapM_ putWord8 bytes

-- binary instance for saving Pixels
instance Binary Pixel where
        put (Pixel r g b) = do
                writeByte b
                writeByte g
                writeByte r
        get = error "Pixel get not supported"

[/code]

Attachment: pgpFEOkZiYO8o.pgp
Description: PGP signature

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to