diagrams-core-1.5.1.1: Core libraries for diagrams EDSL

Copyright | (c) 2013-2015 diagrams-core team (see LICENSE)
License | BSD-style (see LICENSE)
Maintainer | diagrams-discuss@googlegroups.com
Safe Haskell | None
Language | Haskell2010

Diagrams.Core.Compile

Contents

- Tools for backends
- Backend API
- Internals

Description

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

Synopsis

- data RNode b (v :: Type -> Type) n a
  - = RStyle (Style v n)
  - | RAnnot a
  - | RPrim (Prim b v n)
  - | REmpty
- type RTree b (v :: Type -> Type) n a = Tree (RNode b v n a)
- toRTree :: forall (v :: Type -> Type) n m b. (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
- renderDia :: forall b (v :: Type -> Type) n m. (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
- renderDiaT :: forall b (v :: Type -> Type) n m. (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)
- toDTree :: forall (v :: Type -> Type) n b m. (HasLinearMap v, Floating n, Typeable n) => n -> n -> QDiagram b v n m -> Maybe (DTree b v n Annotation)
- fromDTree :: forall b (v :: Type -> Type) n. (Floating n, HasLinearMap v) => DTree b v n Annotation -> RTree b v n Annotation

# Tools for backends

data RNode b (v :: Type -> Type) n a Source #

Constructors

RStyle (Style v n) | A style node.
RAnnot a |
RPrim (Prim b v n) | A primitive.
REmpty |

type RTree b (v :: Type -> Type) n a = Tree (RNode b v n a) Source #

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 :: forall (v :: Type -> Type) n m b. (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 Source #

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 :: forall b (v :: Type -> Type) n m. (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 Source #

Render a diagram.

renderDiaT :: forall b (v :: Type -> Type) n m. (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) Source #

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 :: forall (v :: Type -> Type) n b m. (HasLinearMap v, Floating n, Typeable n) => n -> n -> QDiagram b v n m -> Maybe (DTree b v n Annotation) Source #

Convert a `QDiagram` into a raw tree.

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

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