Color-0.3.3: Color spaces and conversions between them
Copyright(c) Alexey Kuleshevich 2019-2020
LicenseBSD3
MaintainerAlexey Kuleshevich <lehins@yandex.ru>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Graphics.Color.Algebra

Contents

Description

 
Synopsis

2D

data V2 a Source #

A 2D vector with x and y coordinates.

Constructors

V2 !a !a 

Instances

Instances details
Functor V2 Source # 
Instance details

Defined in Graphics.Color.Algebra

Methods

fmap :: (a -> b) -> V2 a -> V2 b #

(<$) :: a -> V2 b -> V2 a #

Applicative V2 Source # 
Instance details

Defined in Graphics.Color.Algebra

Methods

pure :: a -> V2 a #

(<*>) :: V2 (a -> b) -> V2 a -> V2 b #

liftA2 :: (a -> b -> c) -> V2 a -> V2 b -> V2 c #

(*>) :: V2 a -> V2 b -> V2 b #

(<*) :: V2 a -> V2 b -> V2 a #

Foldable V2 Source # 
Instance details

Defined in Graphics.Color.Algebra

Methods

fold :: Monoid m => V2 m -> m #

foldMap :: Monoid m => (a -> m) -> V2 a -> m #

foldMap' :: Monoid m => (a -> m) -> V2 a -> m #

foldr :: (a -> b -> b) -> b -> V2 a -> b #

foldr' :: (a -> b -> b) -> b -> V2 a -> b #

foldl :: (b -> a -> b) -> b -> V2 a -> b #

foldl' :: (b -> a -> b) -> b -> V2 a -> b #

foldr1 :: (a -> a -> a) -> V2 a -> a #

foldl1 :: (a -> a -> a) -> V2 a -> a #

toList :: V2 a -> [a] #

null :: V2 a -> Bool #

length :: V2 a -> Int #

elem :: Eq a => a -> V2 a -> Bool #

maximum :: Ord a => V2 a -> a #

minimum :: Ord a => V2 a -> a #

sum :: Num a => V2 a -> a #

product :: Num a => V2 a -> a #

Traversable V2 Source # 
Instance details

Defined in Graphics.Color.Algebra

Methods

traverse :: Applicative f => (a -> f b) -> V2 a -> f (V2 b) #

sequenceA :: Applicative f => V2 (f a) -> f (V2 a) #

mapM :: Monad m => (a -> m b) -> V2 a -> m (V2 b) #

sequence :: Monad m => V2 (m a) -> m (V2 a) #

Eq a => Eq (V2 a) Source # 
Instance details

Defined in Graphics.Color.Algebra

Methods

(==) :: V2 a -> V2 a -> Bool #

(/=) :: V2 a -> V2 a -> Bool #

Floating a => Floating (V2 a) Source # 
Instance details

Defined in Graphics.Color.Algebra

Methods

pi :: V2 a #

exp :: V2 a -> V2 a #

log :: V2 a -> V2 a #

sqrt :: V2 a -> V2 a #

(**) :: V2 a -> V2 a -> V2 a #

logBase :: V2 a -> V2 a -> V2 a #

sin :: V2 a -> V2 a #

cos :: V2 a -> V2 a #

tan :: V2 a -> V2 a #

asin :: V2 a -> V2 a #

acos :: V2 a -> V2 a #

atan :: V2 a -> V2 a #

sinh :: V2 a -> V2 a #

cosh :: V2 a -> V2 a #

tanh :: V2 a -> V2 a #

asinh :: V2 a -> V2 a #

acosh :: V2 a -> V2 a #

atanh :: V2 a -> V2 a #

log1p :: V2 a -> V2 a #

expm1 :: V2 a -> V2 a #

log1pexp :: V2 a -> V2 a #

log1mexp :: V2 a -> V2 a #

Fractional a => Fractional (V2 a) Source # 
Instance details

Defined in Graphics.Color.Algebra

Methods

(/) :: V2 a -> V2 a -> V2 a #

recip :: V2 a -> V2 a #

fromRational :: Rational -> V2 a #

Num a => Num (V2 a) Source # 
Instance details

Defined in Graphics.Color.Algebra

Methods

(+) :: V2 a -> V2 a -> V2 a #

(-) :: V2 a -> V2 a -> V2 a #

