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

Maintainerdiagrams-discuss@googlegroups.com
Safe HaskellSafe-Infered

Diagrams.TwoD.Size

Contents

Description

Utilities for working with sizes of two-dimensional objects.

Synopsis

Size and extent of diagrams in R2

Computing sizes

width :: (Enveloped a, V a ~ R2) => a -> DoubleSource

Compute the width of an enveloped object.

height :: (Enveloped a, V a ~ R2) => a -> DoubleSource

Compute the height of an enveloped object.

size2D :: (Enveloped a, V a ~ R2) => a -> (Double, Double)Source

Compute the width and height of an enveloped object.

extentX :: (Enveloped a, V a ~ R2) => a -> Maybe (Double, Double)Source

Compute the absolute x-coordinate range of an enveloped object in R2, in the form (lo,hi). Return Nothing for objects with an empty envelope.

extentY :: (Enveloped a, V a ~ R2) => a -> Maybe (Double, Double)Source

Compute the absolute y-coordinate range of an enveloped object in R2, in the form (lo,hi).

center2D :: (Enveloped a, V a ~ R2) => a -> P2Source

Compute the point at the center (in the x- and y-directions) of a enveloped object. Return the origin for objects with an empty envelope.

Specifying sizes

data SizeSpec2D Source

A specification of a (requested) rectangular size.

Constructors

Width Double

Specify an explicit width. The height should be determined automatically (so as to preserve aspect ratio).

Height Double

Specify an explicit height. The width should be determined automatically (so as to preserve aspect ratio).

Dims Double Double

An explicit specification of a width and height.

Absolute

Absolute size: use whatever size an object already has; do not rescale.

mkSizeSpec :: Maybe Double -> Maybe Double -> SizeSpec2DSource

Create a size specification from a possibly-specified width and height.