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




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



adjustDia2D :: Monoid m => (Options b R2 -> R2) -> b -> Options b R2 -> AnnDiagram b R2 m -> AnnDiagram b R2 mSource

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

As its first argument it requires a method for extracting the requested output size from the rendering options.

It then performs the following adjustments:

  • Set some default attributes (in case they have not been set):
  • Line width 0.01
  • Line color black
  • Font size 1
  • Freeze the diagram in its final form
  • Scale and translate the diagram to fit within the requested size

adjustSize :: SizeSpec2D -> R2 -> Transformation R2Source

adjustSize spec sz returns a transformation which can be applied to something of size sz to make it the requested size spec.