Copyright | (c) 2011 diagrams-lib team (see LICENSE) |
---|---|
License | BSD-style (see LICENSE) |
Maintainer | diagrams-discuss@googlegroups.com |
Safe Haskell | None |
Language | Haskell2010 |
A default diagram-adjustment implementation for two-dimensional diagrams, useful for backend implementors.
- setDefault2DAttributes :: Semigroup m => QDiagram b R2 m -> QDiagram b R2 m
- adjustDiaSize2D :: Monoid' m => Lens' (Options b R2) SizeSpec2D -> b -> Options b R2 -> QDiagram b R2 m -> (Options b R2, T2, QDiagram b R2 m)
- adjustDia2D :: Monoid' m => Lens' (Options b R2) SizeSpec2D -> b -> Options b R2 -> QDiagram b R2 m -> (Options b R2, T2, QDiagram b R2 m)
Documentation
setDefault2DAttributes :: Semigroup m => QDiagram b R2 m -> QDiagram b R2 m Source
Set default attributes of a 2D diagram (in case they have not been set):
- Line width 0.01
- Line color black
- Font size 1
- Line cap LineCapButt
- line join miter
- Miter limit 10
adjustDiaSize2D :: Monoid' m => Lens' (Options b R2) SizeSpec2D -> b -> Options b R2 -> QDiagram b R2 m -> (Options b R2, T2, QDiagram b R2 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 :: Monoid' m => Lens' (Options b R2) SizeSpec2D -> b -> Options b R2 -> QDiagram b R2 m -> (Options b R2, T2, QDiagram b R2 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.