From ff8e3cd1401dedef3ed6d40ebf39a283c62b5f17 Mon Sep 17 00:00:00 2001 From: Jan Bracker Date: Fri, 23 Aug 2013 10:20:52 +0200 Subject: [PATCH 1/2] Added Default instances for FillRule and FillRuleA. Added show instance for FillRule. --- src/Diagrams/TwoD/Path.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Diagrams/TwoD/Path.hs b/src/Diagrams/TwoD/Path.hs index 99cecd88..b58e0ae6 100644 --- a/src/Diagrams/TwoD/Path.hs +++ b/src/Diagrams/TwoD/Path.hs @@ -160,7 +160,7 @@ data StrokeOpts a instance Default (StrokeOpts a) where def = StrokeOpts { vertexNames = [] - , queryFillRule = Winding + , queryFillRule = def } -- | A composition of 'stroke' and 'pathFromTrail' for conveniently @@ -221,7 +221,10 @@ data FillRule = Winding -- ^ Interior points are those with a nonzero -- direction crosses the path an odd number -- of times. See -- . - deriving (Eq) + deriving (Eq, Show) + +instance Default FillRule where + def = Winding runFillRule :: FillRule -> P2 -> Path R2 -> Bool runFillRule Winding = isInsideWinding @@ -231,6 +234,9 @@ newtype FillRuleA = FillRuleA (Last FillRule) deriving (Typeable, Semigroup) instance AttributeClass FillRuleA +instance Default FillRuleA where + def = FillRuleA $ Last $ def + -- | Extract the fill rule from a 'FillRuleA' attribute. getFillRule :: FillRuleA -> FillRule getFillRule (FillRuleA (Last r)) = r From a38afc1a75456c4c6708dee8973ddde327201b82 Mon Sep 17 00:00:00 2001 From: Jan Bracker Date: Fri, 23 Aug 2013 10:24:54 +0200 Subject: [PATCH 2/2] Also added show instance for FillRuleA --- src/Diagrams/TwoD/Path.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Diagrams/TwoD/Path.hs b/src/Diagrams/TwoD/Path.hs index b58e0ae6..784cfac7 100644 --- a/src/Diagrams/TwoD/Path.hs +++ b/src/Diagrams/TwoD/Path.hs @@ -231,7 +231,7 @@ runFillRule Winding = isInsideWinding runFillRule EvenOdd = isInsideEvenOdd newtype FillRuleA = FillRuleA (Last FillRule) - deriving (Typeable, Semigroup) + deriving (Typeable, Semigroup, Show) instance AttributeClass FillRuleA instance Default FillRuleA where