-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Efficient RGB colour types. -- -- This Haskell library is a basic RGB colour types, with both -- Double and Word8 channel types. It implements -- efficient conversions between the two (GHC-specific), and general -- arithmetic over colours. Changes: * Now works with GHC 6.12.x. @package AC-Colour @version 1.1.2 -- | This module shouldn't need to exist. It exists because GHC's -- implementation of floor is currently (6.10.3) very slow. See -- the following tickets: -- -- http://hackage.haskell.org/trac/ghc/ticket/1434 -- -- http://hackage.haskell.org/trac/ghc/ticket/2271 module Data.Colour.FastFloor -- | This is a special version of the regular floor function. It -- works by directly calling the low-level internal GHC primitives, and -- thus is as fast as you'd expect for such a trivial operation. -- -- (The standard floor function does something crazy like -- converting a Double to a numerator/denominator -- Integer pair and then computing the integer part of the -- quotient as an Integer, then truncating that to a -- Word8. Which, obviously, is ludicrously slow.) -- -- Hopefully one day the need for this low-level hackery will disappear. fast_floor :: Double -> Word8 -- | This module provides Colour8, which stores RGB (red, green, -- blue) colour values where each channel is a Word8. It also -- provides arithmetic over such colours, and a few predefined colours. -- -- It is the general intention that "most" work will be done with -- Data.Colour.Double, with values converted to Colour8 -- only as a final step. However, full arithmetic is supported anyway, in -- case anybody wants to work that way. It is slightly less efficient and -- flexible, however. module Data.Colour.Word8 -- | The Colour type. Stores a red, a green and a blue component -- as strict, unboxed Word8 values. (So it should be quite -- efficient in time and space.) Also provides various class instances -- for arithmetic, etc. -- -- Note that 0x00 is assumed to mean zero, and 0xFF to mean one. That -- means that (*) is slightly slower than you might expect due -- to the extra steps required for renormalisation; (+) and -- (-) are still efficient, however. data Colour8 Colour8 :: !!Word8 -> !!Word8 -> !!Word8 -> Colour8 red8 :: Colour8 -> !!Word8 green8 :: Colour8 -> !!Word8 blue8 :: Colour8 -> !!Word8 -- | Apply a function to every channel of a Colour8. (Mostly used -- internally; exposed here in case it might be useful.) c8map :: (Word8 -> Word8) -> Colour8 -> Colour8 -- | The colour equivilent of Data.List.zipWith. (Mostly used -- internally; exposed here in case it might be useful.) c8zip :: (Word8 -> Word8 -> Word8) -> Colour8 -> Colour8 -> Colour8 -- | Use a function to fold the three values in a Colour8 into a -- single value. No particular order of application is promised. c8fold :: (Word8 -> Word8 -> Word8) -> Colour8 -> Word8 -- | Convert a Word8 into a shade of grey. grey8 :: Word8 -> Colour8 -- | Scale a Colour8 by the specified amount. Recall that 0x00 -- means zero, and 0xFF means one. This means that it is impossible to -- make a colour brighter, only darker. It also means this -- operation is modestly inefficient due to the renormalisation steps. c8scale :: Word8 -> Colour8 -> Colour8 -- | Constant: Black. c8Black :: Colour8 -- | Constant: Red. c8Red :: Colour8 -- | Constant: Yellow. c8Yellow :: Colour8 -- | Constant: Green. c8Green :: Colour8 -- | Constant: Cyan. c8Cyan :: Colour8 -- | Constant: Blue. c8Blue :: Colour8 -- | Constant: Magenta. c8Magenta :: Colour8 -- | Constant: White. c8White :: Colour8 instance Eq Colour8 instance Ord Colour8 instance Show Colour8 instance Num Colour8 -- | This module provides Colour, which stores RGB (red, green, -- blue) colour values where each channel is a Double. It also -- provides arithmetic over such colours, and a few predefined colours. module Data.Colour.Double -- | The Colour type. Stores a red, a green and a blue component -- as strict, unboxed Double values. (So it should be quite -- efficient in time and space.) Also provides various class instances -- for arithmetic, etc. It is generally assumed that each channel will -- have a value somewhere between 0 and 1 at all times. -- -- Note that (*) acts channel-wise. This is usually what is -- wanted. data Colour Colour :: !!Double -> !!Double -> !!Double -> Colour red :: Colour -> !!Double green :: Colour -> !!Double blue :: Colour -> !!Double -- | Apply a function to every channel in a colour. (Mostly used -- internally, but exposed here in case it may be useful.) cmap :: (Double -> Double) -> Colour -> Colour -- | This is similar to Data.List.zipWith. (Mostly used -- internally, but exposed here in case it may be useful.) czip :: (Double -> Double -> Double) -> Colour -> Colour -> Colour -- | Use a function to collapse a Colour into a Double. -- No particular order of application is promised. cfold :: (Double -> Double -> Double) -> Colour -> Double -- | Turn a Double into a shade of grey. grey :: Double -> Colour -- | Scale a Colour by a specified amount. (That is, change the -- brightness while not affecting the shade.) cscale :: Double -> Colour -> Colour -- | Take a Colour and clip all channels to the range 0--1 -- inclusive. Any value outside that range will be replaced with the -- nearest endpoint (i.e., 0 for negative numbers, 1 for positive numbers -- higher than 1). Values inside the range are unaffected. clip :: Colour -> Colour -- | Constant: Black. cBlack :: Colour -- | Constant: Red. cRed :: Colour -- | Constant: Yellow. cYellow :: Colour -- | Constant: Green. cGreen :: Colour -- | Constant: Cyan. cCyan :: Colour -- | Constant: Blue. cBlue :: Colour -- | Constant: Magenta. cMagenta :: Colour -- | Constant: White. cWhite :: Colour instance Eq Colour instance Ord Colour instance Show Colour instance Fractional Colour instance Num Colour -- | This module exports all the main interesting parts of the various -- colour modules. It also provides functions for converting between -- Colour and Colour8. -- -- It is the general intention that "most" work will be done with -- Colour, with values converted to Colour8 only as a -- final step. However, full arithmetic on Colour8 is supported -- anyway, in case anybody wants to work that way. It is slightly less -- efficient and flexible, however. module Data.Colour -- | The Colour type. Stores a red, a green and a blue component -- as strict, unboxed Double values. (So it should be quite -- efficient in time and space.) Also provides various class instances -- for arithmetic, etc. It is generally assumed that each channel will -- have a value somewhere between 0 and 1 at all times. -- -- Note that (*) acts channel-wise. This is usually what is -- wanted. data Colour Colour :: !!Double -> !!Double -> !!Double -> Colour red :: Colour -> !!Double green :: Colour -> !!Double blue :: Colour -> !!Double -- | Turn a Double into a shade of grey. grey :: Double -> Colour -- | Scale a Colour by a specified amount. (That is, change the -- brightness while not affecting the shade.) cscale :: Double -> Colour -> Colour -- | Take a Colour and clip all channels to the range 0--1 -- inclusive. Any value outside that range will be replaced with the -- nearest endpoint (i.e., 0 for negative numbers, 1 for positive numbers -- higher than 1). Values inside the range are unaffected. clip :: Colour -> Colour -- | Constant: Black. cBlack :: Colour -- | Constant: White. cWhite :: Colour -- | Constant: Red. cRed :: Colour -- | Constant: Yellow. cYellow :: Colour -- | Constant: Green. cGreen :: Colour -- | Constant: Cyan. cCyan :: Colour -- | Constant: Blue. cBlue :: Colour -- | Constant: Magenta. cMagenta :: Colour -- | The Colour type. Stores a red, a green and a blue component -- as strict, unboxed Word8 values. (So it should be quite -- efficient in time and space.) Also provides various class instances -- for arithmetic, etc. -- -- Note that 0x00 is assumed to mean zero, and 0xFF to mean one. That -- means that (*) is slightly slower than you might expect due -- to the extra steps required for renormalisation; (+) and -- (-) are still efficient, however. data Colour8 Colour8 :: !!Word8 -> !!Word8 -> !!Word8 -> Colour8 red8 :: Colour8 -> !!Word8 green8 :: Colour8 -> !!Word8 blue8 :: Colour8 -> !!Word8 -- | Convert a Word8 into a shade of grey. grey8 :: Word8 -> Colour8 -- | Scale a Colour8 by the specified amount. Recall that 0x00 -- means zero, and 0xFF means one. This means that it is impossible to -- make a colour brighter, only darker. It also means this -- operation is modestly inefficient due to the renormalisation steps. c8scale :: Word8 -> Colour8 -> Colour8 -- | Constant: Black. c8Black :: Colour8 -- | Constant: White. c8White :: Colour8 -- | Constant: Red. c8Red :: Colour8 -- | Constant: Yellow. c8Yellow :: Colour8 -- | Constant: Green. c8Green :: Colour8 -- | Constant: Cyan. c8Cyan :: Colour8 -- | Constant: Blue. c8Blue :: Colour8 -- | Constant: Magenta. c8Magenta :: Colour8 -- | Convert a Colour8 into a Colour. Recall that 0x00 means -- zero and 0xFF means one; this function will remap such values -- appropriately. cpromote :: Colour8 -> Colour -- | Convert a Colour into a Colour8. Any values outside the -- range 0--1 will be wrapped to that range. You may want to run -- clip before calling this function to prevent this behaviour -- (unless you know the values can't be outside the permitted range). -- This function is the exact inverse of cpromote; 0 is mapped to -- 0x00 and 1 is mapped to 0xFF. cdemote :: Colour -> Colour8