diagrams-lib 1.5 → 1.5.1
raw patch · 4 files changed
Files
- CHANGELOG.md +20/−0
- diagrams-lib.cabal +3/−3
- src/Diagrams/Trail.hs +11/−0
- src/Diagrams/TwoD/Segment.hs +26/−16
CHANGELOG.md view
@@ -1,3 +1,23 @@+## [v1.5.1](https://github.com/diagrams/diagrams-lib/tree/v1.5.1) (2025-12-02)++- New `Semigroup` instance for located lines (i.e. `Located (Trail'+ Line v n)`), which adds an extra segment from the end of the first+ to the start of the second.++## [v1.5.0.1](https://github.com/diagrams/diagrams-lib/tree/v1.5.0.1) (2025-08-25)++- Fix bug in `bezierFindRoot` that caused diagrams to hang when+ computing the trace of certain degenerate Bezier curves. See+ https://github.com/diagrams/diagrams-contrib/issues/91 .++## [v1.5-r2](https://github.com/diagrams/diagrams-lib/tree/v1.5-r2) (2025-06-12)++- Allow `optparse-applicative-0.19`++## [v1.5-r1](https://github.com/diagrams/diagrams-lib/tree/v1.5-r1) (2025-05-17)++- Allow `monoid-extras-0.7`+ ## [v1.5](https://github.com/diagrams/diagrams-lib/tree/v1.5) (2025-02-13) - Allow `base-4.21` and test on GHC 9.12
diagrams-lib.cabal view
@@ -1,5 +1,5 @@ Name: diagrams-lib-Version: 1.5+Version: 1.5.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@@ -105,7 +105,7 @@ containers >= 0.3 && < 0.8, array >= 0.3 && < 0.6, semigroups >= 0.3.4 && < 0.21,- monoid-extras >= 0.6 && < 0.7,+ monoid-extras >= 0.6 && < 0.8, dual-tree >= 0.2 && < 0.3, diagrams-core >= 1.4 && < 1.6, diagrams-solve >= 0.1 && < 0.2,@@ -116,7 +116,7 @@ intervals >= 0.7 && < 0.10, lens >= 5.1 && < 5.4, tagged >= 0.7 && < 0.9,- optparse-applicative >= 0.11 && < 0.19,+ optparse-applicative >= 0.11 && < 0.20, filepath >= 1.4 && < 1.6, JuicyPixels >= 3.3.4 && < 3.4, hashable >= 1.1 && < 1.6,
src/Diagrams/Trail.hs view
@@ -539,6 +539,17 @@ _Snoc = _Wrapped . _Snoc . bimapping _Unwrapped id {-# INLINE _Snoc #-} +-- | Compose two Located trails by adding a segment joining the endpoint+-- of the first to the starting point of the second. Note, if you have+-- two located trails such that the end of the first coincides with the+-- start of the second, this will still add a trivial zero-length segment+-- between them; in that case you are probably better off with something+-- like @mapLoc (<> unLoc t2) t1@.+instance (Real n, Floating n, Metric v)+ => Semigroup (Located (Trail' Line v n)) where+ a@(Loc aLoc aLine) <> b@(Loc _ bLine) =+ Loc aLoc (aLine <> lineFromOffsets [atStart b .-. atEnd a] <> bLine)+ -------------------------------------------------- -- Extracting segments
src/Diagrams/TwoD/Segment.hs view
@@ -209,22 +209,32 @@ -> n -- ^ The upper bound of the interval -> [n] -- ^ The roots found bezierFindRoot eps p tmin tmax- | isNothing chopInterval = []- | clip > 0.8 = let (p1, p2) = splitAtParam newP 0.5- tmid = tmin' + (tmax' - tmin') / 2- in bezierFindRoot eps p1 tmin' tmid ++- bezierFindRoot eps p2 tmid tmax'- | tmax' - tmin' < eps = [avg tmin' tmax']- | otherwise = bezierFindRoot eps newP tmin' tmax'- where- chopInterval = chopYs (bernsteinCoeffs p)- Just (tminChop, tmaxChop) = chopInterval- newP = section p tminChop tmaxChop- clip = tmaxChop - tminChop- tmin' = tmax * tminChop + tmin * (1 - tminChop)- tmax' = tmax * tmaxChop + tmin * (1 - tmaxChop)--+ -- If we generated the max number of roots and tmax is also a root+ -- (which is not among the generated ones), there must in fact be an+ -- infinite number of roots, so just include tmax.+ | length roots == bernsteinDegree p && last roots /= tmax && abs (evaluateBernstein p tmax) <= eps+ = roots ++ [tmax]+ | otherwise = roots+ where+ -- Lazily take a number of roots at most the degree of the bernstein+ -- polynomial, to avoid generating a ton of roots in the case of a+ -- straight Bezier segment along the x-axis. See https://github.com/diagrams/diagrams-contrib/issues/91 .+ roots = take (bernsteinDegree p) $ go p tmin tmax+ go p tmin tmax+ | isNothing chopInterval = []+ | tmax' - tmin' < eps = [avg tmin' tmax']+ | clip > 0.8 = let (p1, p2) = splitAtParam newP 0.5+ tmid = tmin' + (tmax' - tmin') / 2+ in go p1 tmin' tmid +++ go p2 tmid tmax'+ | otherwise = bezierFindRoot eps newP tmin' tmax'+ where+ chopInterval = chopYs (bernsteinCoeffs p)+ Just (tminChop, tmaxChop) = chopInterval+ newP = section p tminChop tmaxChop+ clip = tmaxChop - tminChop+ tmin' = tmax * tminChop + tmin * (1 - tminChop)+ tmax' = tmax * tmaxChop + tmin * (1 - tmaxChop) ------------------------------------------------------------------------ -- Internal