diagrams-svg 1.5 → 1.5.1
raw patch · 3 files changed
+38/−10 lines, 3 filesdep −colourdep −monoid-extrasdep −semigroupsdep ~basedep ~containersdep ~diagrams-libPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies removed: colour, monoid-extras, semigroups
Dependency ranges changed: base, containers, diagrams-lib
API changes (from Hackage documentation)
+ Diagrams.Backend.SVG: elementToDiagram :: Element -> Diagram B
+ Diagrams.Backend.SVG: instance Diagrams.Core.Transform.Transformable Graphics.Svg.Core.Element
+ Diagrams.Backend.SVG: instance Diagrams.Core.Types.Renderable Graphics.Svg.Core.Element Diagrams.Backend.SVG.B
- Diagrams.Backend.SVG: generateDoctype :: Lens' (Options SVG V2 n) Bool
+ Diagrams.Backend.SVG: generateDoctype :: forall n f. Functor f => (Bool -> f Bool) -> Options SVG V2 n -> f (Options SVG V2 n)
- Diagrams.Backend.SVG: idPrefix :: Lens' (Options SVG V2 n) Text
+ Diagrams.Backend.SVG: idPrefix :: forall n f. Functor f => (Text -> f Text) -> Options SVG V2 n -> f (Options SVG V2 n)
- Diagrams.Backend.SVG: sizeSpec :: Lens' (Options SVG V2 n) (SizeSpec V2 n)
+ Diagrams.Backend.SVG: sizeSpec :: forall n f. Functor f => (SizeSpec V2 n -> f (SizeSpec V2 n)) -> Options SVG V2 n -> f (Options SVG V2 n)
- Diagrams.Backend.SVG: svgAttributes :: Lens' (Options SVG V2 n) [Attribute]
+ Diagrams.Backend.SVG: svgAttributes :: forall n f. Functor f => ([Attribute] -> f [Attribute]) -> Options SVG V2 n -> f (Options SVG V2 n)
- Diagrams.Backend.SVG: svgDefinitions :: Lens' (Options SVG V2 n) (Maybe Element)
+ Diagrams.Backend.SVG: svgDefinitions :: forall n f. Functor f => (Maybe Element -> f (Maybe Element)) -> Options SVG V2 n -> f (Options SVG V2 n)
Files
- CHANGELOG.md +16/−0
- diagrams-svg.cabal +6/−10
- src/Diagrams/Backend/SVG.hs +16/−0
CHANGELOG.md view
@@ -1,3 +1,19 @@+## [v1.5.1](https://github.com/diagrams/diagrams-svg/tree/v1.5.1) (2026-10-14)++- Allow embedding SVG elements as primitives, via new+ `elementToDiagram` function ([#126](https://github.com/diagrams/diagrams-svg/pull/126); thanks to George Thomas)++- Allow `base-4.22` (GHC 9.14), `containers-0.8`, `diagrams-lib-1.6`+- Remove some unneeded dependencies (`monoid-extras`, `colour`, `semigroups`)++## [v1.5-r2](https://github.com/diagrams/diagrams-svg/tree/v1.5-r2) (2025-06-13)++- Allow `optparse-applicative-0.19`++## [v1.5-r1](https://github.com/diagrams/diagrams-svg/tree/v1.5-r1) (2025-06-02)++- Allow `monoid-extras-0.7`+ ## [v1.5](https://github.com/diagrams/diagrams-svg/tree/v1.5) (2025-03-25) - Allow `base-4.21` and test on GHC 9.12
diagrams-svg.cabal view
@@ -1,5 +1,5 @@ Name: diagrams-svg-Version: 1.5+Version: 1.5.1 Synopsis: SVG backend for diagrams drawing EDSL. Homepage: https://diagrams.github.io/ License: BSD3@@ -12,7 +12,7 @@ Category: Graphics Build-type: Simple Cabal-version: >=1.10-Tested-with: GHC ==8.4.4 || ==8.6.5 || ==8.8.4 || ==8.10.7 || ==9.0.2 || ==9.2.8 || ==9.4.8 || ==9.6.5 || ==9.8.2 || ==9.10.1 || ==9.12.1+Tested-with: GHC ==8.4.4 || ==8.6.5 || ==8.8.4 || ==8.10.7 || ==9.0.2 || ==9.2.8 || ==9.4.8 || ==9.6.7 || ==9.8.4 || ==9.10.3 || ==9.12.4 || ==9.14.1 Description: This package provides a modular backend for rendering diagrams created with the diagrams EDSL to SVG files. It uses @svg-builder@ to be a native@@ -40,25 +40,21 @@ Diagrams.Backend.SVG.CmdLine Other-modules: Graphics.Rendering.SVG Hs-source-dirs: src- Build-depends: base >= 4.7 && < 4.22+ Build-depends: base >= 4.7 && < 4.23 , filepath >= 1.4 && < 1.6 , mtl >= 1 && < 2.4 , bytestring >= 0.9 && < 1.0 , base64-bytestring >= 1 && < 1.3- , colour >= 2.3 && < 2.4 , diagrams-core >= 1.4 && < 1.6- , diagrams-lib >= 1.4.5 && < 1.6- , monoid-extras >= 0.3 && < 0.7+ , diagrams-lib >= 1.4.5 && < 1.7 , svg-builder >= 0.1 && < 0.2 , text >= 0.11 && < 2.2 , JuicyPixels >= 3.1.5 && < 3.4 , split >= 0.1.2 && < 0.3- , containers >= 0.3 && < 0.8+ , containers >= 0.3 && < 0.9 , lens >= 4.0 && < 5.4 , hashable >= 1.1 && < 1.6- , optparse-applicative >= 0.13 && < 0.19- , semigroups >= 0.13 && < 0.21-+ , optparse-applicative >= 0.13 && < 0.20 Ghc-options: -Wall Default-language: Haskell2010
src/Diagrams/Backend/SVG.hs view
@@ -108,6 +108,8 @@ , renderPretty , renderPretty' , loadImageSVG++ , elementToDiagram ) where -- from JuicyPixels@@ -142,6 +144,7 @@ -- from diagrams-core import Diagrams.Core.Compile+import Diagrams.Core.Transform (matrixHomRep) import Diagrams.Core.Types (Annotation (..), keyVal) -- from diagrams-lib@@ -193,6 +196,19 @@ -- | Monad to keep track of environment and state when rendering an SVG. type SvgRenderM n = ReaderT (Environment n) (State SvgRenderState) Element++type instance V Element = V2+type instance N Element = Double+instance Transformable Element where+ transform t = flip with [Transform_ <<- transformMatrix]+ where+ [[a,b],[c,d],[e,f]] = matrixHomRep t+ transformMatrix = matrix a b c d e f+instance Renderable Element B where+ render SVG = R . pure++elementToDiagram :: Element -> Diagram B+elementToDiagram e = mkQD (Prim e) mempty mempty mempty mempty runRenderM :: SVGFloat n => T.Text -> SvgRenderM n -> Element runRenderM o s = flip evalState initialSvgRenderState