Skip to content

Commit

Permalink
D.TwoD.Path: stroke' now splits paths into lines & loops.
Browse files Browse the repository at this point in the history
Only one primitive is created if there are only lines or only loops,
but in the case of both lines and loops in the same path, two
primitive diagrams are created, one with just lines and one with just
loops.  This is to help backends which need to handle them
differently---in particular, lines should not be filled, even if a
fill attribute is set. Splitting up paths in this way is semantically
legitimate, since lines cannot affect the semantics of any other
pieces of the path (this is not true of loops, where multiple loops in
the same path can interact with each other to determine the fill).

See also diagrams/diagrams-cairo#32.
  • Loading branch information
Brent Yorgey committed Aug 5, 2013
1 parent def6411 commit d8d6006
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Diagrams/TwoD/Path.hs
Expand Up @@ -110,8 +110,14 @@ instance Renderable (Path R2) b => TrailLike (QDiagram b R2 Any) where
-- 'StrokeOpts' is an instance of 'Default', so @stroke' 'with' {
-- ... }@ syntax may be used.
stroke' :: (Renderable (Path R2) b, IsName a) => StrokeOpts a -> Path R2 -> Diagram b R2
stroke' opts p
= mkQD (Prim p)
stroke' opts path
| null (pathTrails p1) = mkP p2
| null (pathTrails p2) = mkP p1
| otherwise = mkP p1 <> mkP p2
where
(p1,p2) = partitionPath (isLine . unLoc) path
mkP p
= mkQD (Prim p)
(getEnvelope p)
(getTrace p)
(fromNames . concat $
Expand Down

0 comments on commit d8d6006

Please sign in to comment.