colour 2.3.3 → 2.3.4
raw patch · 5 files changed
+82/−55 lines, 5 filesdep +QuickCheckdep +randomdep +test-frameworkdep ~basePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: QuickCheck, random, test-framework, test-framework-quickcheck2
Dependency ranges changed: base
API changes (from Hackage documentation)
- Data.Colour: instance (Fractional a, Read a) => Read (AlphaColour a)
- Data.Colour: instance (Fractional a, Read a) => Read (Colour a)
- Data.Colour: instance (Fractional a, Show a) => Show (Colour a)
- Data.Colour: instance (Fractional a, Show a, Eq a) => Show (AlphaColour a)
- Data.Colour.CIE: instance AffineSpace Chromaticity
- Data.Colour.RGBSpace: channelBlue :: RGB a -> !a
- Data.Colour.RGBSpace: channelGreen :: RGB a -> !a
- Data.Colour.RGBSpace: channelRed :: RGB a -> !a
- Data.Colour.RGBSpace: instance Num a => Monoid (TransferFunction a)
- Data.Colour.RGBSpace: transfer :: TransferFunction a -> a -> a
- Data.Colour.RGBSpace: transferGamma :: TransferFunction a -> a
- Data.Colour.RGBSpace: transferInverse :: TransferFunction a -> a -> a
- Data.Colour.SRGB: channelBlue :: RGB a -> !a
- Data.Colour.SRGB: channelGreen :: RGB a -> !a
- Data.Colour.SRGB: channelRed :: RGB a -> !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: instance (GHC.Real.Fractional a, GHC.Read.Read a) => GHC.Read.Read (Data.Colour.Internal.AlphaColour a)
+ Data.Colour: instance (GHC.Real.Fractional a, GHC.Read.Read a) => GHC.Read.Read (Data.Colour.Internal.Colour a)
+ Data.Colour: instance (GHC.Real.Fractional a, GHC.Show.Show a) => GHC.Show.Show (Data.Colour.Internal.Colour a)
+ Data.Colour: instance (GHC.Real.Fractional a, GHC.Show.Show a, GHC.Classes.Eq a) => GHC.Show.Show (Data.Colour.Internal.AlphaColour a)
+ Data.Colour.CIE: instance Data.Colour.Internal.AffineSpace Data.Colour.CIE.Chromaticity.Chromaticity
+ Data.Colour.RGBSpace: [channelBlue] :: RGB a -> !a
+ Data.Colour.RGBSpace: [channelGreen] :: RGB a -> !a
+ Data.Colour.RGBSpace: [channelRed] :: RGB a -> !a
+ Data.Colour.RGBSpace: [transferGamma] :: TransferFunction a -> a
+ Data.Colour.RGBSpace: [transferInverse] :: TransferFunction a -> a -> a
+ Data.Colour.RGBSpace: [transfer] :: TransferFunction a -> a -> a
+ Data.Colour.RGBSpace: instance GHC.Num.Num a => Data.Semigroup.Semigroup (Data.Colour.RGBSpace.TransferFunction a)
+ Data.Colour.RGBSpace: instance GHC.Num.Num a => GHC.Base.Monoid (Data.Colour.RGBSpace.TransferFunction a)
+ Data.Colour.SRGB: [channelBlue] :: RGB a -> !a
+ Data.Colour.SRGB: [channelGreen] :: RGB a -> !a
+ Data.Colour.SRGB: [channelRed] :: RGB a -> !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: atop :: Fractional a => AlphaColour a -> AlphaColour a -> AlphaColour a
+ Data.Colour: atop :: (Fractional a) => AlphaColour a -> AlphaColour a -> AlphaColour a
- Data.Colour: black :: Num a => Colour a
+ Data.Colour: black :: (Num a) => Colour a
- Data.Colour: dissolve :: Num a => a -> AlphaColour a -> AlphaColour a
+ Data.Colour: dissolve :: (Num a) => a -> AlphaColour a -> AlphaColour a
- Data.Colour: opaque :: Num a => Colour a -> AlphaColour a
+ Data.Colour: opaque :: (Num a) => Colour a -> AlphaColour a
- Data.Colour: transparent :: Num a => AlphaColour a
+ Data.Colour: transparent :: (Num a) => AlphaColour a
- Data.Colour: withOpacity :: Num a => Colour a -> a -> AlphaColour a
+ Data.Colour: withOpacity :: (Num a) => Colour a -> a -> AlphaColour a
- Data.Colour.CIE: chromaColour :: Fractional a => Chromaticity a -> a -> Colour a
+ Data.Colour.CIE: chromaColour :: (Fractional a) => Chromaticity a -> a -> Colour a
- Data.Colour.CIE: chromaCoords :: Fractional a => Chromaticity a -> (a, a, a)
+ Data.Colour.CIE: chromaCoords :: (Fractional a) => Chromaticity a -> (a, a, a)
- Data.Colour.CIE: chromaX :: Fractional a => Chromaticity a -> a
+ Data.Colour.CIE: chromaX :: (Fractional a) => Chromaticity a -> a
- Data.Colour.CIE: chromaY :: Fractional a => Chromaticity a -> a
+ Data.Colour.CIE: chromaY :: (Fractional a) => Chromaticity a -> a
- Data.Colour.CIE: chromaZ :: Fractional a => Chromaticity a -> a
+ Data.Colour.CIE: chromaZ :: (Fractional a) => Chromaticity a -> a
- Data.Colour.CIE: cieXYZ :: Fractional a => a -> a -> a -> Colour a
+ Data.Colour.CIE: cieXYZ :: (Fractional a) => a -> a -> a -> Colour a
- Data.Colour.CIE: cieXYZView :: Fractional a => Colour a -> (a, a, a)
+ Data.Colour.CIE: cieXYZView :: (Fractional a) => Colour a -> (a, a, a)
- Data.Colour.CIE: luminance :: Fractional a => Colour a -> a
+ Data.Colour.CIE: luminance :: (Fractional a) => Colour a -> a
- Data.Colour.CIE: mkChromaticity :: Fractional a => a -> a -> Chromaticity a
+ Data.Colour.CIE: mkChromaticity :: (Fractional a) => a -> a -> Chromaticity a
- Data.Colour.CIE.Illuminant: a :: Fractional a => Chromaticity a
+ Data.Colour.CIE.Illuminant: a :: (Fractional a) => Chromaticity a
- Data.Colour.CIE.Illuminant: b :: Fractional a => Chromaticity a
+ Data.Colour.CIE.Illuminant: b :: (Fractional a) => Chromaticity a
- Data.Colour.CIE.Illuminant: c :: Fractional a => Chromaticity a
+ Data.Colour.CIE.Illuminant: c :: (Fractional a) => Chromaticity a
- Data.Colour.CIE.Illuminant: d50 :: Fractional a => Chromaticity a
+ Data.Colour.CIE.Illuminant: d50 :: (Fractional a) => Chromaticity a
- Data.Colour.CIE.Illuminant: d55 :: Fractional a => Chromaticity a
+ Data.Colour.CIE.Illuminant: d55 :: (Fractional a) => Chromaticity a
- Data.Colour.CIE.Illuminant: d65 :: Fractional a => Chromaticity a
+ Data.Colour.CIE.Illuminant: d65 :: (Fractional a) => Chromaticity a
- Data.Colour.CIE.Illuminant: d75 :: Fractional a => Chromaticity a
+ Data.Colour.CIE.Illuminant: d75 :: (Fractional a) => Chromaticity a
- Data.Colour.CIE.Illuminant: e :: Fractional a => Chromaticity a
+ Data.Colour.CIE.Illuminant: e :: (Fractional a) => Chromaticity a
- Data.Colour.CIE.Illuminant: f1 :: Fractional a => Chromaticity a
+ Data.Colour.CIE.Illuminant: f1 :: (Fractional a) => Chromaticity a
- Data.Colour.CIE.Illuminant: f10 :: Fractional a => Chromaticity a
+ Data.Colour.CIE.Illuminant: f10 :: (Fractional a) => Chromaticity a
- Data.Colour.CIE.Illuminant: f11 :: Fractional a => Chromaticity a
+ Data.Colour.CIE.Illuminant: f11 :: (Fractional a) => Chromaticity a
- Data.Colour.CIE.Illuminant: f12 :: Fractional a => Chromaticity a
+ Data.Colour.CIE.Illuminant: f12 :: (Fractional a) => Chromaticity a
- Data.Colour.CIE.Illuminant: f2 :: Fractional a => Chromaticity a
+ Data.Colour.CIE.Illuminant: f2 :: (Fractional a) => Chromaticity a
- Data.Colour.CIE.Illuminant: f3 :: Fractional a => Chromaticity a
+ Data.Colour.CIE.Illuminant: f3 :: (Fractional a) => Chromaticity a
- Data.Colour.CIE.Illuminant: f4 :: Fractional a => Chromaticity a
+ Data.Colour.CIE.Illuminant: f4 :: (Fractional a) => Chromaticity a
- Data.Colour.CIE.Illuminant: f5 :: Fractional a => Chromaticity a
+ Data.Colour.CIE.Illuminant: f5 :: (Fractional a) => Chromaticity a
- Data.Colour.CIE.Illuminant: f6 :: Fractional a => Chromaticity a
+ Data.Colour.CIE.Illuminant: f6 :: (Fractional a) => Chromaticity a
- Data.Colour.CIE.Illuminant: f7 :: Fractional a => Chromaticity a
+ Data.Colour.CIE.Illuminant: f7 :: (Fractional a) => Chromaticity a
- Data.Colour.CIE.Illuminant: f8 :: Fractional a => Chromaticity a
+ Data.Colour.CIE.Illuminant: f8 :: (Fractional a) => Chromaticity a
- Data.Colour.CIE.Illuminant: f9 :: Fractional a => Chromaticity a
+ Data.Colour.CIE.Illuminant: f9 :: (Fractional a) => Chromaticity a
- Data.Colour.Names: black :: Num a => Colour a
+ Data.Colour.Names: black :: (Num a) => Colour a
- Data.Colour.RGBSpace: inverseTransferFunction :: Fractional a => TransferFunction a -> TransferFunction a
+ Data.Colour.RGBSpace: inverseTransferFunction :: (Fractional a) => TransferFunction a -> TransferFunction a
- Data.Colour.RGBSpace: linearRGBSpace :: Num a => RGBGamut -> RGBSpace a
+ Data.Colour.RGBSpace: linearRGBSpace :: (Num a) => RGBGamut -> RGBSpace a
- Data.Colour.RGBSpace: linearTransferFunction :: Num a => TransferFunction a
+ Data.Colour.RGBSpace: linearTransferFunction :: (Num a) => TransferFunction a
- Data.Colour.RGBSpace: powerTransferFunction :: Floating a => a -> TransferFunction a
+ Data.Colour.RGBSpace: powerTransferFunction :: (Floating a) => a -> TransferFunction a
- Data.Colour.RGBSpace: rgbUsingSpace :: Fractional a => RGBSpace a -> a -> a -> a -> Colour a
+ Data.Colour.RGBSpace: rgbUsingSpace :: (Fractional a) => RGBSpace a -> a -> a -> a -> Colour a
- Data.Colour.RGBSpace: toRGBUsingSpace :: Fractional a => RGBSpace a -> Colour a -> RGB a
+ Data.Colour.RGBSpace: toRGBUsingSpace :: (Fractional a) => RGBSpace a -> Colour a -> RGB a
Files
- CHANGELOG +5/−0
- Data/Colour/Internal.hs +7/−0
- Data/Colour/RGBSpace.hs +4/−0
- Tests.hs +51/−50
- colour.cabal +15/−5
CHANGELOG view
@@ -1,3 +1,8 @@+New in version 2.3.4:++- Support for Semigroup (as superclass of) Monoid Proposal.+- Add test-suite to cabal file.+ New in version 2.3.3: - Support for GHC 7.4 from Eugene Kirpichov.
Data/Colour/Internal.hs view
@@ -26,6 +26,7 @@ import qualified Data.Colour.Chan as Chan import Data.Colour.Chan (Chan(Chan)) import Data.Monoid+import Data.Semigroup data Red = Red data Green = Green@@ -53,6 +54,9 @@ black :: (Num a) => Colour a black = RGB Chan.empty Chan.empty Chan.empty +instance (Num a) => Semigroup (Colour a) where+ (<>) = mappend+ instance (Num a) => Monoid (Colour a) where mempty = black (RGB r1 g1 b1) `mappend` (RGB r2 g2 b2) =@@ -168,6 +172,9 @@ darken s (RGBA c a) = RGBA (darken s c) a -- | 'AlphaColour' forms a monoid with 'over' and 'transparent'.+instance (Num a) => Semigroup (AlphaColour a) where+ (<>) = mappend+ instance (Num a) => Monoid (AlphaColour a) where mempty = transparent mappend = over
Data/Colour/RGBSpace.hs view
@@ -47,6 +47,7 @@ where import Data.Monoid+import Data.Semigroup import Data.Colour.CIE.Chromaticity import Data.Colour.Matrix import Data.Colour.RGB@@ -108,6 +109,9 @@ inverseTransferFunction :: (Fractional a) => TransferFunction a -> TransferFunction a inverseTransferFunction (TransferFunction for rev g) = TransferFunction rev for (recip g)++instance (Num a) => Semigroup (TransferFunction a) where+ (<>) = mappend instance (Num a) => Monoid (TransferFunction a) where mempty = linearTransferFunction
Tests.hs view
@@ -1,4 +1,4 @@-{-# OPTIONS_GHC -XTypeSynonymInstances #-}+{-# LANGUAGE TypeSynonymInstances #-} {- Copyright (c) 2008, 2009 Russell O'Connor@@ -27,7 +27,8 @@ import Data.Word import Control.Monad import Test.QuickCheck-import Text.Printf+import Test.Framework (defaultMain, defaultMainWithOpts, testGroup)+import Test.Framework.Providers.QuickCheck2 (testProperty) import Data.Monoid import Data.Colour.Matrix@@ -119,7 +120,7 @@ prop_matrixMult (a1,b1,c1) (d1,e1,f1) (g1,h1,i1) (a2,b2,c2) (d2,e2,f2) (g2,h2,i2) (x,y,z) = mult m1 (mult m2 v) == mult (matrixMult m1 m2) v- where + where m1 = [[a1,b1,c1],[d1,e1,f1],[g1,h1,i1]] m2 = [[a2,b2,c2],[d2,e2,f2],[g2,h2,i2]] v :: [Rational]@@ -189,19 +190,19 @@ prop_overOpaque c1 c2 = c1 `over` opaque c2 == opaque (c1 `over` c2) prop_blendOver :: Rational -> RColour -> RColour -> Bool-prop_blendOver o c1 c2 = +prop_blendOver o c1 c2 = (c1 `withOpacity` o) `over` c2 == blend o c1 c2 prop_blendTransparent :: Rational -> Rational -> RColour -> Bool-prop_blendTransparent o a c = +prop_blendTransparent o a c = blend o (c `withOpacity` a) transparent == c `withOpacity ` (o*a) prop_blendFlip :: Rational -> RColour -> RColour -> Bool-prop_blendFlip o c1 c2 = +prop_blendFlip o c1 c2 = blend (1-o) c2 c1 == blend o c1 c2 prop_darkenBlend :: Rational -> RColour -> Bool-prop_darkenBlend w c = +prop_darkenBlend w c = blend w c mempty == darken w c prop_darkenBlack :: RAlphaColour -> Bool@@ -268,7 +269,7 @@ prop_fromToHSL h = forAll (two (fmap toRational zeroOne)) (\(s,l) -> checkHSL (hslView (hsl h s l)) (h,s,l)) where- checkHSL (h0,s0,l0) (h1,s1,l1) = + checkHSL (h0,s0,l0) (h1,s1,l1) = snd (properFraction ((h0-h1)/360)::(Integer,Rational)) == 0 && s0 == s1 && l0 == l1 @@ -281,50 +282,50 @@ prop_fromToHSV h = forAll (two (fmap toRational zeroOne)) (\(s,v) -> checkHSV (hsvView (hsv h s v)) (h,s,v)) where- checkHSV (h0,s0,v0) (h1,s1,v1) = + checkHSV (h0,s0,v0) (h1,s1,v1) = snd (properFraction ((h0-h1)/360)::(Integer,Rational)) == 0 && s0 == s1 && v0 == v1 -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)+tests = [ testProperty "matrix-mult" prop_matrixMult+ , testProperty "RGB-to-from" prop_toFromRGB+ , testProperty "RGB-from-to" prop_fromToRGB+ , testProperty "XYZ-to-from" prop_toFromXYZ+ , testProperty "XYZ-from-to" prop_fromToXYZ+ , testProperty "sRGB-to-from" prop_toFromSRGB+ , testProperty "sRGB-from-to" prop_fromToSRGB+ , testProperty "cieLAB-to-from" (prop_toFromLAB d65)+-- , testProperty "Y'CbCr-709-from-to" prop_fromToY'CbCr709+-- , testProperty "Y'CbCr-601-from-to" prop_fromToY'CbCr601+ , testProperty "dissolve-id" prop_disolveId+ , testProperty "dissolve-transparent" prop_disolveTransparent+ , testProperty "transparent-over" prop_transparentOver+ , testProperty "over-transparent" prop_overTransparent+ , testProperty "opaque-over" prop_opaqueOver+ , testProperty "over-opaque" prop_overOpaque+ , testProperty "blend-over" prop_blendOver+ , testProperty "blend-transparent" prop_blendTransparent+ , testProperty "blend-flip" prop_blendFlip+ , testProperty "darken-blend" prop_darkenBlend+ , testProperty "darken-black" prop_darkenBlack+ , testProperty "darken-id" prop_darkenId+ , testProperty "atop-opaque" prop_atopOpaque+ , testProperty "transparent-atop" prop_transparentAtop+ , testProperty "atop-transparent" prop_atopTransparent+ , testProperty "atop-alpha" prop_atopAlpha+ , testProperty "colour-show-read" prop_showReadC+ , testProperty "alphaColour-show-read" prop_showReadAC+ , testProperty "sRGB24-show-length" prop_sRGB24showlength+ , testProperty "sRGB24-read-show" prop_readshowSRGB24+ , testProperty "luminance-white" prop_luminance_white+ , testProperty "rgb" prop_rgb+ , testProperty "toRGB" prop_toRGB+ , testProperty "sRGB" prop_sRGB+ , testProperty "toSRGB" prop_toSRGB+ , testProperty "hueRange" prop_hueRange+ , testProperty "toFromHSL" prop_toFromHSL+ , testProperty "fromToHSL" prop_fromToHSL+ , testProperty "toFromHSV" prop_toFromHSV+ , testProperty "fromToHSV" prop_fromToHSV ] -main = mapM_ (\(s,a) -> printf "%-25s: " s >> a) quickChecks+main = defaultMain tests
colour.cabal view
@@ -1,6 +1,6 @@ Name: colour-Version: 2.3.3-Cabal-Version: >= 1.6+Version: 2.3.4+Cabal-Version: >= 1.10 License: MIT License-file: LICENSE Author: Russell O'Connor@@ -13,12 +13,12 @@ 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.12.3-extra-source-files: Tests.hs+Tested-with: GHC == 8.0.2 data-files: README CHANGELOG Library- Build-Depends: base >= 3 && < 5+ default-language: Haskell98+ Build-Depends: base >= 4.9 && < 5 Exposed-Modules: Data.Colour Data.Colour.SRGB Data.Colour.SRGB.Linear@@ -33,3 +33,13 @@ Data.Colour.RGB Data.Colour.Matrix Data.Colour.CIE.Chromaticity+test-suite test-colour+ default-language: Haskell98+ type: exitcode-stdio-1.0+ main-is: Tests.hs+ build-depends: base >= 4.9 && < 5,+ QuickCheck >= 2.5 && < 2.11,+ random >= 1.0 && < 1.2,+ test-framework >= 0.8 && < 0.9,+ test-framework-quickcheck2 >= 0.3 && < 0.4+