(*) :: V2 a -> V2 a -> V2 a #

negate :: V2 a -> V2 a #

abs :: V2 a -> V2 a #

signum :: V2 a -> V2 a #

fromInteger :: Integer -> V2 a #

Ord a => Ord (V2 a) Source # 
Instance details

Defined in Graphics.Color.Algebra

Methods

compare :: V2 a -> V2 a -> Ordering #

(<) :: V2 a -> V2 a -> Bool #

(<=) :: V2 a -> V2 a -> Bool #

(>) :: V2 a -> V2 a -> Bool #

(>=) :: V2 a -> V2 a -> Bool #

max :: V2 a -> V2 a -> V2 a #

min :: V2 a -> V2 a -> V2 a #

Elevator a => Show (V2 a) Source # 
Instance details

Defined in Graphics.Color.Algebra

Methods

showsPrec :: Int -> V2 a -> ShowS #

show :: V2 a -> String #

showList :: [V2 a] -> ShowS #

Storable e => Storable (V2 e) Source # 
Instance details

Defined in Graphics.Color.Algebra

Methods

sizeOf :: V2 e -> Int #

alignment :: V2 e -> Int #

peekElemOff :: Ptr (V2 e) -> Int -> IO (V2 e) #

pokeElemOff :: Ptr (V2 e) -> Int -> V2 e -> IO () #

peekByteOff :: Ptr b -> Int -> IO (V2 e) #

pokeByteOff :: Ptr b -> Int -> V2 e -> IO () #

peek :: Ptr (V2 e) -> IO (V2 e) #

poke :: Ptr (V2 e) -> V2 e -> IO () #

3D

data V3 a Source #

A 3D vector with x, y and z coordinates.

Constructors

V3 !a !a !a 

Instances

Instances details
Functor V3 Source # 
Instance details

Defined in Graphics.Color.Algebra

Methods

fmap :: (a -> b) -> V3 a -> V3 b #

(<$) :: a -> V3 b -> V3 a #

Applicative V3 Source # 
Instance details

Defined in Graphics.Color.Algebra

Methods

pure :: a -> V3 a #

(<*>) :: V3 (a -> b) -> V3 a -> V3 b #

liftA2 :: (a -> b -> c) -> V3 a -> V3 b -> V3 c #

(*>) :: V3 a -> V3 b -> V3 b #

(<*) :: V3 a -> V3 b -> V3 a #

Foldable V3 Source # 
Instance details

Defined in Graphics.Color.Algebra

Methods

fold :: Monoid m => V3 m -> m #

foldMap :: Monoid m => (a -> m) -> V3 a -> m #

foldMap' :: Monoid m => (a -> m) -> V3 a -> m #

foldr :: (a -> b -> b) -> b -> V3 a -> b #

foldr' :: (a -> b -> b) -> b -> V3 a -> b #

foldl :: (b -> a -> b) -> b -> V3 a -> b #

foldl' :: (b -> a -> b) -> b -> V3 a -> b #

foldr1 :: (a -> a -> a) -> V3 a -> a #

foldl1 :: (a -> a -> a) -> V3 a -> a #

toList :: V3 a -> [a] #

null :: V3 a -> Bool #

length :: V3 a -> Int #

elem :: Eq a => a -> V3 a -> Bool #

maximum :: Ord a => V3 a -> a #

minimum :: Ord a => V3 a -> a #

sum :: Num a => V3 a -> a #

product :: Num a => V3 a -> a #

Traversable V3 Source # 
Instance details

Defined in Graphics.Color.Algebra

Methods

traverse :: Applicative f => (a -> f b) -> V3 a -> f (V3 b) #

sequenceA :: Applicative f => V3 (f a) -> f (V3 a) #

mapM :: Monad m => (a -> m b) -> V3 a -> m (V3 b) #

sequence :: Monad m => V3 (m a) -> m (V3 a) #

Eq a => Eq (V3 a) Source # 
Instance details

Defined in Graphics.Color.Algebra

Methods

(==) :: V3 a -> V3 a -> Bool #

(/=) :: V3 a -> V3 a -> Bool #

Floating a => Floating (V3 a) Source # 
Instance details

Defined in Graphics.Color.Algebra

Methods

pi :: V3 a #

