packages feed

waterfall-cad-svg 0.8.0.0 → 0.9.0.0

raw patch · 6 files changed

+102/−66 lines, 6 filesdep ~opencascade-hsdep ~waterfall-cadPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: opencascade-hs, waterfall-cad

API changes (from Hackage documentation)

- Waterfall.SVG.FromSVG: instance GHC.Generics.Generic Waterfall.SVG.FromSVG.SVGError
- Waterfall.SVG.FromSVG: instance GHC.Generics.Generic Waterfall.SVG.FromSVG.SVGErrorKind
- Waterfall.SVG.FromSVG: instance GHC.Show.Show Waterfall.SVG.FromSVG.SVGError
- Waterfall.SVG.FromSVG: instance GHC.Show.Show Waterfall.SVG.FromSVG.SVGErrorKind
- Waterfall.SVG.ToSVG.LineStyle: instance GHC.Base.Monoid Waterfall.SVG.ToSVG.LineStyle.DiagramStyle
- Waterfall.SVG.ToSVG.LineStyle: instance GHC.Base.Monoid Waterfall.SVG.ToSVG.LineStyle.LineStyle
- Waterfall.SVG.ToSVG.LineStyle: instance GHC.Base.Semigroup Waterfall.SVG.ToSVG.LineStyle.DiagramStyle
- Waterfall.SVG.ToSVG.LineStyle: instance GHC.Base.Semigroup Waterfall.SVG.ToSVG.LineStyle.LineStyle
- Waterfall.SVG.ToSVG.LineStyle: instance GHC.Generics.Generic Waterfall.SVG.ToSVG.LineStyle.DiagramStyle
- Waterfall.SVG.ToSVG.LineStyle: instance GHC.Generics.Generic Waterfall.SVG.ToSVG.LineStyle.LineStyle
- Waterfall.SVG.ToSVG.LineStyle: instance GHC.Show.Show Waterfall.SVG.ToSVG.LineStyle.DiagramStyle
- Waterfall.SVG.ToSVG.LineStyle: instance GHC.Show.Show Waterfall.SVG.ToSVG.LineStyle.LineStyle
+ Waterfall.SVG.FromSVG: instance GHC.Internal.Generics.Generic Waterfall.SVG.FromSVG.SVGError
+ Waterfall.SVG.FromSVG: instance GHC.Internal.Generics.Generic Waterfall.SVG.FromSVG.SVGErrorKind
+ Waterfall.SVG.FromSVG: instance GHC.Internal.Show.Show Waterfall.SVG.FromSVG.SVGError
+ Waterfall.SVG.FromSVG: instance GHC.Internal.Show.Show Waterfall.SVG.FromSVG.SVGErrorKind
+ Waterfall.SVG.ToSVG.LineStyle: instance GHC.Internal.Base.Monoid Waterfall.SVG.ToSVG.LineStyle.DiagramStyle
+ Waterfall.SVG.ToSVG.LineStyle: instance GHC.Internal.Base.Monoid Waterfall.SVG.ToSVG.LineStyle.LineStyle
+ Waterfall.SVG.ToSVG.LineStyle: instance GHC.Internal.Base.Semigroup Waterfall.SVG.ToSVG.LineStyle.DiagramStyle
+ Waterfall.SVG.ToSVG.LineStyle: instance GHC.Internal.Base.Semigroup Waterfall.SVG.ToSVG.LineStyle.LineStyle
+ Waterfall.SVG.ToSVG.LineStyle: instance GHC.Internal.Generics.Generic Waterfall.SVG.ToSVG.LineStyle.DiagramStyle
+ Waterfall.SVG.ToSVG.LineStyle: instance GHC.Internal.Generics.Generic Waterfall.SVG.ToSVG.LineStyle.LineStyle
+ Waterfall.SVG.ToSVG.LineStyle: instance GHC.Internal.Show.Show Waterfall.SVG.ToSVG.LineStyle.DiagramStyle
+ Waterfall.SVG.ToSVG.LineStyle: instance GHC.Internal.Show.Show Waterfall.SVG.ToSVG.LineStyle.LineStyle

