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

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

Diagrams.TwoD.Adjust

Description

A default diagram-adjustment implementation for two-dimensional diagrams, useful for backend implementors.

Synopsis

Documentation

setDefault2DAttributes :: (TypeableFloat n, Semigroup m) => QDiagram b V2 n m -> QDiagram b V2 n m Source #

Set default attributes of a 2D diagram (in case they have not been set):

adjustSize2D :: (TypeableFloat n, Monoid' m) => Lens' (Options b V2 n) (SizeSpec V2 n) -> b -> Options b V2 n -> QDiagram b V2 n m -> (Options b V2 n, Transformation V2 n, QDiagram b V2 n m) Source #

Adjust the size and position of a 2D diagram to fit within the requested size. The first argument is a lens into the output size contained in the rendering options. Returns an updated options record, any transformation applied to the diagram (the inverse of which can be used, say, to translate output/device coordinates back into local diagram coordinates), and the modified diagram itself.

adjustDia2D :: (TypeableFloat n, Monoid' m) => Lens' (Options b V2 n) (SizeSpec V2 n) -> b -> Options b V2 n -> QDiagram b V2 n m -> (Options b V2 n, Transformation V2 n, QDiagram b V2 n m) Source #

adjustDia2D provides a useful default implementation of the adjustDia method from the Backend type class.

As its first argument it requires a lens into the output size contained in the rendering options.

It then performs the following adjustments:

  • Set default attributes (see setDefault2DAttributes)
  • Scale and translate the diagram to fit within the requested size (see adjustDiaSize2D)

It returns an updated options record, any transformation applied to the diagram (the inverse of which can be used, say, to translate output/device coordinates back into local diagram coordinates), and the modified diagram itself.