Copyright | [2016..2020] Trevor L. McDonell |
---|---|
License | BSD3 |
Maintainer | Trevor L. McDonell <trevor.mcdonell@gmail.com> |
Stability | experimental |
Portability | non-portable (GHC extensions) |
Safe Haskell | None |
Language | Haskell2010 |
RGB triples for an unspecified colour space
Synopsis
- type Colour = RGB Float
- data RGB a = RGB a a a
- pattern RGB_ :: (Elt (RGB a), Elt a, VecElt a, EltR (RGB a) ~ Vec3 a) => Exp a -> Exp a -> Exp a -> Exp (RGB a)
- rgb :: Exp Float -> Exp Float -> Exp Float -> Exp Colour
- rgb8 :: Exp Word8 -> Exp Word8 -> Exp Word8 -> Exp Colour
- clamp :: Exp Colour -> Exp Colour
- blend :: Exp Float -> Exp Float -> Exp Colour -> Exp Colour -> Exp Colour
- luminance :: Exp Colour -> Exp Float
- packRGB :: Exp Colour -> Exp Word32
- packBGR :: Exp Colour -> Exp Word32
- unpackRGB :: Exp Word32 -> Exp Colour
- unpackBGR :: Exp Word32 -> Exp Colour
- packRGB8 :: Exp (RGB Word8) -> Exp Word32
- packBGR8 :: Exp (RGB Word8) -> Exp Word32
- unpackRGB8 :: Exp Word32 -> Exp (RGB Word8)
- unpackBGR8 :: Exp Word32 -> Exp (RGB Word8)
Documentation
An RGB colour value to hold the colour components. All components lie in the range [0..1] for floating point values, or [0..255] for byte values.
Colours in the floating point representation are stored in the usual unzipped struct-of-array representation. Colours with Word8 components are stored in a packed array-of-struct representation, which is typically more convenient when exporting the data (e.g. as a 24-bit BMP image).
RGB a a a |
Instances
pattern RGB_ :: (Elt (RGB a), Elt a, VecElt a, EltR (RGB a) ~ Vec3 a) => Exp a -> Exp a -> Exp a -> Exp (RGB a) Source #
Construct an RGB colour from individual channel components. The components will be clamped to the range [0..1].
Construct a colour from 8-bit-per-channel colour components.
:: Exp Float | Proportion of first colour |
-> Exp Float | Proportion of second colour |
-> Exp Colour | First colour |
-> Exp Colour | Second colour |
-> Exp Colour | Resulting colour |
Blend two colours in the given proportions.
Note that this uses an approximation of gamma=2 (i.e. sum-of-squares method). It is recommended to instead convert to the sRGB colour space if you want more accurate colour blending, or if you intend to use the gamma-corrected values more than once (e.g. in a stencil).
blend c1 c2 ~= SRGB.toRGB ( (SRGB.fromRGB c1 + SRGB.fromRGB c2) / 2 )
See the Blur program in the examples for a comparison of mixing colours in the RGB and sRGB colour spaces.
luminance :: Exp Colour -> Exp Float Source #
Luminance of an RGB colour (Y component of a YUV colour).
unpackRGB :: Exp Word32 -> Exp Colour Source #
Convert a colour from a packed-word RGBA representation