Skip to content

Commit

Permalink
Merge pull request #100 from jbracker/master
Browse files Browse the repository at this point in the history
Default and Show instances for FillRule and FillRuleA
  • Loading branch information
byorgey committed Aug 23, 2013
2 parents 58a2d65 + a38afc1 commit 16511d8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Diagrams/TwoD/Path.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -221,16 +221,22 @@ data FillRule = Winding -- ^ Interior points are those with a nonzero
-- direction crosses the path an odd number
-- of times. See
-- <http://en.wikipedia.org/wiki/Even-odd_rule>.
deriving (Eq)
deriving (Eq, Show)

instance Default FillRule where
def = Winding

runFillRule :: FillRule -> P2 -> Path R2 -> Bool
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
def = FillRuleA $ Last $ def

-- | Extract the fill rule from a 'FillRuleA' attribute.
getFillRule :: FillRuleA -> FillRule
getFillRule (FillRuleA (Last r)) = r
Expand Down

0 comments on commit 16511d8

Please sign in to comment.