exp :: V3 a -> V3 a #

log :: V3 a -> V3 a #

sqrt :: V3 a -> V3 a #

(**) :: V3 a -> V3 a -> V3 a #

logBase :: V3 a -> V3 a -> V3 a #

sin :: V3 a -> V3 a #

cos :: V3 a -> V3 a #

tan :: V3 a -> V3 a #

asin :: V3 a -> V3 a #

acos :: V3 a -> V3 a #

atan :: V3 a -> V3 a #

sinh :: V3 a -> V3 a #

cosh :: V3 a -> V3 a #

tanh :: V3 a -> V3 a #

asinh :: V3 a -> V3 a #

acosh :: V3 a -> V3 a #

atanh :: V3 a -> V3 a #

log1p :: V3 a -> V3 a #

expm1 :: V3 a -> V3 a #

log1pexp :: V3 a -> V3 a #

log1mexp :: V3 a -> V3 a #

Fractional a => Fractional (V3 a) Source # 
Instance details

Defined in Graphics.Color.Algebra

Methods

(/) :: V3 a -> V3 a -> V3 a #

recip :: V3 a -> V3 a #

fromRational :: Rational -> V3 a #

Num a => Num (V3 a) Source # 
Instance details

Defined in Graphics.Color.Algebra

Methods

(+) :: V3 a -> V3 a -> V3 a #

(-) :: V3 a -> V3 a -> V3 a #

(*) :: V3 a -> V3 a -> V3 a #

negate :: V3 a -> V3 a #

abs :: V3 a -> V3 a #

signum :: V3 a -> V3 a #

fromInteger :: Integer -> V3 a #

Ord a => Ord (V3 a) Source # 
Instance details

Defined in Graphics.Color.Algebra

Methods

compare :: V3 a -> V3 a -> Ordering #

(<) :: V3 a -> V3 a -> Bool #

(<=) :: V3 a -> V3 a -> Bool #

(>) :: V3 a -> V3 a -> Bool #

(>=) :: V3 a -> V3 a -> Bool #

max :: V3 a -> V3 a -> V3 a #

min :: V3 a -> V3 a -> V3 a #

Elevator a => Show (V3 a) Source # 
Instance details

Defined in Graphics.Color.Algebra

Methods

showsPrec :: Int -> V3 a -> ShowS #

show :: V3 a -> String #

showList :: [V3 a] -> ShowS #

Storable e => Storable (V3 e) Source # 
Instance details

Defined in Graphics.Color.Algebra

Methods

sizeOf :: V3 e -> Int #

alignment :: V3 e -> Int #

peekElemOff :: Ptr (V3 e) -> Int -> IO (V3 e) #

pokeElemOff :: Ptr (V3 e) -> Int -> V3 e -> IO () #

peekByteOff :: Ptr b -> Int -> IO (V3 e) #

pokeByteOff :: Ptr b -> Int -> V3 e -> IO () #

peek :: Ptr (V3 e) -> IO (V3 e) #

poke :: Ptr (V3 e) -> V3 e -> IO () #

showV3 :: Show a => V3 a -> String Source #

dotProduct :: Num a => V3 a -> V3 a -> a Source #

Mulitply a 1x3 vector by a 3x1 vector, i.e. dot product.

Since: 0.1.0

data M3x3 a Source #

A 3x3 Matrix

Constructors

M3x3 

Fields

Instances

Instances details
Functor M3x3 Source # 
Instance details

Defined in Graphics.Color.Algebra

Methods

fmap :: (a -> b) -> M3x3 a -> M3x3 b #

(<$) :: a -> M3x3 b -> M3x3 a #

Applicative M3x3 Source # 
Instance details

Defined in Graphics.Color.Algebra

Methods

pure :: a -> M3x3 a #

(<*>) :: M3x3 (a -> b) -> M3x3 a -> M3x3 b #

liftA2 :: (a -> b -> c) -> M3x3 a -> M3x3 b -> M3x3 c #

(*>) :: M3x3 a -> M3x3 b -> M3x3 b #

(<*) :: M3x3 a -> M3x3 b -> M3x3 a #

Foldable M3x3 Source # 
Instance details

Defined in Graphics.Color.Algebra

Methods

fold :: Monoid m => M3x3 m -> m #

