colour 2.3.1 → 2.3.2
raw patch · 11 files changed
+94/−71 lines, 11 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Data.Colour: instance Fractional a => Show (AlphaColour a)
- Data.Colour: instance Fractional a => Show (Colour a)
- Data.Colour.SRGB.Linear: RGB :: !a -> !a -> !a -> RGB a
- Data.Colour.SRGB.Linear: channelBlue :: RGB a -> !a
- Data.Colour.SRGB.Linear: channelGreen :: RGB a -> !a
- Data.Colour.SRGB.Linear: channelRed :: RGB a -> !a
- Data.Colour.SRGB.Linear: data Colour a
- Data.Colour.SRGB.Linear: data RGB a
+ Data.Colour: instance (Fractional a, Show a) => Show (AlphaColour a)
+ Data.Colour: instance (Fractional a, Show a) => Show (Colour a)
- Data.Colour.Names: readColourName :: (Monad m, Ord a, Floating a) => String -> m (Colour a)
+ Data.Colour.Names: readColourName :: (Ord a, Floating a) => String -> Maybe (Colour a)
Files
- CHANGELOG +9/−2
- Data/Colour.hs +4/−3
- Data/Colour/CIE.hs +2/−2
- Data/Colour/CIE/Chromaticity.hs +1/−1
- Data/Colour/Internal.hs +2/−2
- Data/Colour/Names.hs +2/−2
- Data/Colour/RGBSpace.hs +1/−0
- Data/Colour/SRGB.hs +7/−1
- Data/Colour/SRGB/Linear.hs +1/−2
- Tests.hs +61/−52
- colour.cabal +4/−4
CHANGELOG view
@@ -1,6 +1,12 @@+New in version 2.3.2:++- Support for GHC 7.4.1 from Brent Yorgey.++- Documentation fixes.+ New in version 2.3.1: -Fixed Data.Colour.Names colour documenation.+- Fixed Data.Colour.Names colour documenation. New in version 2.3: @@ -9,4 +15,5 @@ - CIELAB conversion functions New in version 2.2.1:- - Additional Documenation++- Additional Documenation
Data/Colour.hs view
@@ -128,16 +128,17 @@ import Data.Char import Data.Colour.Internal import qualified Data.Colour.SRGB.Linear+import qualified Data.Colour.SRGB import Data.Colour.CIE.Chromaticity (app_prec, infix_prec) -instance (Fractional a) => Show (Colour a) where+instance (Fractional a, Show a) => Show (Colour a) where showsPrec d c = showParen (d > app_prec) showStr where showStr = showString linearConstructorQualifiedName . showString " " . (showsPrec (app_prec+1) r) . showString " " . (showsPrec (app_prec+1) g) . showString " " . (showsPrec (app_prec+1) b)- Data.Colour.SRGB.Linear.RGB r g b = Data.Colour.SRGB.Linear.toRGB c+ Data.Colour.SRGB.RGB r g b = Data.Colour.SRGB.Linear.toRGB c instance (Fractional a, Read a) => Read (Colour a) where readsPrec d r = readParen (d > app_prec)@@ -156,7 +157,7 @@ linearConstructorQualifiedName = "Data.Colour.SRGB.Linear.rgb" linearConstructorName = "rgb" -instance (Fractional a) => Show (AlphaColour a) where+instance (Fractional a, Show a) => Show (AlphaColour a) where showsPrec d ac | a == 0 = showString "transparent" | otherwise = showParen (d > infix_prec) showStr where
Data/Colour/CIE.hs view
@@ -144,9 +144,9 @@ -- perceptually uniform colour space. -- If you don't know what white point to use, use -- 'Data.Colour.CIE.Illuminant.d65'.-cieLuv :: (Ord a, Floating a) => Chromaticity a -- ^White point+cieLUV :: (Ord a, Floating a) => Chromaticity a -- ^White point -> Colour a -> (a,a,a)-cieLuv white_ch c = (l, 13*l*(u'-un'), 13*l*(v'-vn'))+cieLUV white_ch c = (l, 13*l*(u'-un'), 13*l*(v'-vn')) where white = chromaColour white_ch 1.0 (u', v') = u'v' c
Data/Colour/CIE/Chromaticity.hs view
@@ -53,7 +53,7 @@ chromaConvert :: (Fractional b, Real a) => Chromaticity a -> Chromaticity b chromaConvert (Chroma x y) = Chroma (realToFrac x) (realToFrac y) -instance (Fractional a) => Show (Chromaticity a) where+instance (Fractional a, Show a) => Show (Chromaticity a) where showsPrec d c = showParen (d > app_prec) showStr where showStr = showString "mkChromaticity " . (showsPrec (app_prec+1) x)
Data/Colour/Internal.hs view
@@ -73,7 +73,7 @@ -- To get the (pre-multiplied) colour channel of an 'AlphaColour' @c@, -- simply composite @c@ over black. ----- >c `over` (mempty :: Colour a)+-- >c `over` black -- Internally we use a premultiplied-alpha representation. data AlphaColour a = RGBA !(Colour a) !(Chan Alpha a) deriving (Eq)@@ -111,7 +111,7 @@ -- The last parameter will get the remaining weight. -- e.g. --- -- >affineCombo [(0.2,a), (0.3,b)] c == 0.2*a + 0.3*b + 0.4*c+ -- >affineCombo [(0.2,a), (0.3,b)] c == 0.2*a + 0.3*b + 0.5*c -- -- Weights can be negative, or greater than 1.0; however, be aware -- that non-convex combinations may lead to out of gamut colours.
Data/Colour/Names.hs view
@@ -185,7 +185,7 @@ import Data.Colour.SRGB import Data.Colour (black) -readColourName :: (Monad m, Ord a, Floating a) => String -> m (Colour a)+readColourName :: (Ord a, Floating a) => String -> Maybe (Colour a) readColourName "aliceblue" = return aliceblue readColourName "antiquewhite" = return antiquewhite readColourName "aqua" = return aqua@@ -334,7 +334,7 @@ readColourName "yellow" = return yellow readColourName "yellowgreen" = return yellowgreen readColourName x = fail $ - "Data.Colour.Names.readColourNames: Unknown colour name "++show x+ "Data.Colour.Names.readColourName: Unknown colour name "++show x aliceblue :: (Ord a, Floating a) => Colour a aliceblue = sRGB24 240 248 255
Data/Colour/RGBSpace.hs view
@@ -47,6 +47,7 @@ where import Data.Monoid+import Data.Colour.Internal (Colour) import Data.Colour.CIE.Chromaticity import Data.Colour.Matrix import Data.Colour.RGB
Data/Colour/SRGB.hs view
@@ -1,5 +1,5 @@ {--Copyright (c) 2008+Copyright (c) 2008, 2009 Russell O'Connor Permission is hereby granted, free of charge, to any person obtaining a copy@@ -38,6 +38,12 @@ import Data.Colour.Internal (quantize) import Data.Colour.SRGB.Linear import Data.Colour.RGBSpace hiding (transferFunction)++{- a rewrite rule to think about adding.+ Should I have some instance restrictions (like Word8/Word16 Float/Double)?+# RULES "sRGBBounded" + forall r g b. toSRGBBounded (sRGBBounded r g b) = RGB r g b #+-} {- Non-linear colour space -} {- the sRGB transfer function approximates a gamma of about 1/2.2 -}
Data/Colour/SRGB/Linear.hs view
@@ -24,8 +24,7 @@ -- |Provides a /linear/ colour space with the same gamut as -- "Data.Colour.SRGB". module Data.Colour.SRGB.Linear - (Colour, RGB(..)- ,rgb, toRGB+ (rgb, toRGB ,sRGBGamut ) where
Tests.hs view
@@ -52,20 +52,12 @@ type RAlphaColour = AlphaColour Rational type DAlphaColour = AlphaColour Double -instance Arbitrary Word8 where- arbitrary = liftM fromIntegral $- choose (fromIntegral (minBound::Word8)::Int,- fromIntegral (maxBound::Word8)::Int)- coarbitrary x = variant (fromIntegral x)--instance Arbitrary (Rational) where- arbitrary = liftM (toRational :: Double -> Rational) $ arbitrary- coarbitrary x = coarbitrary (fromRational x :: Double)- instance (Real a, Fractional a, Arbitrary a) => Arbitrary (Colour a) where arbitrary = liftM3 mkColour arbitrary arbitrary arbitrary where mkColour r' g' b' = colourConvert (sRGB24 r' g' b'::Colour Double)++instance (Real a, Fractional a, CoArbitrary a) => CoArbitrary (Colour a) where coarbitrary c = coarbitrary (r,g,b) where (RGB r g b) = toRGB c@@ -77,6 +69,9 @@ mkAlphaColour :: (Fractional a) => Colour a -> Word8 -> AlphaColour a mkAlphaColour c a = c `withOpacity` (fromIntegral a/fromIntegral (maxBound `asTypeOf` a))++instance (Real a, Fractional a, CoArbitrary a) =>+ CoArbitrary (AlphaColour a) where coarbitrary ac = coarbitrary a . coarbitrary c where a = alphaChannel ac@@ -85,16 +80,23 @@ instance (Fractional a, Arbitrary a) => Arbitrary (Chromaticity a) where arbitrary = liftM2 mkChromaticity arbitrary arbitrary++instance (Fractional a, CoArbitrary a) =>+ CoArbitrary (Chromaticity a) where coarbitrary c = coarbitrary x . coarbitrary y where (x,y,_) = chromaCoords c instance (Arbitrary a) => Arbitrary (RGB a) where arbitrary = liftM3 RGB arbitrary arbitrary arbitrary++instance (CoArbitrary a) => CoArbitrary (RGB a) where coarbitrary (RGB r g b) = coarbitrary (r,g,b) instance Arbitrary RGBGamut where arbitrary = liftM2 RGBGamut arbitrary arbitrary++instance CoArbitrary RGBGamut where coarbitrary (RGBGamut p w) = coarbitrary p . coarbitrary w -- generate RGB values with channels between 0 and 1.@@ -103,6 +105,12 @@ zeroOne = choose (0,1::Double) +two :: Monad m => m a -> m (a, a)+two m = liftM2 (,) m m++three :: Monad m => m a -> m (a, a, a)+three m = liftM3 (,,) m m m+ good (RGBGamut p w) = p1 && p2 where p1 = 0 /= determinant (primaryMatrix p)@@ -121,6 +129,8 @@ instance Arbitrary Depth where arbitrary = liftM Depth $ choose (0,11)++instance CoArbitrary Depth where coarbitrary (Depth x) = coarbitrary x prop_toFromRGB :: RColour -> Bool@@ -275,47 +285,46 @@ snd (properFraction ((h0-h1)/360)::(Integer,Rational)) == 0 && s0 == s1 && v0 == v1 --tests = [("matrix-mult", test prop_matrixMult)- ,("RGB-to-from", test prop_toFromRGB)- ,("RGB-from-to", test prop_fromToRGB)- ,("XYZ-to-from", test prop_toFromXYZ)- ,("XYZ-from-to", test prop_fromToXYZ)- ,("sRGB-to-from", test prop_toFromSRGB)- ,("sRGB-from-to", test prop_fromToSRGB)- ,("cieLAB-to-from", test (prop_toFromLAB d65))--- ,("Y'CbCr-709-from-to", test prop_fromToY'CbCr709)--- ,("Y'CbCr-601-from-to", test prop_fromToY'CbCr601)- ,("dissolve-id", test prop_disolveId)- ,("dissolve-transparent", test prop_disolveTransparent)- ,("transparent-over", test prop_transparentOver)- ,("over-transparent", test prop_overTransparent)- ,("opaque-over", test prop_opaqueOver)- ,("over-opaque", test prop_overOpaque)- ,("blend-over", test prop_blendOver)- ,("blend-transparent", test prop_blendTransparent)- ,("blend-flip", test prop_blendFlip)- ,("darken-blend", test prop_darkenBlend)- ,("darken-black", test prop_darkenBlack)- ,("darken-id", test prop_darkenId)- ,("atop-opaque", test prop_atopOpaque)- ,("transparent-atop", test prop_transparentAtop)- ,("atop-transparent", test prop_atopTransparent)- ,("atop-alpha", test prop_atopAlpha)- ,("colour-show-read", test prop_showReadC)- ,("alphaColour-show-read", test prop_showReadAC)- ,("sRGB24-show-length", test prop_sRGB24showlength)- ,("sRGB24-read-show", test prop_readshowSRGB24)- ,("luminance-white", test prop_luminance_white)- ,("rgb", test prop_rgb)- ,("toRGB", test prop_toRGB)- ,("sRGB", test prop_sRGB)- ,("toSRGB", test prop_toSRGB)- ,("hueRange", test prop_hueRange)- ,("toFromHSL", test prop_toFromHSL)- ,("fromToHSL", test prop_fromToHSL)- ,("toFromHSV", test prop_toFromHSV)- ,("fromToHSV", test prop_fromToHSV)+quickChecks = [("matrix-mult", quickCheck prop_matrixMult)+ ,("RGB-to-from", quickCheck prop_toFromRGB)+ ,("RGB-from-to", quickCheck prop_fromToRGB)+ ,("XYZ-to-from", quickCheck prop_toFromXYZ)+ ,("XYZ-from-to", quickCheck prop_fromToXYZ)+ ,("sRGB-to-from", quickCheck prop_toFromSRGB)+ ,("sRGB-from-to", quickCheck prop_fromToSRGB)+ ,("cieLAB-to-from", quickCheck (prop_toFromLAB d65))+-- ,("Y'CbCr-709-from-to", quickCheck prop_fromToY'CbCr709)+-- ,("Y'CbCr-601-from-to", quickCheck prop_fromToY'CbCr601)+ ,("dissolve-id", quickCheck prop_disolveId)+ ,("dissolve-transparent", quickCheck prop_disolveTransparent)+ ,("transparent-over", quickCheck prop_transparentOver)+ ,("over-transparent", quickCheck prop_overTransparent)+ ,("opaque-over", quickCheck prop_opaqueOver)+ ,("over-opaque", quickCheck prop_overOpaque)+ ,("blend-over", quickCheck prop_blendOver)+ ,("blend-transparent", quickCheck prop_blendTransparent)+ ,("blend-flip", quickCheck prop_blendFlip)+ ,("darken-blend", quickCheck prop_darkenBlend)+ ,("darken-black", quickCheck prop_darkenBlack)+ ,("darken-id", quickCheck prop_darkenId)+ ,("atop-opaque", quickCheck prop_atopOpaque)+ ,("transparent-atop", quickCheck prop_transparentAtop)+ ,("atop-transparent", quickCheck prop_atopTransparent)+ ,("atop-alpha", quickCheck prop_atopAlpha)+ ,("colour-show-read", quickCheck prop_showReadC)+ ,("alphaColour-show-read", quickCheck prop_showReadAC)+ ,("sRGB24-show-length", quickCheck prop_sRGB24showlength)+ ,("sRGB24-read-show", quickCheck prop_readshowSRGB24)+ ,("luminance-white", quickCheck prop_luminance_white)+ ,("rgb", quickCheck prop_rgb)+ ,("toRGB", quickCheck prop_toRGB)+ ,("sRGB", quickCheck prop_sRGB)+ ,("toSRGB", quickCheck prop_toSRGB)+ ,("hueRange", quickCheck prop_hueRange)+ ,("toFromHSL", quickCheck prop_toFromHSL)+ ,("fromToHSL", quickCheck prop_fromToHSL)+ ,("toFromHSV", quickCheck prop_toFromHSV)+ ,("fromToHSV", quickCheck prop_fromToHSV) ] -main = mapM_ (\(s,a) -> printf "%-25s: " s >> a) tests+main = mapM_ (\(s,a) -> printf "%-25s: " s >> a) quickChecks
colour.cabal view
@@ -1,7 +1,7 @@ Name: colour-Version: 2.3.1-Cabal-Version: >= 1.2-License: OtherLicense+Version: 2.3.2+Cabal-Version: >= 1.6+License: MIT License-file: LICENSE Author: Russell O'Connor Maintainer: Russell O'Connor <roconnor@theorem.ca>@@ -13,7 +13,7 @@ Colours can be blended and composed. Various colour spaces are supported. A module of colour names ("Data.Colour.Names") is provided.-Tested-with: GHC == 6.8.2+Tested-with: GHC == 6.12.3 extra-source-files: Tests.hs data-files: README CHANGELOG