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 |
RGBA quadruples for an unspecified colour space
Synopsis
- type Colour = RGBA Float
- data RGBA a = RGBA a a a a
- pattern RGBA_ :: (Elt (RGBA a), Elt a, VecElt a, EltR (RGBA a) ~ Vec4 a) => Exp a -> Exp a -> Exp a -> Exp a -> Exp (RGBA a)
- rgba :: Exp Float -> Exp Float -> Exp Float -> Exp Float -> Exp Colour
- rgba8 :: Exp Word8 -> 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
- opacity :: Exp Float -> Exp Colour -> Exp Colour
- opaque :: Exp Colour -> Exp Colour
- transparent :: Exp Colour -> Exp Colour
- packRGBA :: Exp Colour -> Exp Word32
- packABGR :: Exp Colour -> Exp Word32
- unpackRGBA :: Exp Word32 -> Exp Colour
- unpackABGR :: Exp Word32 -> Exp Colour
- packRGBA8 :: Exp (RGBA Word8) -> Exp Word32
- packABGR8 :: Exp (RGBA Word8) -> Exp Word32
- unpackRGBA8 :: Exp Word32 -> Exp (RGBA Word8)
- unpackABGR8 :: Exp Word32 -> Exp (RGBA Word8)
Documentation
An RGBA 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 32-bit BMP image)
RGBA a a a a |
Instances
pattern RGBA_ :: (Elt (RGBA a), Elt a, VecElt a, EltR (RGBA a) ~ Vec4 a) => Exp a -> Exp a -> Exp a -> Exp a -> Exp (RGBA a) Source #
:: Exp Float | red component |
-> Exp Float | green component |
-> Exp Float | blue component |
-> Exp Float | alpha component |
-> Exp Colour |
Construct an RGBA colour from individual channel components. The components will be clamped to the range [0..1].
:: Exp Word8 | red component |
-> Exp Word8 | green component |
-> Exp Word8 | blue component |
-> Exp Word8 | alpha component |
-> Exp Colour |
Construct a colour from 8-bits-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).
opacity :: Exp Float -> Exp Colour -> Exp Colour Source #
Set the opacity of the given colour. The opacity is clamped to the range [0..1].
packRGBA :: Exp Colour -> Exp Word32 Source #
Convert a Colour into a packed-word RGBA representation
packABGR :: Exp Colour -> Exp Word32 Source #
Convert a colour into a packed-word ABGR representation
unpackRGBA :: Exp Word32 -> Exp Colour Source #
Convert a colour from a packed-word RGBA representation