foldMap :: Monoid m => (a -> m) -> M3x3 a -> m #

foldMap' :: Monoid m => (a -> m) -> M3x3 a -> m #

foldr :: (a -> b -> b) -> b -> M3x3 a -> b #

foldr' :: (a -> b -> b) -> b -> M3x3 a -> b #

foldl :: (b -> a -> b) -> b -> M3x3 a -> b #

foldl' :: (b -> a -> b) -> b -> M3x3 a -> b #

foldr1 :: (a -> a -> a) -> M3x3 a -> a #

foldl1 :: (a -> a -> a) -> M3x3 a -> a #

toList :: M3x3 a -> [a] #

null :: M3x3 a -> Bool #

length :: M3x3 a -> Int #

elem :: Eq a => a -> M3x3 a -> Bool #

maximum :: Ord a => M3x3 a -> a #

minimum :: Ord a => M3x3 a -> a #

sum :: Num a => M3x3 a -> a #

product :: Num a => M3x3 a -> a #

Traversable M3x3 Source # 
Instance details

Defined in Graphics.Color.Algebra

Methods

traverse :: Applicative f => (a -> f b) -> M3x3 a -> f (M3x3 b) #

sequenceA :: Applicative f => M3x3 (f a) -> f (M3x3 a) #

mapM :: Monad m => (a -> m b) -> M3x3 a -> m (M3x3 b) #

sequence :: Monad m => M3x3 (m a) -> m (M3x3 a) #

Eq a => Eq (M3x3 a) Source # 
Instance details

Defined in Graphics.Color.Algebra

Methods

(==) :: M3x3 a -> M3x3 a -> Bool #

(/=) :: M3x3 a -> M3x3 a -> Bool #

Floating a => Floating (M3x3 a) Source # 
Instance details

Defined in Graphics.Color.Algebra

Methods

pi :: M3x3 a #

exp :: M3x3 a -> M3x3 a #

log :: M3x3 a -> M3x3 a #

sqrt :: M3x3 a -> M3x3 a #

(**) :: M3x3 a -> M3x3 a -> M3x3 a #

logBase :: M3x3 a -> M3x3 a -> M3x3 a #

sin :: M3x3 a -> M3x3 a #

cos :: M3x3 a -> M3x3 a #

tan :: M3x3 a -> M3x3 a #

asin :: M3x3 a -> M3x3 a #

acos :: M3x3 a -> M3x3 a #

atan :: M3x3 a -> M3x3 a #

sinh :: M3x3 a -> M3x3 a #

cosh :: M3x3 a -> M3x3 a #

tanh :: M3x3 a -> M3x3 a #

asinh :: M3x3 a -> M3x3 a #

acosh :: M3x3 a -> M3x3 a #

atanh :: M3x3 a -> M3x3 a #

log1p :: M3x3 a -> M3x3 a #

expm1 :: M3x3 a -> M3x3 a #

log1pexp :: M3x3 a -> M3x3 a #

log1mexp :: M3x3 a -> M3x3 a #

Fractional a => Fractional (M3x3 a) Source # 
Instance details

Defined in Graphics.Color.Algebra

Methods

(/) :: M3x3 a -> M3x3 a -> M3x3 a #

recip :: M3x3 a -> M3x3 a #

fromRational :: Rational -> M3x3 a #

Num a => Num (M3x3 a) Source # 
Instance details

Defined in Graphics.Color.Algebra

Methods

(+) :: M3x3 a -> M3x3 a -> M3x3 a #

(-) :: M3x3 a -> M3x3 a -> M3x3 a #

(*) :: M3x3 a -> M3x3 a -> M3x3 a #

negate :: M3x3 a -> M3x3 a #

abs :: M3x3 a -> M3x3 a #

signum :: M3x3 a -> M3x3 a #

fromInteger :: Integer -> M3x3 a #

Elevator a => Show (M3x3 a) Source # 
Instance details

Defined in Graphics.Color.Algebra

Methods

showsPrec :: Int -> M3x3 a -> ShowS #

show :: M3x3 a -> String #

showList :: [M3x3 a] -> ShowS #

detM3x3 :: Num a => M3x3 a -> a Source #

Compute a determinant of a 3x3 matrix.

Since: 0.1.0

