Puregrain.Pixel
- Package
- purescript-puregrain
- Repository
- roman-mkh/puregrain
Pixel types: a single gray channel (Gray, a plain Number), RGB
and RGBA, with channel values on the 0–255 scale by convention.
Error diffusion adds and subtracts error, so a pixel type must be a
Ring, and Scalable by the kernel's Number weights. MapChannels
lets a one-channel quantizer work on every channel of a pixel (see
Puregrain.Quantize.perChannel), and ColorChannels lets a pixel be
converted to light and back, alpha excepted (see Puregrain.Gamma).
#RGB Source
newtype RGBA color pixel: red, green and blue, each from 0 to 255 by convention. Adds, subtracts and scales channel by channel, as error diffusion needs.
Constructors
Instances
#RGBA Source
newtype RGBAA color pixel with alpha: as RGB, plus a, which error diffusion
treats like the other channels.
Constructors
Instances
Semiring RGBARing RGBAScalable RGBAMapChannels RGBAAlpha too, like the other channels, as in the
RingandScalableinstances.ColorChannels RGBARed, green and blue; alpha stays as it is.
#Scalable Source
class (Ring a) <= Scalable a whereA pixel type that error diffusion can scale by a kernel's weights.
With Ring, for adding and subtracting error, it's what ditherImage
needs from a pixel type.
Members
scale :: Number -> a -> aMultiplies every channel by a weight.
Number: the weight, a kernel's share of the error.a: the pixel.
Instances
#MapChannels Source
class MapChannels a whereA pixel type whose channels can be mapped one by one: what
Puregrain.Quantize.perChannel needs to run a one-channel quantizer
on every channel. Laws, as for any functor-like mapping:
mapChannels identity == identity
mapChannels (f <<< g) == mapChannels f <<< mapChannels g
Members
mapChannels :: (Number -> Number) -> a -> aApplies the function to every channel, independently.
Number -> Number: the function for one channel.a: the pixel.
Instances
MapChannels NumberA gray pixel is its one channel:
perChannelonNumberis the quantizer itself.MapChannels RGBMapChannels RGBAAlpha too, like the other channels, as in the
RingandScalableinstances.
#ColorChannels Source
class ColorChannels a whereA pixel type whose color channels can be mapped one by one, leaving
any other channel as it is: what converting a pixel between stored
values and light needs (Puregrain.Gamma.toLight and fromLight),
since alpha isn't on a light curve. Laws, as for MapChannels:
mapColorChannels identity == identity
mapColorChannels (f <<< g) == mapColorChannels f <<< mapColorChannels g
Members
mapColorChannels :: (Number -> Number) -> a -> aApplies the function to every color channel, independently.
Number -> Number: the function for one channel.a: the pixel.
Instances
ColorChannels NumberA gray pixel is its one color channel.
ColorChannels RGBColorChannels RGBARed, green and blue; alpha stays as it is.
- Modules
- Puregrain
- Puregrain.
Cells - Puregrain.
Dither - Puregrain.
Gamma - Puregrain.
Internal. Exact - Puregrain.
Internal. Fifo - Puregrain.
Internal. Gamma - Puregrain.
Internal. Image - Puregrain.
Internal. Kernel - Puregrain.
Internal. Quantize - Puregrain.
Internal. Row - Puregrain.
Internal. SelfCheck - Puregrain.
Internal. State - Puregrain.
Internal. Step - Puregrain.
Internal. Util - Puregrain.
Kernel - Puregrain.
Machine. C64 - Puregrain.
Machine. ZxSpectrum - Puregrain.
Ordered - Puregrain.
Palette - Puregrain.
Palette. Presets - Puregrain.
Pixel - Puregrain.
Quantize - Puregrain.
SelfCheck
Compared and shown like the record inside.