diagrams-core-1.2: Core libraries for diagrams EDSL

Copyright(c) 2013 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 a Source

Constructors

RStyle (Style v)

A style node.

RAnnot a 
RPrim (Prim b v)

A primitive.

REmpty 

type RTree b v a = Tree (RNode b v 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 :: (HasLinearMap v, InnerSpace v, Data v, Data (Scalar v), OrderedField (Scalar v), Monoid m, Semigroup m) => Transformation v -> QDiagram b v m -> RTree b v 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 :: (Backend b v, InnerSpace v, Data v, OrderedField (Scalar v), Data (Scalar v), Monoid' m) => b -> Options b v -> QDiagram b v m -> Result b v Source

Render a diagram.

renderDiaT :: (Backend b v, HasLinearMap v, InnerSpace v, Data v, OrderedField (Scalar v), Data (Scalar v), Monoid' m) => b -> Options b v -> QDiagram b v m -> (Transformation v, Result b v) 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 :: HasLinearMap v => Scalar v -> Scalar v -> QDiagram b v m -> Maybe (DTree b v Annotation) Source

Convert a QDiagram into a raw tree.

fromDTree :: HasLinearMap v => DTree b v Annotation -> RTree b v Annotation Source

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.

styleToOutput :: forall v. (Data v, Data (Scalar v), Num (Scalar v), Ord (Scalar v), Fractional (Scalar v)) => Scalar v -> Scalar v -> Style v -> Style v Source

Convert all Measure values to Output units. The arguments are, respectively, the scaling factor from global units to output units, and from normalized units to output units. It is assumed that local units are identical to output units (which will be the case if all transformations have been fully pushed down and applied). Normalized units are based on a logical diagram size of 1 x 1.

toOutput :: forall v. (Data v, Data (Scalar v), Num (Scalar v), Ord (Scalar v), Fractional (Scalar v)) => Scalar v -> Scalar v -> Measure v -> Measure v Source

Convert an aribrary Measure to Output units.