diagrams-core 1.4 → 1.4.0.1
raw patch · 5 files changed
+24/−9 lines, 5 filesdep ~basePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base
API changes (from Hackage documentation)
Files
- CHANGELOG.md +4/−0
- diagrams-core.cabal +3/−3
- src/Diagrams/Core/Envelope.hs +14/−5
- src/Diagrams/Core/Measure.hs +2/−1
- src/Diagrams/Core/Points.hs +1/−0
CHANGELOG.md view
@@ -1,3 +1,7 @@+## v1.4.0.1 (???)++* Allow base-4.10+ ## [v1.4](https://github.com/diagrams/diagrams-core/tree/v1.4) (2016-10-26) * **New features**
diagrams-core.cabal view
@@ -1,5 +1,5 @@ Name: diagrams-core-Version: 1.4+Version: 1.4.0.1 Synopsis: Core libraries for diagrams EDSL Description: The core modules underlying diagrams, an embedded domain-specific language@@ -12,7 +12,7 @@ Bug-reports: https://github.com/diagrams/diagrams-core/issues Category: Graphics Build-type: Simple-Cabal-version: >=1.10+Cabal-version: >=1.18 Extra-source-files: CHANGELOG.md, README.markdown, diagrams/*.svg extra-doc-files: diagrams/*.svg Tested-with: GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.2, GHC == 8.0.1@@ -36,7 +36,7 @@ Diagrams.Core.Types, Diagrams.Core.V - Build-depends: base >= 4.2 && < 4.10,+ Build-depends: base >= 4.2 && < 4.11, containers >= 0.4.2 && < 0.6, unordered-containers >= 0.2 && < 0.3, semigroups >= 0.8.4 && < 0.19,
src/Diagrams/Core/Envelope.hs view
@@ -107,7 +107,7 @@ -- -- The idea for envelopes came from -- Sebastian Setzer; see--- <http://byorgey.wordpress.com/2009/10/28/collecting-attributes/#comment-2030>. See also Brent Yorgey, /Monoids: Theme and Variations/, published in the 2012 Haskell Symposium: <http://www.cis.upenn.edu/~byorgey/pub/monoid-pearl.pdf>; video: <http://www.youtube.com/watch?v=X-8NCkD2vOw>.+-- <http://byorgey.wordpress.com/2009/10/28/collecting-attributes/#comment-2030>. See also Brent Yorgey, /Monoids: Theme and Variations/, published in the 2012 Haskell Symposium: <http://ozark.hendrix.edu/~yorgey/pub/monoid-pearl.pdf>; video: <http://www.youtube.com/watch?v=X-8NCkD2vOw>. newtype Envelope v n = Envelope (Option (v n -> Max n)) instance Wrapped (Envelope v n) where@@ -116,16 +116,24 @@ instance Rewrapped (Envelope v n) (Envelope v' n') +-- | \"Apply\" an envelope by turning it into a function. @Nothing@+-- is returned iff the envelope is empty. appEnvelope :: Envelope v n -> Maybe (v n -> n) appEnvelope (Envelope (Option e)) = (getMax .) <$> e +-- | A convenient way to transform an envelope, by specifying a+-- transformation on the underlying @v n -> n@ function. The empty+-- envelope is unaffected. onEnvelope :: ((v n -> n) -> v n -> n) -> Envelope v n -> Envelope v n onEnvelope t = over (_Wrapping' Envelope . mapped) ((Max .) . t . (getMax .)) +-- | Create an envelope from a @v n -> n@ function. mkEnvelope :: (v n -> n) -> Envelope v n mkEnvelope = Envelope . Option . Just . (Max .) --- | Create an envelope for the given point.+-- | Create a point envelope for the given point. A point envelope+-- has distance zero to a bounding hyperplane in every direction.+-- Note this is /not/ the same as the empty envelope. pointEnvelope :: (Fractional n, Metric v) => Point v n -> Envelope v n pointEnvelope p = moveTo p (mkEnvelope $ const 0) @@ -217,8 +225,8 @@ However, it turns out that if v and w are perpendicular, then t^-1 v will be perpendicular to t^T w, that is, the *transpose* of t (when-considered as a matrix) applied to w. The proof is simple: if vand w-are perpendicular then v . w = v^T w = 0. Thus,+considered as a matrix) applied to w. The proof is simple. Recall+that v and w are perpendicular if and only if v . w = v^T w = 0. Thus, (t^-1 v) . (t^T w) = (t^-1 v)^T (t^T w) = v^T t^-T t^T w = v^T w = 0. @@ -350,6 +358,7 @@ extent :: (V a ~ v, N a ~ n, Enveloped a) => v n -> a -> Maybe (n, n) extent v a = (\f -> (-f (negated v), f v)) <$> (appEnvelope . getEnvelope $ a) --- | The smallest positive vector that bounds the envelope of an object.+-- | The smallest positive /axis-parallel/ vector that bounds the+-- envelope of an object. size :: (V a ~ v, N a ~ n, Enveloped a, HasBasis v) => a -> v n size d = tabulate $ \(E l) -> diameter (zero & l .~ 1) d
src/Diagrams/Core/Measure.hs view
@@ -56,7 +56,8 @@ local :: Num n => n -> Measure n local x = views _1 (*x) --- | Global units are ?+-- | Global units are scaled so that they are interpreted relative to+-- the size of the final rendered diagram. global :: Num n => n -> Measure n global x = views _2 (*x)
src/Diagrams/Core/Points.hs view
@@ -30,6 +30,7 @@ type instance V (Point v n) = v type instance N (Point v n) = n +-- | Reflect a point across the origin. mirror :: (Additive v, Num n) => Point v n -> Point v n mirror = reflectThrough origin