SVGPath 1.0.2 → 1.0.3
raw patch · 2 files changed
+13/−10 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- SVGPath.cabal +3/−3
- src/Graphics/SVG/ReadPath.hs +10/−7
SVGPath.cabal view
@@ -1,7 +1,7 @@ Name: SVGPath -Version: 1.0.2 -Synopsis: Parsing the path command from SVG -Description: Parsing the path command from SVG +Version: 1.0.3 +Synopsis: Parsing the path command of SVG +Description: Parsing the path command of SVG category: Graphics License: BSD3 License-file: LICENSE
src/Graphics/SVG/ReadPath.hs view
@@ -1,7 +1,7 @@ -------------------------------------------------------------------- -- | -- Module : Graphics.SVG.ReadPath --- Copyright : (c) 2010 Tillmann Vogt +-- Copyright : (c) 2011 Tillmann Vogt -- License : BSD3 -- -- Maintainer: Tillmann Vogt <Tillmann.Vogt@rwth-aachen.de> @@ -23,6 +23,7 @@ import Text.ParserCombinators.Parsec.Expr import qualified Text.ParserCombinators.Parsec.Token as P import Text.ParserCombinators.Parsec.Language( javaStyle ) +import System.IO.Unsafe (unsafePerformIO) type X = Float type Y = Float @@ -141,9 +142,11 @@ ctp :: [PathCommand] -> [F2] -> F2 -> Bool -> Int -> F2 -> [[F2]] ctp [] _ _ _ _ _ = [] ctp (c:commands) points lastContr useTex n (dx, dy) -- dx, dy is the size of a pixel, used for rasterisation - | (length nextPoints) == 0 = [tail points] ++ ( ctp commands nextPoints (contr c) useTex (if n>0 then n-1 else 0) (dx,dy) ) - | otherwise = ctp commands (points ++ nextPoints) (contr c) useTex (if n>0 then n-1 else 0) (dx,dy) - where nextPoints = (go c) + | (length nextPoints) == 0 = [tail $ tail points] ++ -- one outline completed + ( ctp commands [] (contr c) useTex nminus (dx,dy) ) + | otherwise = ctp commands (points ++ (tail nextPoints)) (contr c) useTex nminus (dx,dy) + where nminus = if n>0 then n-1 else 0 + nextPoints = (go c) contr ( C_abs (x1,y1,x2,y2,x,y) ) = ( (x+x-x2)/dx, (y+y-y2)/dy ) -- control point of bezier curve contr ( C_rel (x1,y1,x2,y2,x,y) ) = (x0+(x+x-x2)/dx, y0+(y+y-y2)/dy ) contr ( S_abs (x2,y2,x,y) ) = ( (x+x-x2)/dx, (y+y-y2)/dy ) @@ -162,8 +165,8 @@ contr ( V_rel y ) = (x0, y0 + y/dy ) go ( L_abs (x,y) ) = bsub [(x0,y0), (x/dx, y/dy)] go ( L_rel (x,y) ) = bsub [(x0,y0), (x0 + x/dx, y0 + y/dy)] - go ( M_abs (x,y) ) = [(x/dx, y/dy)] - go ( M_rel (x,y) ) = [(x0 + x/dx, y0 + y/dy)] + go ( M_abs (x,y) ) = [(0, 0), (x/dx, y/dy)] + go ( M_rel (x,y) ) = [(0, 0), (x0 + x/dx, y0 + y/dy)] go ( H_abs x) = bsub [(x0,y0), (x/dx, y0)] go ( H_rel x) = bsub [(x0,y0), (x0 + x/dx, y0)] go ( V_abs y) = bsub [(x0,y0), (x0, y/dy)] @@ -210,7 +213,7 @@ ((abs (p1x-p0x)) < 1 && p0x_int == p1x_int && useTex) || -- vertical line ((abs (p1y-p0y)) < 1 && p0y_int == p1y_int && useTex) -- horizontal line = [ (p0x, p0y), (p1x, p1y) ] - | otherwise = firstArc ++ secondArc -- tail secondArc -- subdivide + | otherwise = firstArc ++ (tail secondArc) -- subdivide where firstArc = bSubCurve useTex (dx,dy) (take l twoArcs) secondArc = bSubCurve useTex (dx,dy) (drop (l-1) twoArcs)