Files

CHANGELOG.md view
@@ -8,6 +8,17 @@  ## Unreleased +# 0.9.0.0++### Fixed++- Fixed a hang when reading relative quadratic Bezier commands ('t')+- Fixed support for `skew` transforms+- Fixed a bug where rounded rectangles were not positioned (ignored their `x` and `y` attributes) +- Fixed a bug where rounded rectangles with only one radius specified would not be treated as round+- Fixes to handling of control points in smooth curves to be closer in line to the svg spec +- Fixes to Arc commands ('a'/'A') where either radius is 0+ ## 0.8.0.0  ### Added
src/Waterfall/SVG/FromSVG.hs view
@@ -28,7 +28,7 @@ import Control.Exception (IOException, try) import Control.Monad (join, (<=<)) import Data.Bifunctor (first)-import Data.Maybe (catMaybes)+import Data.Maybe (catMaybes, fromMaybe) import Data.Function ((&)) import GHC.Generics (Generic) import Control.DeepSeq (NFData)@@ -45,7 +45,7 @@  instance NFData SVGErrorKind --- | Type representing an error that occured when processing an SVG+-- | Type representing an error that occurred when processing an SVG data SVGError = SVGError SVGErrorKind String         deriving (Eq, Ord, Show, Generic) @@ -54,17 +54,34 @@ uncurry6 :: (a -> b -> c -> d -> e -> f -> g) -> (a, b, c, d, e, f) -> g uncurry6 fn (a, b, c, d, e, f) = fn a b c d e f -pathFromToWithControlPoint :: [Maybe (V2 Double) -> V2 Double -> Either SVGError (Maybe (V2 Double), (V2 Double, Waterfall.Path2D))] -> V2 Double -> Either SVGError (V2 Double, Waterfall.Path2D)+data LastControlPoint = +    NoControlPoint +    | ControlPointQuadratic (V2 Double)+    | ControlPointCubic (V2 Double)++quadraticControlPoint :: LastControlPoint -> Maybe (V2 Double)+quadraticControlPoint (ControlPointQuadratic v) = Just v+quadraticControlPoint _ = Nothing++cubicControlPoint :: LastControlPoint -> Maybe (V2 Double)+cubicControlPoint (ControlPointCubic v) = Just v+cubicControlPoint _ = Nothing++pathFromToWithControlPoint :: [LastControlPoint -> V2 Double -> Either SVGError (LastControlPoint, (V2 Double, Waterfall.Path2D))] -> V2 Double -> Either SVGError (V2 Double, Waterfall.Path2D) pathFromToWithControlPoint commands start =      let go (cp, (pos, paths)) cmd = second (second (:paths)) <$> cmd cp pos         go' b a = join (go <$> b <*> pure a)-    in case foldl' go' (Right (Nothing, (start, []))) commands of+    in case foldl' go' (Right (NoControlPoint, (start, []))) commands of         Right (_cp, (end, allPaths)) -> Right (end, mconcat . reverse $ allPaths)         Left err -> Left err  ellipseToRelative :: Double -> Double -> Double -> Bool -> Bool -> V2 Double -> V2 Double -> (V2 Double, Waterfall.Path2D)-ellipseToRelative rx ry angleDeg largeArcFlag sweepFlag relativeEnd =+ellipseToRelative rx' ry' angleDeg largeArcFlag sweepFlag relativeEnd +    | rx' == 0 || ry' == 0 = Waterfall.lineRelative relativeEnd+    | otherwise =      let angleRads = angleDeg * pi / 180+        ry = abs ry'+        rx = abs rx'         scaleFac = ry / rx         transformForward :: Waterfall.Transformable2D a => a -> a         transformForward = Waterfall.rotate2D (angleRads) . Waterfall.scale2D (V2 (1/scaleFac) 1)@@ -80,48 +97,47 @@         centerPerpDistance = sqrt (radius * radius - halfTD * halfTD)         center = (relativeEndTransformed ^* 0.5) + (p1 ^* centerPerpDistance)         midPoint = center + (p2 ^* radius)-        -        in Waterfall.splice . transformForward $ Waterfall.arcVia zero midPoint relativeEndTransformed +    in Waterfall.splice . transformForward $ Waterfall.arcVia zero midPoint relativeEndTransformed   quadraticBezierAbsolute :: V2 Double -> V2 Double -> V2 Double -> (V2 Double, Waterfall.Path2D) quadraticBezierAbsolute p0 p1 p2 = (p2, Waterfall.bezier2D p0 (p0 + ((p1 - p0) ^* (2/3))) (p2 + ((p1 - p2) ^* (2/3))) p2) -curveToAbsolute :: (V2 Double, V2 Double, V2 Double) -> Maybe (V2 Double) -> V2 Double -> Either SVGError (Maybe (V2 Double), (V2 Double, Waterfall.Path2D))-curveToAbsolute (cp1, cp2, cp3) _ cp0 = Right (Just (cp3 + cp3 - cp2), Waterfall.bezierTo2D cp1 cp2 cp3 cp0)+curveToAbsolute :: (V2 Double, V2 Double, V2 Double) -> LastControlPoint -> V2 Double -> Either SVGError (LastControlPoint, (V2 Double, Waterfall.Path2D))+curveToAbsolute (cp1, cp2, cp3) _ cp0 = Right (ControlPointCubic (cp3 + cp3 - cp2), Waterfall.bezierTo2D cp1 cp2 cp3 cp0) -curveToRelative :: (V2 Double, V2 Double, V2 Double) -> Maybe (V2 Double) -> V2 Double -> Either SVGError (Maybe (V2 Double), (V2 Double, Waterfall.Path2D))-curveToRelative (cp1, cp2, cp3) _ cp0 = curveToAbsolute (cp0 + cp1, cp0 + cp2, cp0 + cp3) Nothing cp0+curveToRelative :: (V2 Double, V2 Double, V2 Double) -> LastControlPoint -> V2 Double -> Either SVGError (LastControlPoint, (V2 Double, Waterfall.Path2D))+curveToRelative (cp1, cp2, cp3) _ cp0 = curveToAbsolute ((cp0 + cp1), cp0 + cp2, cp0 + cp3) NoControlPoint cp0 -quadraticBezierAbsolute' :: (V2 Double, V2 Double) -> Maybe (V2 Double) -> V2 Double -> Either SVGError (Maybe (V2 Double), (V2 Double, Waterfall.Path2D))-quadraticBezierAbsolute' (cp1, cp2) _ cp0 = Right (Just (cp2 + cp2 - cp1), quadraticBezierAbsolute cp0 cp1 cp2)+quadraticBezierAbsolute' :: (V2 Double, V2 Double) -> LastControlPoint -> V2 Double -> Either SVGError (LastControlPoint, (V2 Double, Waterfall.Path2D))+quadraticBezierAbsolute' (cp1, cp2) _ cp0 = Right (ControlPointQuadratic (cp2 + cp2 - cp1), quadraticBezierAbsolute cp0 cp1 cp2) -quadraticBezierRelative' :: (V2 Double, V2 Double) -> Maybe (V2 Double) -> V2 Double -> Either SVGError (Maybe (V2 Double), (V2 Double, Waterfall.Path2D))-quadraticBezierRelative' (cp1, cp2) _ cp0 = quadraticBezierAbsolute' (cp0 + cp1, cp0 + cp2) Nothing cp0+quadraticBezierRelative' :: (V2 Double, V2 Double) -> LastControlPoint -> V2 Double -> Either SVGError (LastControlPoint, (V2 Double, Waterfall.Path2D))+quadraticBezierRelative' (cp1, cp2) _ cp0 = quadraticBezierAbsolute' (cp0 + cp1, cp0 + cp2) NoControlPoint cp0  ellipseToAbsolute :: Double -> Double -> Double -> Bool -> Bool -> V2 Double -> V2 Double -> (V2 Double, Waterfall.Path2D) ellipseToAbsolute rx ry angleDeg largeArcFlag sweepFlag absoluteEnd start =     ellipseToRelative rx ry angleDeg largeArcFlag sweepFlag (absoluteEnd - start) start -smoothCurveToAbsolute :: (V2 Double, V2 Double) -> Maybe (V2 Double) -> V2 Double -> Either SVGError (Maybe (V2 Double), (V2 Double, Waterfall.Path2D))-smoothCurveToAbsolute _ Nothing _ = Left (SVGError SVGPathError "S command must follow either an S, s, C or c command")-smoothCurveToAbsolute (cp2, cp3) (Just cp1) cp0 = Right (Just (cp3 + cp3 - cp2), Waterfall.bezierTo2D cp1 cp2 cp3 cp0) +smoothCurveToAbsolute :: (V2 Double, V2 Double) -> LastControlPoint -> V2 Double -> Either SVGError (LastControlPoint, (V2 Double, Waterfall.Path2D))+smoothCurveToAbsolute (cp2, cp3) cp1' cp0 = +    let cp1 = fromMaybe cp0 (cubicControlPoint cp1')+    in Right (ControlPointCubic (cp3 + cp3 - cp2), Waterfall.bezierTo2D cp1 cp2 cp3 cp0)  -smoothCurveToRelative ::  (V2 Double, V2 Double) -> Maybe (V2 Double) -> V2 Double -> Either SVGError (Maybe (V2 Double), (V2 Double, Waterfall.Path2D))-smoothCurveToRelative _ Nothing _ = Left (SVGError SVGPathError "s command must follow either an S, s, C or c command")+smoothCurveToRelative ::  (V2 Double, V2 Double) -> LastControlPoint -> V2 Double -> Either SVGError (LastControlPoint, (V2 Double, Waterfall.Path2D)) smoothCurveToRelative (cp2, cp3) cp1 cp0 = smoothCurveToAbsolute (cp0 + cp2, cp0 + cp3) cp1 cp0 -smoothQuadraticBezierCurveToAbsolute :: V2 Double -> Maybe (V2 Double) -> V2 Double -> Either SVGError (Maybe (V2 Double), (V2 Double, Waterfall.Path2D))-smoothQuadraticBezierCurveToAbsolute _ Nothing _ = Left (SVGError SVGPathError "T command must follow either an T, t, Q or q command")-smoothQuadraticBezierCurveToAbsolute cp2 (Just cp1) cp0 = Right (Just (cp2 + cp2 - cp1), quadraticBezierAbsolute cp0 cp1 cp2)+smoothQuadraticBezierCurveToAbsolute :: V2 Double -> LastControlPoint -> V2 Double -> Either SVGError (LastControlPoint, (V2 Double, Waterfall.Path2D))+smoothQuadraticBezierCurveToAbsolute cp2 cp1' cp0 = +    let cp1 = fromMaybe cp0 (quadraticControlPoint cp1') +    in Right (ControlPointQuadratic (cp2 + cp2 - cp1), quadraticBezierAbsolute cp0 cp1 cp2) -smoothQuadraticBezierCurveToRelative :: V2 Double -> Maybe (V2 Double) -> V2 Double -> Either SVGError (Maybe (V2 Double), (V2 Double, Waterfall.Path2D))-smoothQuadraticBezierCurveToRelative _ Nothing _ = Left (SVGError SVGPathError "t command must follow either an T, t, Q or q command")-smoothQuadraticBezierCurveToRelative cp2 cp1 cp0 = smoothQuadraticBezierCurveToRelative (cp0 + cp2) cp1 cp0+smoothQuadraticBezierCurveToRelative :: V2 Double -> LastControlPoint -> V2 Double -> Either SVGError (LastControlPoint, (V2 Double, Waterfall.Path2D))+smoothQuadraticBezierCurveToRelative cp2 cp1 cp0 = smoothQuadraticBezierCurveToAbsolute (cp0 + cp2) cp1 cp0  -- | Generate `Waterfall.Path2D`s from a parsed list of `Svg.PathCommand`s. -- --- Consective `Svg.PathCommands` will be merged into the same `Waterfall.Path2D` --- unless either a move command ('m', 'M') or a close path command ('z', 'Z') is encountered.+-- Consecutive `Svg.PathCommand`s will be merged into the same `Waterfall.Path2D` +-- unless either a move command @(\'m\', \'M\')@ or a close path command @(\'z\', \'Z\')@ is encountered. convertPathCommands :: [Svg.PathCommand] -> Either SVGError [Waterfall.Path2D] convertPathCommands cs =     let@@ -129,7 +145,7 @@         relativeLocation curPos Svg.OriginRelative v = curPos + v         buildPathInProgress (origin, segments) =              pathFromToWithControlPoint segments origin-        withoutControlPoint f _cp o = Right (Nothing, f o)+        withoutControlPoint f _cp o = Right (NoControlPoint, f o)         go (cmd:rest) pathInProgress@(o, segments) paths =              let goSegment ss = go rest (o, segments <> ss) paths               in case cmd of@@ -181,7 +197,7 @@     in reverse <$> go cs (zero, []) []  -- | Parse [SVG Path data](https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths) --- and convert it into a `Path2D`+-- and convert it into a `Waterfall.Path2D` parsePath :: String -> Either SVGError [Waterfall.Path2D] parsePath s =     case Atto.parseOnly (pathParser <* Atto.endOfInput) (T.pack s) of @@ -191,7 +207,7 @@ -- | Parse a `Svg.Transformation` into a function that can be applied to  -- any Waterfall type with a `Waterfall.Transformable2D` instance -- --- This should handle every case except for `TransformUnknown`+-- This should handle every case except for `Svg.TransformUnknown` convertTransform :: Waterfall.Transformable2D a => Svg.Transformation -> Either SVGError (a -> a) convertTransform (Svg.TransformMatrix a b c d e f) = Right $ Waterfall.matTransform2D (V2 (V3 a c e) (V3 b d f)) convertTransform (Svg.Translate x y) = Right $ Waterfall.translate2D (V2 x y)@@ -203,8 +219,12 @@         angleRad = angleDeg * pi / 180         back = Waterfall.translate2D center'      in Right (back . Waterfall.rotate2D angleRad . fwd)-convertTransform (Svg.SkewX x) = Right $ Waterfall.matTransform2D (V2 (V3 x 0 0) (V3 0 1 0))-convertTransform (Svg.SkewY y) = Right $ Waterfall.matTransform2D (V2 (V3 1 0 0) (V3 0 y 0))+convertTransform (Svg.SkewX angle) =+    let t = tan (angle * pi / 180)+    in Right $ Waterfall.matTransform2D (V2 (V3 1 t 0) (V3 0 1 0))+convertTransform (Svg.SkewY angle) =+    let t = tan (angle * pi / 180)+    in Right $ Waterfall.matTransform2D (V2 (V3 1 0 0) (V3 t 1 0)) convertTransform Svg.TransformUnknown = Left . (SVGError SVGTransformError) $ "Unknown Transform"  chain :: [a -> a] -> a -> a@@ -274,7 +294,9 @@ convertRectangle :: Svg.Rectangle -> Either SVGError [Waterfall.Path2D] convertRectangle rect = do     upperLeft <- convertPoint (rect ^. Svg.rectUpperLeftCorner)    -    (rX', rY') <- each convertNumber (rect ^. Svg.rectCornerRadius)+    (rX'', rY'') <- each convertNumber (rect ^. Svg.rectCornerRadius)+    let rX' = if rX'' == 0 then rY'' else rX''+    let rY' = if rY'' == 0 then rX'' else rY''     w <- convertNumber (rect ^. Svg.rectWidth)     h <- convertNumber (rect ^. Svg.rectHeight)     let rX = min rX' (w/2)@@ -289,7 +311,9 @@                 Waterfall.translate2D upperLeft &                 Waterfall.shapePaths &                  return-        else return . pure . Waterfall.pathFrom (V2 rX 0) . catMaybes $+        else return . pure +                . Waterfall.translate2D upperLeft +                . Waterfall.pathFrom (V2 rX 0) . catMaybes $                 [ if w' > 0 then Just (Waterfall.lineRelative (w' *^ unit _x)) else Nothing                 , quarterCircle                      & scaleBevel @@ -333,7 +357,7 @@         Svg.RectangleTree rectangle -> convertRectangle rectangle         _ -> Right [] --- | Convert an `Svg.Document` into a list of `Path2Ds`+-- | Convert an `Svg.Document` into a list of `Waterfall.Path2D`s convertDocument :: Svg.Document -> Either SVGError [Waterfall.Path2D] convertDocument doc = fmap mconcat . traverse convertTree $ (doc ^. Svg.elements)  
src/Waterfall/SVG/ToSVG.hs view
@@ -16,7 +16,7 @@ import qualified Graphics.Svg as Svg import qualified Graphics.Svg.CssTypes as Svg.Css import Waterfall.Internal.NearZero (nearZero)-import Linear (_xy, _x, _y, V2 (..))+import Linear (_xy, _x, _y, V2 (..), V3 (..)) import Control.Lens ((^.), (&), (.~), (<&>)) import Foreign.Ptr (Ptr) import Control.Monad ((<=<)) @@ -94,7 +94,7 @@ bezierToPathCommand edge curve = do      firstParam <- liftIO $ BRep.Tool.curveParamFirst edge     lastParam <- liftIO $ BRep.Tool.curveParamLast edge-    bezier <- BRepAdaptor.Curve.bezier curve+    bezier <- Geom.BezierCurve.copy =<< BRepAdaptor.Curve.bezier curve     liftIO $ Geom.BezierCurve.segment bezier firstParam lastParam      bezierCurveToPathCommand edge bezier @@ -164,13 +164,14 @@         . Waterfall.shapePaths       colourToPixel :: Waterfall.Colour -> PixelRGBA8-colourToPixel (Waterfall.Colour r g b) =-    let conv = round . (* 255) . min 1 . max 0+colourToPixel c =+    let V3 r g b = Waterfall.sRGBComponents c+        conv = round . (* 255) . min 1 . max 0      in PixelRGBA8 (conv r) (conv g) (conv b) 255  fillToPath :: (Waterfall.Paint, Waterfall.Shape) -> Svg.Path fillToPath (paint, shape) =-    let colour = fromMaybe (Waterfall.Colour 1 1 1) (paint ^. Waterfall.paintColour <|> Waterfall.defaultPaint ^. Waterfall.paintColour)+    let colour = fromMaybe (Waterfall.white) (paint ^. Waterfall.paintColour <|> Waterfall.defaultPaint ^. Waterfall.paintColour)         opacity = fromMaybe (1.0)  (paint ^. Waterfall.paintOpacity <|> Waterfall.defaultPaint ^. Waterfall.paintOpacity)         setOpacity = if opacity == 1.0              then id @@ -181,7 +182,7 @@         & Svg.drawAttr . Svg.fillColor .~ (pure . Svg.ColorRef . colourToPixel $ colour)         & setOpacity         --- | Convert a `Waterfall.Path2D` into a list of `Svg.PathCommands`+-- | Convert a `Waterfall.Path2D` into a list of `Svg.PathCommand`s path2DToPathCommands :: Waterfall.Path2D -> [Svg.PathCommand] path2DToPathCommands (Path2D theRawPath) = case theRawPath of       Internal.Path.Common.EmptyRawPath -> []@@ -204,7 +205,7 @@ lineStyleCss style =     let resolve l fallback line defaultLine = fromMaybe fallback (line ^. l <|> defaultLine ^. l)         strokeDeclarations line defaultLine =-            [ Svg.Css.CssDeclaration "stroke" [[Svg.Css.CssColor . colourToPixel $ resolve lineColour (Waterfall.Colour 0 0 0) line defaultLine]]+            [ Svg.Css.CssDeclaration "stroke" [[Svg.Css.CssColor . colourToPixel $ resolve lineColour Waterfall.black line defaultLine]]             , Svg.Css.CssDeclaration "stroke-opacity" [[Svg.Css.CssNumber . Svg.Num $ resolve lineOpacity 1 line defaultLine]]             , Svg.Css.CssDeclaration "stroke-width" [[Svg.Css.CssNumber . Svg.Num $ resolve lineWidth 1 line defaultLine]]             ]@@ -234,7 +235,7 @@ -- The diagram fills have the class "fill" diagramToSvgWithLineStyle :: DiagramStyle -> Waterfall.Diagram -> Svg.Document diagramToSvgWithLineStyle lineStyle diagram = -    case Waterfall.diagramBoundingBox diagram of +    case Waterfall.axisAlignedBoundingBox2D diagram of          Nothing -> Svg.Document Nothing Nothing Nothing [] mempty mempty mempty mempty         Just (lo, hi) ->              let 
src/Waterfall/SVG/ToSVG/LineStyle.hs view
@@ -177,12 +177,12 @@ defaultDiagramStyle :: DiagramStyle defaultDiagramStyle = DiagramStyle     { _visibleLine = LineStyle -        { _lineColour = Last . Just $ Waterfall.Colour 0 0 0+        { _lineColour = Last . Just $ Waterfall.black         , _lineOpacity = Last . Just $ 1         , _lineWidth = Last . Just $ 1         }     , _hiddenLine = LineStyle -        { _lineColour = Last . Just $ Waterfall.Colour 0 0 0+        { _lineColour = Last . Just $ Waterfall.black         , _lineOpacity = Last . Just $ 0.4         , _lineWidth = Last . Just $ 1         }
test/LineStyleTests.hs view
@@ -3,7 +3,7 @@ ) where  import Waterfall.SVG.ToSVG.LineStyle-import Waterfall.Colour (Colour (..))+import qualified Waterfall.Colour as Colour import Control.Lens ((^.)) import Test.Tasty (TestTree, testGroup) import Test.Tasty.HUnit@@ -22,25 +22,25 @@      , testCase "single property" $         assertEqual ""-            "lineWithColour (Colour 1.0 0.0 0.0)"-            (show (lineWithColour (Colour 1 0 0)))+            "lineWithColour (rgb24 0xff0000)"+            (show (lineWithColour (Colour.rgb24 0xFF0000)))      , testCase "combined properties" $         assertEqual ""-            "lineWithColour (Colour 0.0 0.0 1.0) <> lineWithOpacity 0.5"+            "lineWithColour (rgb24 0x0000ff) <> lineWithOpacity 0.5"             (show                 (lineWithOpacity 0.5-                <> lineWithColour (Colour 1 0 0)-                <> lineWithColour (Colour 0 0 1)+                <> lineWithColour (Colour.rgb24 0xFF0000)+                <> lineWithColour (Colour.rgb24 0x0000FF)                 ))      , testCase "all properties" $         assertEqual ""-            "lineWithColour (Colour 1.0 0.0 0.0) <> lineWithOpacity 0.5 <> lineWithWidth 2.0"+            "lineWithColour (rgb24 0xff0000) <> lineWithOpacity 0.5 <> lineWithWidth 2.0"             (show                 (lineWithWidth 2                 <> lineWithOpacity 0.5-                <> lineWithColour (Colour 1 0 0)+                <> lineWithColour (Colour.rgb24 0xFF0000)                 ))      , testCase "negative argument in brackets" $@@ -71,8 +71,8 @@      , testCase "hidden line only, with combined properties" $         assertEqual ""-            "diagramWithHiddenLine (lineWithColour (Colour 0.0 0.0 0.0) <> lineWithOpacity 0.4)"-            (show (diagramWithHiddenLine (lineWithColour (Colour 0 0 0) <> lineWithOpacity 0.4)))+            "diagramWithHiddenLine (lineWithColour (rgb24 0x000000) <> lineWithOpacity 0.4)"+            (show (diagramWithHiddenLine (lineWithColour (Colour.rgb24 0x000000) <> lineWithOpacity 0.4)))      , testCase "both lines" $         assertEqual ""@@ -84,12 +84,12 @@      , testCase "repeated lines are merged" $         assertEqual ""-            "diagramWithVisibleLine (lineWithColour (Colour 1.0 0.0 0.0) <> lineWithWidth 2.0) <> diagramWithHiddenLine (lineWithOpacity 0.4)"+            "diagramWithVisibleLine (lineWithColour (rgb24 0xff0000) <> lineWithWidth 2.0) <> diagramWithHiddenLine (lineWithOpacity 0.4)"             (show                 (diagramWithVisibleLine (lineWithWidth 2)                 <> diagramWithHiddenLine (lineWithOpacity 0.4)-                <> diagramWithVisibleLine (lineWithColour (Colour 1 0 0))-                ))+                <> diagramWithVisibleLine (lineWithColour (Colour.rgb24 0xFF0000)+                )))      , testCase "visible line only in brackets when used as an argument" $         assertEqual ""@@ -107,14 +107,14 @@      , testCase "defaultStyle" $         assertEqual ""-            "diagramWithVisibleLine (lineWithColour (Colour 0.0 0.0 0.0) <> lineWithOpacity 1.0 <> lineWithWidth 1.0) <> diagramWithHiddenLine (lineWithColour (Colour 0.0 0.0 0.0) <> lineWithOpacity 0.4 <> lineWithWidth 1.0)"+            "diagramWithVisibleLine (lineWithColour (rgb24 0x000000) <> lineWithOpacity 1.0 <> lineWithWidth 1.0) <> diagramWithHiddenLine (lineWithColour (rgb24 0x000000) <> lineWithOpacity 0.4 <> lineWithWidth 1.0)"             (show defaultDiagramStyle)     ]  lensTests :: TestTree lensTests = testGroup "lenses"     [ testCase "lineColour" $-        assertEqual "" (Just (Colour 1 0 0)) (lineWithColour (Colour 1 0 0) ^. lineColour)+        assertEqual "" (Just Colour.red) (lineWithColour Colour.red ^. lineColour)      , testCase "lineOpacity" $         assertEqual "" (Just 0.5) (lineWithOpacity 0.5 ^. lineOpacity)
waterfall-cad-svg.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           waterfall-cad-svg-version:        0.8.0.0+version:        0.9.0.0 synopsis:       Declarative CAD/Solid Modeling Library, SVG Support description:    Please see the README on GitHub at <https://github.com/joe-warren/opencascade-hs#readme> category:       Graphics@@ -47,11 +47,11 @@     , deepseq >=1.4 && <2     , lens ==5.*     , linear >=1.0 && <2-    , opencascade-hs >=0.8.0.0 && <0.9+    , opencascade-hs >=0.9.0.0 && <0.10     , resourcet >=1.2 && <1.4     , svg-tree >=0.6 && <1     , text >=1.2 && <3-    , waterfall-cad >=0.8.0.0 && <0.9+    , waterfall-cad >=0.9.0.0 && <0.10   default-language: Haskell2010  test-suite tests@@ -70,12 +70,12 @@     , deepseq >=1.4 && <2     , lens ==5.*     , linear >=1.0 && <2-    , opencascade-hs >=0.8.0.0 && <0.9+    , opencascade-hs >=0.9.0.0 && <0.10     , resourcet >=1.2 && <1.4     , svg-tree >=0.6 && <1     , tasty     , tasty-hunit     , text >=1.2 && <3-    , waterfall-cad >=0.8.0.0 && <0.9+    , waterfall-cad >=0.9.0.0 && <0.10     , waterfall-cad-svg   default-language: Haskell2010