invertM3x3 :: Fractional a => M3x3 a -> M3x3 a Source #

Invert a 3x3 matrix.

Since: 0.1.0

multM3x3byV3 :: Num a => M3x3 a -> V3 a -> V3 a Source #

Mulitply a 3x3 matrix by a 3x1 vector, while getting a vector back.

Since: 0.1.0

multM3x3byM3x3 :: Num a => M3x3 a -> M3x3 a -> M3x3 a Source #

multM3x3byV3d :: Num a => M3x3 a -> V3 a -> M3x3 a Source #

Multiply a 3x3 matrix by another 3x3 diagonal matrix represented by a 1x3 vector

class (Show e, Eq e, Num e, Typeable e, Unbox e, Storable e) => Elevator e where Source #

A class with a set of functions that allow for changing precision by shrinking and streatching the values.

Methods

maxValue :: e Source #

minValue :: e Source #

fieldFormat :: e -> FieldFormat Source #

toShowS :: e -> ShowS Source #

This is a pretty printer for the value.

default toShowS :: PrintfArg e => e -> ShowS Source #

toWord8 :: e -> Word8 Source #

Values are scaled to [0, 255] range.

toWord16 :: e -> Word16 Source #

Values are scaled to [0, 65535] range.

toWord32 :: e -> Word32 Source #

Values are scaled to [0, 4294967295] range.

toWord64 :: e -> Word64 Source #

Values are scaled to [0, 18446744073709551615] range.

toRealFloat :: (Elevator a, RealFloat a) => e -> a Source #

Values are scaled to [0.0, 1.0] range.

fromRealFloat :: (Elevator a, RealFloat a) => a -> e Source #

Values are scaled from [0.0, 1.0] range.

toFloat :: e -> Float Source #

Values are scaled to [0.0, 1.0] range.

toDouble :: e -> Double Source #

Values are scaled to [0.0, 1.0] range.

fromDouble :: Double -> e Source #

Values are scaled from [0.0, 1.0] range.

(//) :: e -> e -> e infixl 7 Source #

Division that works for integral types as well as floating points. May throw an exception.

Instances

Instances details
Elevator Double Source #

Values between [0.0, 1.0]

Instance details

Defined in Graphics.Color.Algebra.Elevator

Elevator Float Source #

Values between [0.0, 1.0]

Instance details

Defined in Graphics.Color.Algebra.Elevator

Elevator Int Source #

Values between [0, 9223372036854775807] on 64bit

Instance details

Defined in Graphics.Color.Algebra.Elevator

Elevator Int8 Source #

Values between [0, 127]

Instance details

Defined in Graphics.Color.Algebra.Elevator

Elevator Int16 Source #

Values between [0, 32767]

Instance details

Defined in Graphics.Color.Algebra.Elevator

Elevator Int32 Source #

Values between [0, 2147483647]

Instance details

Defined in Graphics.Color.Algebra.Elevator

Elevator Int64 Source #

Values between [0, 9223372036854775807]

Instance details

Defined in Graphics.Color.Algebra.Elevator

Elevator Word Source #

Values between [0, 18446744073709551615] on 64bit

Instance details

Defined in Graphics.Color.Algebra.Elevator

Elevator Word8 Source #

Values between [0, 255]]

Instance details

Defined in Graphics.Color.Algebra.Elevator

Elevator Word16 Source #

Values between [0, 65535]]

Instance details

Defined in Graphics.Color.Algebra.Elevator

Elevator Word32 Source #

Values between [0, 4294967295]

Instance details

Defined in Graphics.Color.Algebra.Elevator

Elevator Word64 Source #

Values between [0, 18446744073709551615]

Instance details

Defined in Graphics.Color.Algebra.Elevator

Elevator Bit Source #

Values: 0 and 1

Instance details

Defined in Graphics.Color.Algebra.Binary

(PrintfArg e, Elevator e, RealFloat e) => Elevator (Complex e) Source #

Discards imaginary part and changes precision of real part.

Instance details

Defined in Graphics.Color.Algebra.Elevator

module Data.Word

clamp01 :: RealFloat a => a -> a Source #

Clamp a value to [0, 1] range.

Helpers

showsType :: Typeable t => proxy t -> ShowS Source #

asProxy :: p -> (Proxy p -> t) -> t Source #