Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default and Show instances for FillRule and FillRuleA #100

Merged
merged 2 commits into from
Aug 23, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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