diagrams-core-1.4.0.1: Core libraries for diagrams EDSL

Copyright(c) 2013-2015 diagrams-core team (see LICENSE)
LicenseBSD-style (see LICENSE)
Maintainerdiagrams-discuss@googlegroups.com
Safe HaskellNone
LanguageHaskell2010

Diagrams.Core.Compile

Contents

Description

This module provides tools for compiling QDiagrams into a more convenient and optimized tree form, suitable for use by backends.

Synopsis

Tools for backends

data RNode b v n a #

Constructors

RStyle (Style v n)

A style node.

RAnnot a 
RPrim (Prim b v n)

A primitive.

REmpty 

type RTree b v n a = Tree (RNode b v n a) #

An RTree is a compiled and optimized representation of a QDiagram, which can be used by backends. They have the following invariant which backends may rely upon:

  • RPrim nodes never have any children.

toRTree :: (HasLinearMap v, Metric v, Typeable n, OrderedField n, Monoid m, Semigroup m) => Transformation v n -> QDiagram b v n m -> RTree b v n Annotation #

Compile a QDiagram into an RTree, rewriting styles with the given function along the way. Suitable for use by backends when implementing renderData. The first argument is the transformation used to convert the diagram from local to output units.

Backend API

renderDia :: (Backend b v n, HasLinearMap v, Metric v, Typeable n, OrderedField n, Monoid' m) => b -> Options b v n -> QDiagram b v n m -> Result b v n #

Render a diagram.

renderDiaT :: (Backend b v n, HasLinearMap v, Metric v, Typeable n, OrderedField n, Monoid' m) => b -> Options b v n -> QDiagram b v n m -> (Transformation v n, Result b v n) #

Render a diagram, returning also the transformation which was used to convert the diagram from its ("global") coordinate system into the output coordinate system. The inverse of this transformation can be used, for example, to convert output/screen coordinates back into diagram coordinates. See also adjustDia.

Internals

toDTree :: (HasLinearMap v, Floating n, Typeable n) => n -> n -> QDiagram b v n m -> Maybe (DTree b v n Annotation) #

Convert a QDiagram into a raw tree.

fromDTree :: forall b v n. (Floating n, HasLinearMap v) => DTree b v n Annotation -> RTree b v n Annotation #

Convert a DTree to an RTree which can be used dirctly by backends. A DTree includes nodes of type DTransform (Transformation v); in the RTree transform is pushed down until it reaches a primitive node.