Copyright | (c) Alexey Kuleshevich 2019-2020 |
---|---|
License | BSD3 |
Maintainer | Alexey Kuleshevich <lehins@yandex.ru> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- newtype Pixel cs e where
- Pixel (Color cs e)
- pattern PixelY :: e -> Pixel (Y i) e
- pattern PixelXYZ :: e -> e -> e -> Pixel (XYZ i) e
- pattern PixelLAB :: e -> e -> e -> Pixel (LAB i) e
- pattern PixelRGB :: RedGreenBlue cs (i :: k) => e -> e -> e -> Pixel (cs l) e
- pattern PixelHSI :: e -> e -> e -> Pixel (HSI cs) e
- pattern PixelHSL :: e -> e -> e -> Pixel (HSL cs) e
- pattern PixelHSV :: e -> e -> e -> Pixel (HSV cs) e
- pattern PixelCMYK :: e -> e -> e -> e -> Pixel (CMYK cs) e
- pattern PixelY'CbCr :: e -> e -> e -> Pixel (Y'CbCr cs) e
- pattern PixelY' :: e -> Pixel (Y' cs) e
- pattern PixelYA :: e -> e -> Pixel (Alpha (Y i)) e
- pattern PixelXYZA :: e -> e -> e -> e -> Pixel (Alpha (XYZ i)) e
- pattern PixelLABA :: e -> e -> e -> e -> Pixel (Alpha (LAB i)) e
- pattern PixelRGBA :: RedGreenBlue cs i => e -> e -> e -> e -> Pixel (Alpha (cs l)) e
- pattern PixelHSIA :: e -> e -> e -> e -> Pixel (Alpha (HSI cs)) e
- pattern PixelHSLA :: e -> e -> e -> e -> Pixel (Alpha (HSL cs)) e
- pattern PixelHSVA :: e -> e -> e -> e -> Pixel (Alpha (HSV cs)) e
- pattern PixelCMYKA :: e -> e -> e -> e -> e -> Pixel (Alpha (CMYK cs)) e
- pattern PixelY'CbCrA :: e -> e -> e -> e -> Pixel (Alpha (Y'CbCr cs)) e
- pattern PixelY'A :: e -> e -> Pixel (Alpha (Y' cs)) e
- liftPixel :: (Color cs e -> Color cs' e') -> Pixel cs e -> Pixel cs' e'
- pixelColor :: Pixel cs e -> Color cs e
- convertPixel :: forall cs i e cs' i' e'. (ColorSpace cs' i' e', ColorSpace cs i e) => Pixel cs' e' -> Pixel cs e
- toPixelY :: ColorSpace cs i e => Pixel cs e -> Pixel (Y i) e
- toPixelXYZ :: (ColorSpace cs i e, Elevator a, RealFloat a) => Pixel cs e -> Pixel (XYZ i) a
- fromPixelXYZ :: (ColorSpace cs i e, Elevator a, RealFloat a) => Pixel (XYZ i) a -> Pixel cs e
- toPixelBaseSpace :: (ColorSpace cs i e, bcs ~ BaseSpace cs, ColorSpace bcs i e) => Pixel cs e -> Pixel bcs e
- fromPixelBaseSpace :: (ColorSpace cs i e, bcs ~ BaseSpace cs, ColorSpace bcs i e) => Pixel bcs e -> Pixel cs e
- toPixelBaseModel :: ColorSpace cs i e => Pixel cs e -> Pixel (BaseModel cs) e
- fromPixelBaseModel :: ColorSpace cs i e => Pixel (BaseModel cs) e -> Pixel cs e
- toPixel8 :: ColorModel cs e => Pixel cs e -> Pixel cs Word8
- toPixel16 :: ColorModel cs e => Pixel cs e -> Pixel cs Word16
- toPixel32 :: ColorModel cs e => Pixel cs e -> Pixel cs Word32
- toPixel64 :: ColorModel cs e => Pixel cs e -> Pixel cs Word64
- toPixelF :: ColorModel cs e => Pixel cs e -> Pixel cs Float
- toPixelD :: ColorModel cs e => Pixel cs e -> Pixel cs Double
- toPixelLinearRGB :: (RedGreenBlue cs i, RealFloat e) => Pixel (cs 'NonLinear) e -> Pixel (cs 'Linear) e
- fromPixelLinearRGB :: (RedGreenBlue cs i, RealFloat e) => Pixel (cs 'Linear) e -> Pixel (cs 'NonLinear) e
- pattern PixelSRGB :: e -> e -> e -> Pixel (SRGB 'NonLinear) e
- pattern PixelSRGBA :: e -> e -> e -> e -> Pixel (Alpha (SRGB 'NonLinear)) e
- rgbPixelLuma :: forall cs i e' e. (Luma cs, RedGreenBlue cs i, Elevator e', Elevator e, RealFloat e) => Pixel (cs 'NonLinear) e' -> Pixel (Y' cs) e
- module Graphics.Color.Space
- module Graphics.Color.Algebra.Binary
Documentation
Digital imaging is one of the most common places for a color to be used in. The smallest element in any image is a pixel, which is defined by its color.
Since: 0.1.0
pattern PixelY :: e -> Pixel (Y i) e | Constructor for a pixel with Luminance Since: 0.1.0 |
pattern PixelXYZ :: e -> e -> e -> Pixel (XYZ i) e | Constructor for a pixel in Since: 0.1.0 |
pattern PixelLAB :: e -> e -> e -> Pixel (LAB i) e | Constructor for a pixel in Since: 0.3.0 |
pattern PixelRGB :: RedGreenBlue cs (i :: k) => e -> e -> e -> Pixel (cs l) e | Constructor for a pixel in RGB color space. Since: 0.1.0 |
pattern PixelHSI :: e -> e -> e -> Pixel (HSI cs) e | Constructor for a pixel in Since: 0.1.0 |
pattern PixelHSL :: e -> e -> e -> Pixel (HSL cs) e | Constructor for a pixel in Since: 0.1.0 |
pattern PixelHSV :: e -> e -> e -> Pixel (HSV cs) e | Constructor for a pixel in Since: 0.1.0 |
pattern PixelCMYK :: e -> e -> e -> e -> Pixel (CMYK cs) e | Constructor for a pixel in Since: 0.1.0 |
pattern PixelY'CbCr :: e -> e -> e -> Pixel (Y'CbCr cs) e | Constructor for a pixel in Since: 0.1.0 |
pattern PixelY' :: e -> Pixel (Y' cs) e | Constructor for a pixel with Luma (not to be confused with luminance Since: 0.1.4 |
pattern PixelYA :: e -> e -> Pixel (Alpha (Y i)) e | Constructor for a pixel with Luminance and Alpha channel Since: 0.1.0 |
pattern PixelXYZA :: e -> e -> e -> e -> Pixel (Alpha (XYZ i)) e | Constructor for a pixel in Since: 0.1.0 |
pattern PixelLABA :: e -> e -> e -> e -> Pixel (Alpha (LAB i)) e | Constructor for a pixel in Since: 0.3.0 |
pattern PixelRGBA :: RedGreenBlue cs i => e -> e -> e -> e -> Pixel (Alpha (cs l)) e | Constructor for a pixel in RGB color space with Alpha channel Since: 0.1.0 |
pattern PixelHSIA :: e -> e -> e -> e -> Pixel (Alpha (HSI cs)) e | Constructor for a pixel in Since: 0.1.0 |
pattern PixelHSLA :: e -> e -> e -> e -> Pixel (Alpha (HSL cs)) e | Constructor for a pixel in Since: 0.1.0 |
pattern PixelHSVA :: e -> e -> e -> e -> Pixel (Alpha (HSV cs)) e | Constructor for a pixel in Since: 0.1.0 |
pattern PixelCMYKA :: e -> e -> e -> e -> e -> Pixel (Alpha (CMYK cs)) e | Constructor for a pixel in Since: 0.1.0 |
pattern PixelY'CbCrA :: e -> e -> e -> e -> Pixel (Alpha (Y'CbCr cs)) e | Constructor for a pixel in Since: 0.1.0 |
pattern PixelY'A :: e -> e -> Pixel (Alpha (Y' cs)) e | Constructor for a pixel with Luma and Alpha channel (not to be confused with luminance Since: 0.1.4 |
Instances
Conversion
Color space
convertPixel :: forall cs i e cs' i' e'. (ColorSpace cs' i' e', ColorSpace cs i e) => Pixel cs' e' -> Pixel cs e Source #
Convert a pixel from one color space to any other.
>>>
:set -XDataKinds
>>>
:set -XTypeApplications
>>>
px = PixelSRGB @Float 0.0 0.5 1.0
>>>
px
<SRGB 'NonLinear:( 0.00000000, 0.50000000, 1.00000000)>>>>
convertPixel @(AdobeRGB 'NonLinear) @_ @Word8 px
<AdobeRGB 'NonLinear:( 71,127,251)>
Since: 0.1.0
toPixelY :: ColorSpace cs i e => Pixel cs e -> Pixel (Y i) e Source #
Compute luminance of a pixel color
Since: 0.1.0
toPixelXYZ :: (ColorSpace cs i e, Elevator a, RealFloat a) => Pixel cs e -> Pixel (XYZ i) a Source #
Convert to CIE1931 XYZ color space, with the same illuminant as the original.
Since: 0.1.0
fromPixelXYZ :: (ColorSpace cs i e, Elevator a, RealFloat a) => Pixel (XYZ i) a -> Pixel cs e Source #
Convert from CIE1931 XYZ color space, with the same illuminant as the target color space.
Since: 0.1.0
toPixelBaseSpace :: (ColorSpace cs i e, bcs ~ BaseSpace cs, ColorSpace bcs i e) => Pixel cs e -> Pixel bcs e Source #
Convert pixel in an alternative representation of color space, to its base color space. Example from CMYK to SRGB
Since: 0.1.0
fromPixelBaseSpace :: (ColorSpace cs i e, bcs ~ BaseSpace cs, ColorSpace bcs i e) => Pixel bcs e -> Pixel cs e Source #
Covert a color space of a pixel into it's alternative representation. Example AdobeRGB to HSI.
Since: 0.1.0
Color model
toPixelBaseModel :: ColorSpace cs i e => Pixel cs e -> Pixel (BaseModel cs) e Source #
Drop all color space information and only keep the values encoded in the fitting color model, which the color space is backed by.
Since: 0.1.0
fromPixelBaseModel :: ColorSpace cs i e => Pixel (BaseModel cs) e -> Pixel cs e Source #
Promote a pixel without color space information to a color space that is backed by the fitting color model
Since: 0.1.0
Precision
toPixel8 :: ColorModel cs e => Pixel cs e -> Pixel cs Word8 Source #
Convert all channels of a pixel to 8bits each, while doing appropriate scaling. See
Elevator
.
Since: 0.1.0
toPixel16 :: ColorModel cs e => Pixel cs e -> Pixel cs Word16 Source #
Convert all channels of a pixel to 16bits each, while appropriate scaling. See
Elevator
.
Since: 0.1.0
toPixel32 :: ColorModel cs e => Pixel cs e -> Pixel cs Word32 Source #
Convert all channels of a pixel to 32bits each, while doing appropriate scaling. See
Elevator
.
Since: 0.1.0
toPixel64 :: ColorModel cs e => Pixel cs e -> Pixel cs Word64 Source #
Convert all channels of a pixel to 64bits each, while doing appropriate scaling. See
Elevator
.
Since: 0.1.0
toPixelF :: ColorModel cs e => Pixel cs e -> Pixel cs Float Source #
Convert all channels of a pixel to 32bit floating point numers each, while doing
appropriate scaling. See Elevator
.
Since: 0.1.0
toPixelD :: ColorModel cs e => Pixel cs e -> Pixel cs Double Source #
Convert all channels of a pixel to 64bit floating point numers each, while doing
appropriate scaling. See Elevator
.
Since: 0.1.0
RGB
toPixelLinearRGB :: (RedGreenBlue cs i, RealFloat e) => Pixel (cs 'NonLinear) e -> Pixel (cs 'Linear) e Source #
Convert non-linear RGB color space into linear one
Since: 0.2.0
fromPixelLinearRGB :: (RedGreenBlue cs i, RealFloat e) => Pixel (cs 'Linear) e -> Pixel (cs 'NonLinear) e Source #
Convert linear RGB color space into a non-linear one
Since: 0.2.0
sRGB color space
pattern PixelSRGB :: e -> e -> e -> Pixel (SRGB 'NonLinear) e Source #
Constructor for a pixel in sRGB
color space
Since: 0.1.0
pattern PixelSRGBA :: e -> e -> e -> e -> Pixel (Alpha (SRGB 'NonLinear)) e Source #
Constructor for a pixel in sRGB
color space with Alpha channel
Since: 0.1.0
Luma
rgbPixelLuma :: forall cs i e' e. (Luma cs, RedGreenBlue cs i, Elevator e', Elevator e, RealFloat e) => Pixel (cs 'NonLinear) e' -> Pixel (Y' cs) e Source #
Re-export of color space
module Graphics.Color.Space