diagrams-lib-0.2: Embedded domain-specific language for declarative graphics

Maintainerdiagrams-discuss@googlegroups.com

Diagrams.TwoD.Path

Contents

Description

Paths in two dimensions are special since we may stroke them to create a 2D diagram, and (eventually) perform operations such as intersection and union.

Synopsis

Constructing path-based diagrams

stroke :: Renderable (Path R2) b => Path R2 -> Diagram b R2Source

Convert a path into a diagram. The resulting diagram has the names 0, 1, ... assigned to each of the path's vertices.

Note that a bug in GHC 7.0.1 causes a context stack overflow when inferring the type of stroke. The solution is to give a type signature to expressions involving stroke, or (recommended) upgrade GHC (the bug is fixed in 7.0.2 onwards).

strokeT :: Renderable (Path R2) b => Trail R2 -> Diagram b R2Source

A composition of stroke and pathFromTrail for conveniently converting a trail directly into a diagram.

Note that a bug in GHC 7.0.1 causes a context stack overflow when inferring the type of stroke and hence of strokeT as well. The solution is to give a type signature to expressions involving strokeT, or (recommended) upgrade GHC (the bug is fixed in 7.0.2 onwards).

Clipping

newtype Clip Source

Clip tracks the accumulated clipping paths applied to a diagram. Note that the semigroup structure on Clip is list concatenation, so applying multiple clipping paths is sensible. The clipping region is the intersection of all the applied clipping paths.

Constructors

Clip [Path R2] 

clipBy :: (HasStyle a, V a ~ R2) => Path R2 -> a -> aSource

Clip a diagram by the given path:

  • Only the parts of the diagram which lie in the interior of the path will be drawn.
  • The bounding function of the diagram is unaffected.