Permalink
Browse files

Merge pull request #88 from shkoo/master

Add viewBox entry to svg files (colah/ImplicitCAD#83)
  • Loading branch information...
2 parents f6480b2 + e8d9bdd commit ac4f23067a3ae87e48f786097116a08ebd088987 @colah committed Dec 19, 2012
Showing with 2 additions and 1 deletion.
  1. +2 −1 Graphics/Implicit/Export/PolylineFormats.hs
@@ -15,7 +15,7 @@ import Text.Blaze.Svg11 ((!),docTypeSvg,g,polyline,toValue)
import Text.Blaze.Internal (stringValue)
import qualified Text.Blaze.Svg11.Attributes as A
-import Data.List (foldl')
+import Data.List (foldl',intersperse)
import qualified Data.List as List
svg :: [Polyline] -> Text
@@ -27,6 +27,7 @@ svg plines = renderSvg . svg11 . svg' $ plines
svg11 content = docTypeSvg ! A.version "1.1"
! A.width (stringValue $ show (xmax-xmin) ++ "mm")
! A.height (stringValue $ show (ymax-ymin) ++ "mm")
+ ! A.viewbox (stringValue $ concat . intersperse " " . map show $ [xmin, xmax, ymin, ymax])
$ content
-- The reason this isn't totally straightforwards is that svg has different coordinate system
-- and we need to compute the requisite translation.

0 comments on commit ac4f230

Please sign in to comment.