diagrams-lib 1.4.0.1 → 1.4.1
raw patch · 11 files changed
+62/−33 lines, 11 filesdep +bytestringdep ~basedep ~intervalsPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: bytestring
Dependency ranges changed: base, intervals
API changes (from Hackage documentation)
- Diagrams.Coordinates: instance (GHC.Classes.Eq a, GHC.Classes.Eq b) => GHC.Classes.Eq (a Diagrams.Coordinates.:& b)
- Diagrams.Coordinates: instance (GHC.Classes.Ord a, GHC.Classes.Ord b) => GHC.Classes.Ord (a Diagrams.Coordinates.:& b)
- Diagrams.Coordinates: instance (GHC.Show.Show a, GHC.Show.Show b) => GHC.Show.Show (a Diagrams.Coordinates.:& b)
- Diagrams.Trail: instance (GHC.Float.Floating n, GHC.Classes.Ord n, Linear.Metric.Metric v) => Data.FingerTree.Measured (Diagrams.Segment.SegMeasure v n) (Diagrams.Trail.SegTree v n)
- Diagrams.Trail: instance (GHC.Float.Floating n, GHC.Classes.Ord n, Linear.Metric.Metric v) => Diagrams.Core.Transform.Transformable (Diagrams.Trail.SegTree v n)
- Diagrams.Trail: instance (GHC.Float.Floating n, GHC.Classes.Ord n, Linear.Metric.Metric v) => GHC.Base.Monoid (Diagrams.Trail.SegTree v n)
+ Diagrams.Coordinates: instance (GHC.Classes.Eq b, GHC.Classes.Eq a) => GHC.Classes.Eq (a Diagrams.Coordinates.:& b)
+ Diagrams.Coordinates: instance (GHC.Classes.Ord b, GHC.Classes.Ord a) => GHC.Classes.Ord (a Diagrams.Coordinates.:& b)
+ Diagrams.Coordinates: instance (GHC.Show.Show b, GHC.Show.Show a) => GHC.Show.Show (a Diagrams.Coordinates.:& b)
+ Diagrams.Trail: instance (Linear.Metric.Metric v, GHC.Classes.Ord n, GHC.Float.Floating n) => Data.FingerTree.Measured (Diagrams.Segment.SegMeasure v n) (Diagrams.Trail.SegTree v n)
+ Diagrams.Trail: instance (Linear.Metric.Metric v, GHC.Classes.Ord n, GHC.Float.Floating n) => Diagrams.Core.Transform.Transformable (Diagrams.Trail.SegTree v n)
+ Diagrams.Trail: instance (Linear.Metric.Metric v, GHC.Classes.Ord n, GHC.Float.Floating n) => GHC.Base.Monoid (Diagrams.Trail.SegTree v n)
+ Diagrams.TwoD.Image: embeddedImage :: Num n => DynamicImage -> DImage n Embedded
+ Diagrams.TwoD.Image: loadImageEmbBS :: Num n => ByteString -> Either String (DImage n Embedded)
- Diagrams.Names: (.>>) :: IsName a => a -> q -> q
+ Diagrams.Names: (.>>) :: (Qualifiable q, IsName a) => a -> q -> q
- Diagrams.Names: toName :: a -> Name
+ Diagrams.Names: toName :: IsName a => a -> Name
- Diagrams.Parametric: domainUpper :: (DomainBounds p, Num n) => p -> n
+ Diagrams.Parametric: domainUpper :: (DomainBounds p, Num (N p)) => p -> N p
- Diagrams.Prelude: (<*>) :: f (a -> b) -> f a -> f b
+ Diagrams.Prelude: (<*>) :: Applicative f => f (a -> b) -> f a -> f b
- Diagrams.Prelude: pure :: a -> f a
+ Diagrams.Prelude: pure :: Applicative f => a -> f a
- Diagrams.Segment: oeEnvelope :: forall v_a1BZv n_a1BZw. Lens' (OffsetEnvelope v_a1BZv n_a1BZw) (Envelope v_a1BZv n_a1BZw)
+ Diagrams.Segment: oeEnvelope :: forall v_a1dG2 n_a1dG3. Lens' (OffsetEnvelope v_a1dG2 n_a1dG3) (Envelope v_a1dG2 n_a1dG3)
- Diagrams.Segment: oeOffset :: forall v_a1BZv n_a1BZw. Lens' (OffsetEnvelope v_a1BZv n_a1BZw) (TotalOffset v_a1BZv n_a1BZw)
+ Diagrams.Segment: oeOffset :: forall v_a1dG2 n_a1dG3. Lens' (OffsetEnvelope v_a1dG2 n_a1dG3) (TotalOffset v_a1dG2 n_a1dG3)
- Diagrams.ThreeD.Camera: horizontalFieldOfView :: forall n_aWgn. Lens' (PerspectiveLens n_aWgn) (Angle n_aWgn)
+ Diagrams.ThreeD.Camera: horizontalFieldOfView :: forall n_aRpb. Lens' (PerspectiveLens n_aRpb) (Angle n_aRpb)
- Diagrams.ThreeD.Camera: orthoHeight :: forall n_aWiB. Lens' (OrthoLens n_aWiB) n_aWiB
+ Diagrams.ThreeD.Camera: orthoHeight :: forall n_aRrp. Lens' (OrthoLens n_aRrp) n_aRrp
- Diagrams.ThreeD.Camera: orthoWidth :: forall n_aWiB. Lens' (OrthoLens n_aWiB) n_aWiB
+ Diagrams.ThreeD.Camera: orthoWidth :: forall n_aRrp. Lens' (OrthoLens n_aRrp) n_aRrp
- Diagrams.ThreeD.Camera: verticalFieldOfView :: forall n_aWgn. Lens' (PerspectiveLens n_aWgn) (Angle n_aWgn)
+ Diagrams.ThreeD.Camera: verticalFieldOfView :: forall n_aRpb. Lens' (PerspectiveLens n_aRpb) (Angle n_aRpb)
- Diagrams.ThreeD.Types: _x :: Functor f => (a -> f a) -> t a -> f (t a)
+ Diagrams.ThreeD.Types: _x :: (R1 t, Functor f) => (a -> f a) -> t a -> f (t a)
- Diagrams.ThreeD.Types: _xy :: Functor f => (V2 a -> f (V2 a)) -> t a -> f (t a)
+ Diagrams.ThreeD.Types: _xy :: (R2 t, Functor f) => (V2 a -> f (V2 a)) -> t a -> f (t a)
- Diagrams.ThreeD.Types: _xyz :: Functor f => (V3 a -> f (V3 a)) -> t a -> f (t a)
+ Diagrams.ThreeD.Types: _xyz :: (R3 t, Functor f) => (V3 a -> f (V3 a)) -> t a -> f (t a)
- Diagrams.ThreeD.Types: _y :: Functor f => (a -> f a) -> t a -> f (t a)
+ Diagrams.ThreeD.Types: _y :: (R2 t, Functor f) => (a -> f a) -> t a -> f (t a)
- Diagrams.ThreeD.Types: _z :: Functor f => (a -> f a) -> t a -> f (t a)
+ Diagrams.ThreeD.Types: _z :: (R3 t, Functor f) => (a -> f a) -> t a -> f (t a)
- Diagrams.Transform: moveOriginTo :: Point (V t) (N t) -> t -> t
+ Diagrams.Transform: moveOriginTo :: HasOrigin t => Point (V t) (N t) -> t -> t
- Diagrams.Transform: transform :: Transformation (V t) (N t) -> t -> t
+ Diagrams.Transform: transform :: Transformable t => Transformation (V t) (N t) -> t -> t
- Diagrams.Transform.ScaleInv: scaleInvDir :: forall t_a1hxs. Lens' (ScaleInv t_a1hxs) (Vn t_a1hxs)
+ Diagrams.Transform.ScaleInv: scaleInvDir :: forall t_a14KY. Lens' (ScaleInv t_a14KY) (Vn t_a14KY)
- Diagrams.Transform.ScaleInv: scaleInvLoc :: forall t_a1hxs. Lens' (ScaleInv t_a1hxs) (Point (V t_a1hxs) (N t_a1hxs))
+ Diagrams.Transform.ScaleInv: scaleInvLoc :: forall t_a14KY. Lens' (ScaleInv t_a14KY) (Point (V t_a14KY) (N t_a14KY))
- Diagrams.Transform.ScaleInv: scaleInvObj :: forall t_a1hxs. Lens' (ScaleInv t_a1hxs) t_a1hxs
+ Diagrams.Transform.ScaleInv: scaleInvObj :: forall t_a14KY. Lens' (ScaleInv t_a14KY) t_a14KY
- Diagrams.TwoD: _LG :: forall n_a4lW8. Prism' (Texture n_a4lW8) (LGradient n_a4lW8)
+ Diagrams.TwoD: _LG :: forall n_a27LF. Prism' (Texture n_a27LF) (LGradient n_a27LF)
- Diagrams.TwoD: _RG :: forall n_a4lW8. Prism' (Texture n_a4lW8) (RGradient n_a4lW8)
+ Diagrams.TwoD: _RG :: forall n_a27LF. Prism' (Texture n_a27LF) (RGradient n_a27LF)
- Diagrams.TwoD: _SC :: forall n_a4lW8. Prism' (Texture n_a4lW8) SomeColor
+ Diagrams.TwoD: _SC :: forall n_a27LF. Prism' (Texture n_a27LF) SomeColor
- Diagrams.TwoD: _x :: Functor f => (a -> f a) -> t a -> f (t a)
+ Diagrams.TwoD: _x :: (R1 t, Functor f) => (a -> f a) -> t a -> f (t a)
- Diagrams.TwoD: _xy :: Functor f => (V2 a -> f (V2 a)) -> t a -> f (t a)
+ Diagrams.TwoD: _xy :: (R2 t, Functor f) => (V2 a -> f (V2 a)) -> t a -> f (t a)
- Diagrams.TwoD: _y :: Functor f => (a -> f a) -> t a -> f (t a)
+ Diagrams.TwoD: _y :: (R2 t, Functor f) => (a -> f a) -> t a -> f (t a)
- Diagrams.TwoD: eColor :: forall n_a4WCn. Lens' (EnvelopeOpts n_a4WCn) (Colour Double)
+ Diagrams.TwoD: eColor :: forall n_a2mrJ. Lens' (EnvelopeOpts n_a2mrJ) (Colour Double)
- Diagrams.TwoD: eLineWidth :: forall n_a4WCn n_a4WEn. Lens (EnvelopeOpts n_a4WCn) (EnvelopeOpts n_a4WEn) (Measure n_a4WCn) (Measure n_a4WEn)
+ Diagrams.TwoD: eLineWidth :: forall n_a2mrJ n_a2mtI. Lens (EnvelopeOpts n_a2mrJ) (EnvelopeOpts n_a2mtI) (Measure n_a2mrJ) (Measure n_a2mtI)
- Diagrams.TwoD: ePoints :: forall n_a4WCn. Lens' (EnvelopeOpts n_a4WCn) Int
+ Diagrams.TwoD: ePoints :: forall n_a2mrJ. Lens' (EnvelopeOpts n_a2mrJ) Int
- Diagrams.TwoD: oColor :: forall n_a4WBu. Lens' (OriginOpts n_a4WBu) (Colour Double)
+ Diagrams.TwoD: oColor :: forall n_a2mqQ. Lens' (OriginOpts n_a2mqQ) (Colour Double)
- Diagrams.TwoD: oMinSize :: forall n_a4WBu. Lens' (OriginOpts n_a4WBu) n_a4WBu
+ Diagrams.TwoD: oMinSize :: forall n_a2mqQ. Lens' (OriginOpts n_a2mqQ) n_a2mqQ
- Diagrams.TwoD: oScale :: forall n_a4WBu. Lens' (OriginOpts n_a4WBu) n_a4WBu
+ Diagrams.TwoD: oScale :: forall n_a2mqQ. Lens' (OriginOpts n_a2mqQ) n_a2mqQ
- Diagrams.TwoD: radiusBL :: forall d_a3ljq. Lens' (RoundedRectOpts d_a3ljq) d_a3ljq
+ Diagrams.TwoD: radiusBL :: forall d_a2Ayz. Lens' (RoundedRectOpts d_a2Ayz) d_a2Ayz
- Diagrams.TwoD: radiusBR :: forall d_a3ljq. Lens' (RoundedRectOpts d_a3ljq) d_a3ljq
+ Diagrams.TwoD: radiusBR :: forall d_a2Ayz. Lens' (RoundedRectOpts d_a2Ayz) d_a2Ayz
- Diagrams.TwoD: radiusTL :: forall d_a3ljq. Lens' (RoundedRectOpts d_a3ljq) d_a3ljq
+ Diagrams.TwoD: radiusTL :: forall d_a2Ayz. Lens' (RoundedRectOpts d_a2Ayz) d_a2Ayz
- Diagrams.TwoD: radiusTR :: forall d_a3ljq. Lens' (RoundedRectOpts d_a3ljq) d_a3ljq
+ Diagrams.TwoD: radiusTR :: forall d_a2Ayz. Lens' (RoundedRectOpts d_a2Ayz) d_a2Ayz
- Diagrams.TwoD: tColor :: forall n_a4WEM. Lens' (TraceOpts n_a4WEM) (Colour Double)
+ Diagrams.TwoD: tColor :: forall n_a2mu7. Lens' (TraceOpts n_a2mu7) (Colour Double)
- Diagrams.TwoD: tMinSize :: forall n_a4WEM. Lens' (TraceOpts n_a4WEM) n_a4WEM
+ Diagrams.TwoD: tMinSize :: forall n_a2mu7. Lens' (TraceOpts n_a2mu7) n_a2mu7
- Diagrams.TwoD: tPoints :: forall n_a4WEM. Lens' (TraceOpts n_a4WEM) Int
+ Diagrams.TwoD: tPoints :: forall n_a2mu7. Lens' (TraceOpts n_a2mu7) Int
- Diagrams.TwoD: tScale :: forall n_a4WEM. Lens' (TraceOpts n_a4WEM) n_a4WEM
+ Diagrams.TwoD: tScale :: forall n_a2mu7. Lens' (TraceOpts n_a2mu7) n_a2mu7
- Diagrams.TwoD.Attributes: _LG :: forall n_a4lW8. Prism' (Texture n_a4lW8) (LGradient n_a4lW8)
+ Diagrams.TwoD.Attributes: _LG :: forall n_a27LF. Prism' (Texture n_a27LF) (LGradient n_a27LF)
- Diagrams.TwoD.Attributes: _RG :: forall n_a4lW8. Prism' (Texture n_a4lW8) (RGradient n_a4lW8)
+ Diagrams.TwoD.Attributes: _RG :: forall n_a27LF. Prism' (Texture n_a27LF) (RGradient n_a27LF)
- Diagrams.TwoD.Attributes: _SC :: forall n_a4lW8. Prism' (Texture n_a4lW8) SomeColor
+ Diagrams.TwoD.Attributes: _SC :: forall n_a27LF. Prism' (Texture n_a27LF) SomeColor
- Diagrams.TwoD.Model: eColor :: forall n_a4WCn. Lens' (EnvelopeOpts n_a4WCn) (Colour Double)
+ Diagrams.TwoD.Model: eColor :: forall n_a2mrJ. Lens' (EnvelopeOpts n_a2mrJ) (Colour Double)
- Diagrams.TwoD.Model: eLineWidth :: forall n_a4WCn n_a4WEn. Lens (EnvelopeOpts n_a4WCn) (EnvelopeOpts n_a4WEn) (Measure n_a4WCn) (Measure n_a4WEn)
+ Diagrams.TwoD.Model: eLineWidth :: forall n_a2mrJ n_a2mtI. Lens (EnvelopeOpts n_a2mrJ) (EnvelopeOpts n_a2mtI) (Measure n_a2mrJ) (Measure n_a2mtI)
- Diagrams.TwoD.Model: ePoints :: forall n_a4WCn. Lens' (EnvelopeOpts n_a4WCn) Int
+ Diagrams.TwoD.Model: ePoints :: forall n_a2mrJ. Lens' (EnvelopeOpts n_a2mrJ) Int
- Diagrams.TwoD.Model: oColor :: forall n_a4WBu. Lens' (OriginOpts n_a4WBu) (Colour Double)
+ Diagrams.TwoD.Model: oColor :: forall n_a2mqQ. Lens' (OriginOpts n_a2mqQ) (Colour Double)
- Diagrams.TwoD.Model: oMinSize :: forall n_a4WBu. Lens' (OriginOpts n_a4WBu) n_a4WBu
+ Diagrams.TwoD.Model: oMinSize :: forall n_a2mqQ. Lens' (OriginOpts n_a2mqQ) n_a2mqQ
- Diagrams.TwoD.Model: oScale :: forall n_a4WBu. Lens' (OriginOpts n_a4WBu) n_a4WBu
+ Diagrams.TwoD.Model: oScale :: forall n_a2mqQ. Lens' (OriginOpts n_a2mqQ) n_a2mqQ
- Diagrams.TwoD.Model: tColor :: forall n_a4WEM. Lens' (TraceOpts n_a4WEM) (Colour Double)
+ Diagrams.TwoD.Model: tColor :: forall n_a2mu7. Lens' (TraceOpts n_a2mu7) (Colour Double)
- Diagrams.TwoD.Model: tMinSize :: forall n_a4WEM. Lens' (TraceOpts n_a4WEM) n_a4WEM
+ Diagrams.TwoD.Model: tMinSize :: forall n_a2mu7. Lens' (TraceOpts n_a2mu7) n_a2mu7
- Diagrams.TwoD.Model: tPoints :: forall n_a4WEM. Lens' (TraceOpts n_a4WEM) Int
+ Diagrams.TwoD.Model: tPoints :: forall n_a2mu7. Lens' (TraceOpts n_a2mu7) Int
- Diagrams.TwoD.Model: tScale :: forall n_a4WEM. Lens' (TraceOpts n_a4WEM) n_a4WEM
+ Diagrams.TwoD.Model: tScale :: forall n_a2mu7. Lens' (TraceOpts n_a2mu7) n_a2mu7
- Diagrams.TwoD.Shapes: radiusBL :: forall d_a3ljq. Lens' (RoundedRectOpts d_a3ljq) d_a3ljq
+ Diagrams.TwoD.Shapes: radiusBL :: forall d_a2Ayz. Lens' (RoundedRectOpts d_a2Ayz) d_a2Ayz
- Diagrams.TwoD.Shapes: radiusBR :: forall d_a3ljq. Lens' (RoundedRectOpts d_a3ljq) d_a3ljq
+ Diagrams.TwoD.Shapes: radiusBR :: forall d_a2Ayz. Lens' (RoundedRectOpts d_a2Ayz) d_a2Ayz
- Diagrams.TwoD.Shapes: radiusTL :: forall d_a3ljq. Lens' (RoundedRectOpts d_a3ljq) d_a3ljq
+ Diagrams.TwoD.Shapes: radiusTL :: forall d_a2Ayz. Lens' (RoundedRectOpts d_a2Ayz) d_a2Ayz
- Diagrams.TwoD.Shapes: radiusTR :: forall d_a3ljq. Lens' (RoundedRectOpts d_a3ljq) d_a3ljq
+ Diagrams.TwoD.Shapes: radiusTR :: forall d_a2Ayz. Lens' (RoundedRectOpts d_a2Ayz) d_a2Ayz
- Diagrams.TwoD.Types: _x :: Functor f => (a -> f a) -> t a -> f (t a)
+ Diagrams.TwoD.Types: _x :: (R1 t, Functor f) => (a -> f a) -> t a -> f (t a)
- Diagrams.TwoD.Types: _xy :: Functor f => (V2 a -> f (V2 a)) -> t a -> f (t a)
+ Diagrams.TwoD.Types: _xy :: (R2 t, Functor f) => (V2 a -> f (V2 a)) -> t a -> f (t a)
- Diagrams.TwoD.Types: _y :: Functor f => (a -> f a) -> t a -> f (t a)
+ Diagrams.TwoD.Types: _y :: (R2 t, Functor f) => (a -> f a) -> t a -> f (t a)
Files
- CHANGELOG.md +10/−0
- diagrams-lib.cabal +7/−6
- src/Diagrams/Backend/CmdLine.hs +1/−1
- src/Diagrams/Combinators.hs +1/−1
- src/Diagrams/Names.hs +1/−0
- src/Diagrams/Parametric.hs +1/−1
- src/Diagrams/Segment.hs +7/−2
- src/Diagrams/Trace.hs +1/−0
- src/Diagrams/Transform/Matrix.hs +5/−3
- src/Diagrams/TwoD/Image.hs +18/−9
- test/Diagrams/Test/Transform.hs +10/−10
CHANGELOG.md view
@@ -1,3 +1,13 @@+## [v1.4.1](https://github.com/diagrams/diagrams-lib/tree/v1.4.0.1) (2017-05-28)++- New functions `embeddedImage` and `loadImageEmbBS` for loading+ images.+- Fix [#289](https://github.com/diagrams/diagrams-lib/issues/289)+ which could have caused strange behavior in looped compilation mode+ on 32-bit platforms.+- Allow `intervals-0.8` and `directory-1.3`.+- Minor fixes to compile with GHC 8.2.+ ## [v1.4.0.1](https://github.com/diagrams/diagrams-lib/tree/v1.4.0.1) (2016-11-07) - Fix test suite compilation problem ([#286](https://github.com/diagrams/diagrams-lib/issues/286))
diagrams-lib.cabal view
@@ -1,5 +1,5 @@ Name: diagrams-lib-Version: 1.4.0.1+Version: 1.4.1 Synopsis: Embedded domain-specific language for declarative graphics Description: Diagrams is a flexible, extensible EDSL for creating graphics of many types. Graphics can be created@@ -100,7 +100,7 @@ Diagrams.TwoD.Types, Diagrams.TwoD.Vector, Diagrams.Util- Build-depends: base >= 4.6 && < 4.10,+ Build-depends: base >= 4.6 && < 4.11, containers >= 0.3 && < 0.6, array >= 0.3 && < 0.6, semigroups >= 0.3.4 && < 0.19,@@ -112,7 +112,7 @@ colour >= 2.3.2 && < 2.4, data-default-class < 0.2, fingertree >= 0.1 && < 0.2,- intervals >= 0.7 && < 0.8,+ intervals >= 0.7 && < 0.9, lens >= 4.6 && < 4.16, tagged >= 0.7, optparse-applicative >= 0.11 && < 0.14,@@ -124,14 +124,15 @@ distributive >=0.2.2 && < 1.0, process >= 1.1 && < 1.5, fsnotify >= 0.2.1 && < 0.3,- directory >= 1.2 && < 1.3,+ directory >= 1.2 && < 1.4, unordered-containers >= 0.2 && < 0.3, text >= 0.7.1 && < 1.3, mtl >= 2.0 && < 2.3, transformers >= 0.3.0 && < 0.6.0, profunctors >= 5.0 && < 6.0, exceptions >= 0.6 && < 1.0,- cereal >=0.4.1.1 && <0.6+ cereal >=0.4.1.1 && <0.6,+ bytestring >=0.9 && <0.11 if impl(ghc < 7.6) Build-depends: ghc-prim Hs-source-dirs: src@@ -155,7 +156,7 @@ , Diagrams.Test.Angle , Instances hs-source-dirs: test- build-depends: base >= 4.2 && < 4.10,+ build-depends: base, tasty >= 0.10 && < 0.12, tasty-hunit >= 0.9.2 && < 0.10, tasty-quickcheck >= 0.8 && < 0.9,
src/Diagrams/Backend/CmdLine.hs view
@@ -609,7 +609,7 @@ putStrLn $ "Program args: " ++ unwords args' forever . threadDelay $ case os of -- https://ghc.haskell.org/trac/ghc/ticket/7325- "darwin" -> 5000000000000+ "darwin" -> 2000000000 _ -> maxBound recompile :: FilePath -> FilePath -> [String] -> IO ExitCode
src/Diagrams/Combinators.hs view
@@ -113,7 +113,7 @@ -- to alignment and envelope acts like a 1-dimensional segment -- oriented along the vector @v@, with local origin at its -- center. (Note, however, that it has an empty trace; for 2D struts--- with a nonempty trace see 'strutR2', 'strutX', and 'strutY' from+-- with a nonempty trace see 'strutR2' from -- "Diagrams.TwoD.Combinators".) Useful for manually creating -- separation between two diagrams. --
src/Diagrams/Names.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE MonoLocalBinds #-} ----------------------------------------------------------------------------- -- | -- Module : Diagrams.Names
src/Diagrams/Parametric.hs view
@@ -55,7 +55,7 @@ -- with numeric scalars). domainUpper :: p -> N p - default domainUpper :: Num n => p -> n+ default domainUpper :: Num (N p) => p -> N p domainUpper = const 1 -- | Type class for querying the values of a parametric object at the
src/Diagrams/Segment.hs view
@@ -325,6 +325,11 @@ reverseSegment (Linear (OffsetClosed v)) = straight (negated v) reverseSegment (Cubic c1 c2 (OffsetClosed x2)) = bezier3 (c2 ^-^ x2) (c1 ^-^ x2) (negated x2) +-- Imitates I.elem for intervals<0.8 and I.member for intervals>=0.8+member :: Ord a => a -> I.Interval a -> Bool+member x (I.I a b) = x >= a && x <= b+{-# INLINE member #-}+ instance (Metric v, OrderedField n) => HasArcLength (Segment Closed v n) where @@ -339,9 +344,9 @@ arcLengthToParam m s _ | arcLength m s == 0 = 0.5 arcLengthToParam m s@(Linear {}) len = len / arcLength m s arcLengthToParam m s@(Cubic {}) len- | len `I.elem` I (-m/2) (m/2) = 0+ | len `member` I (-m/2) (m/2) = 0 | len < 0 = - arcLengthToParam m (fst (splitAtParam s (-1))) (-len)- | len `I.elem` slen = 1+ | len `member` slen = 1 | len > I.sup slen = 2 * arcLengthToParam m (fst (splitAtParam s 2)) len | len < I.sup llen = (*0.5) $ arcLengthToParam m l len | otherwise = (+0.5) . (*0.5)
src/Diagrams/Trace.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE MonoLocalBinds #-} ----------------------------------------------------------------------------- -- | -- Module : Diagrams.Trace
src/Diagrams/Transform/Matrix.hs view
@@ -1,4 +1,5 @@-{-# LANGUAGE CPP #-}+{-# LANGUAGE CPP #-}+{-# LANGUAGE MonoLocalBinds #-} ----------------------------------------------------------------------------- -- |@@ -64,7 +65,8 @@ mat22 :: Floating n => Iso' (M22 n, V2 n) (T2 n) mat22 = iso (uncurry fromMat22) (mkMat &&& transl) --- | Prism onto a 2D transformation from a 2x2 transform matrix and--- translation vector (in which case the 'T3' will be invalid).+-- | Prism onto a 3D transformation from a 3x3 transform matrix and+-- translation vector. Does not check if the matrix is invertible+-- (in which case the 'T3' will be invalid). mat33 :: Floating n => Iso' (M33 n, V3 n) (T3 n) mat33 = iso (uncurry fromMat33) (mkMat &&& transl)
src/Diagrams/TwoD/Image.hs view
@@ -25,7 +25,9 @@ DImage(..), ImageData(..) , Embedded, External, Native , image+ , embeddedImage , loadImageEmb+ , loadImageEmbBS , loadImageExt , uncheckedImageRef , raster@@ -48,6 +50,8 @@ import Diagrams.Query import Diagrams.TwoD.Types +import Data.ByteString+ import Linear.Affine data Embedded deriving Typeable@@ -103,17 +107,22 @@ rectPath :: RealFloat n => n -> n -> Path V2 n rectPath = rect --- | Use JuicyPixels to read an image in any format and wrap it in a 'DImage'.+-- | Read a JuicyPixels @DynamicImage@ and wrap it in a 'DImage'. -- The width and height of the image are set to their actual values.+embeddedImage :: Num n => DynamicImage -> DImage n Embedded+embeddedImage img = DImage (ImageRaster img) w h mempty+ where+ w = dynamicMap imageWidth img+ h = dynamicMap imageHeight img++-- | Use JuicyPixels to read a file in any format and wrap it in a 'DImage'.+-- The width and height of the image are set to their actual values. loadImageEmb :: Num n => FilePath -> IO (Either String (DImage n Embedded))-loadImageEmb path = do- dImg <- readImage path- return $ case dImg of- Left msg -> Left msg- Right img -> Right (DImage (ImageRaster img) w h mempty)- where- w = dynamicMap imageWidth img- h = dynamicMap imageHeight img+loadImageEmb path = fmap embeddedImage `fmap` readImage path++-- | A pure variant of 'loadImageEmb'+loadImageEmbBS :: Num n => ByteString -> Either String (DImage n Embedded)+loadImageEmbBS bs = embeddedImage `fmap` decodeImage bs -- | Check that a file exists, and use JuicyPixels to figure out -- the right size, but save a reference to the image instead
test/Diagrams/Test/Transform.hs view
@@ -15,31 +15,31 @@ testProperty "rotating a vector by a number then its additive inverse will yield the original vector" $ \θ a -> rotate ((θ * (-1)) @@ deg) (rotate ((θ :: Double) @@ deg) (a :: V2 Double)) =~ a , testProperty "under rotated allows scaling along an angle" $- \θ f a -> under (rotated ((θ :: Double) @@ deg)) (scaleX (f :: Double)) (a :: V2 Double) == (rotate (negated (θ @@ deg)) . (scaleX f) . rotate (θ @@ deg)) a+ \θ f a -> under (rotated ((θ :: Double) @@ deg)) (scaleX (f :: Double)) (a :: V2 Double) =~ (rotate (negated (θ @@ deg)) . (scaleX f) . rotate (θ @@ deg)) a , testProperty "a rotation of 0 does nothing" $ \a -> rotate (0 @@ deg) (a :: V2 Double) =~ a , testProperty "adding 360 degrees to a turn does nothing" $ \c a -> rotate (((c :: Double) + 360) @@ deg) (a :: V2 Double) =~ rotate (c @@ deg) a , testProperty "over rotated allows scaling along x of a rotated shape" $- \θ f a -> over (rotated ((θ :: Double) @@ deg)) (scaleX (f :: Double)) (a :: V2 Double) == (rotate (θ @@ deg) . (scaleX f) . rotate (negated (θ @@ deg))) a+ \θ f a -> over (rotated ((θ :: Double) @@ deg)) (scaleX (f :: Double)) (a :: V2 Double) =~ (rotate (θ @@ deg) . (scaleX f) . rotate (negated (θ @@ deg))) a , testProperty "scaleX" $- \f a b -> (scaleX (f :: Double)) (V2 (a :: Double) b) == V2 (a * f) b+ \f a b -> (scaleX (f :: Double)) (V2 (a :: Double) b) =~ V2 (a * f) b , testProperty "scaleY" $- \f a b -> (scaleY (f :: Double)) (V2 (a :: Double) b) == V2 a (f * b)+ \f a b -> (scaleY (f :: Double)) (V2 (a :: Double) b) =~ V2 a (f * b) , testProperty "reflectX" $- \a b -> reflectX (V2 (a :: Double) b) == V2 (a * (-1)) b+ \a b -> reflectX (V2 (a :: Double) b) =~ V2 (a * (-1)) b , testProperty "reflectY" $- \a b -> reflectY (V2 (a :: Double) b) == V2 a ((-1) * b)+ \a b -> reflectY (V2 (a :: Double) b) =~ V2 a ((-1) * b) , testProperty "reflectXY" $- \a b -> reflectXY (V2 (a :: Double) b) == V2 b a+ \a b -> reflectXY (V2 (a :: Double) b) =~ V2 b a , testProperty "translate" $- \a b c d -> translateX (a :: Double) (translateY b (P (V2 c d ))) == P (V2 (a + c) (b + d))+ \a b c d -> translateX (a :: Double) (translateY b (P (V2 c d ))) =~ P (V2 (a + c) (b + d)) , testProperty "shear" $- \a b c d -> shearX (a :: Double) (shearY b (V2 c d)) == V2 ((c*b + d) * a + c) (c*b + d)+ \a b c d -> shearX (a :: Double) (shearY b (V2 c d)) =~ V2 ((c*b + d) * a + c) (c*b + d) , testProperty "(1,0) rotateTo some dir will return normalised dir" $ \(NonZero a) b -> rotateTo (dir (V2 (a :: Double) b)) (V2 1 0) =~ signorm (V2 a b) , testProperty "rotates" $- \a c -> rotate ((a :: Double)@@ deg) (c :: V2 Double) == rotate'' ((a :: Double)@@ deg) (c :: V2 Double) && rotate ((a :: Double)@@ deg) (c :: V2 Double) == rotate' ((a :: Double)@@ deg) (c :: V2 Double)+ \a c -> rotate ((a :: Double)@@ deg) (c :: V2 Double) =~ rotate'' ((a :: Double)@@ deg) (c :: V2 Double) && rotate ((a :: Double)@@ deg) (c :: V2 Double) =~ rotate' ((a :: Double)@@ deg) (c :: V2 Double) , testProperty "reflectAbout works for a vector" $ \a b c d e f -> reflectAbout (P (V2 (a :: Double) b)) (dir (V2 c d)) (V2 e f) =~ over (rotated (atan2A' d c)) reflectY (V2 e f) , testProperty "reflectAbout works for a point" $