This page describes breaking API changes between diagrams 1.2 and 1.3, along with explanations of how to migrate to the new 1.2 API.
The linear algebra package has moved from
The most obvious difference is there are now two type variables for the vector space:
v, which gives the space being worked in and
n, the number type used.
v now has kind
* -> *, which means is takes some type (usually
n) and makes a concrete vector. Basically this means whenever you saw
v, replace it by
v n. So:
R2 -> V2 Double
Point R2 -> Point V2 Double
Path R2 -> Path V2 Double
QDiagram b v m -> QDiagram b v n m
Diagram alias has also changed. Now it uses the default space and number type for some backend:
Diagram b = QDiagram b (V b) (N b) Any
V b is the default space and
N b is the default number type for backend
linear’s functions are very similar to
vector-space. The biggest difference is
lerp which is defined as
lerp alpha u v = alpha *^ u ^+^ (1 - alpha) *^ v
This is the opposite way round to
HasZ classes have been replaced by linear’s
Direction type has been added to
Direction is a vector that has forgot its magnitude. Certain functions include
reflectAcross have had their types moved from
V2 Double to
Direction Double to make it clear the magnitude has no impact.
arc now takes a starting direction and an angle.
arcCCW give a clockwise or counter clockwise arc between two directions.
angleBetween is commutative (and always positive).
The internal representation of
Measure has now changed. The old constructor cannot be used anymore. Instead the have been replaced by:
Normalized -> normalizedor
Local -> local
Global -> global
Output -> output
SizeSpec2D is now
SizeSpec V2 Double and has moved to
Diagrams.Size. The resizing functions now work for any vector space. The constructors have been replaced with the following functions:
Dims -> dims2D
Width -> mkWidth
Height -> mkHeight
Absolute -> absolute
mkHeight are in
The qualify with name operator
(|>) has moved to
(.>>) to make room for lenses snoc operator
(|>) (which now works on
New transform isomorphisms
rotated have been added. These can be used with lens’s
under function (see
Diagrams.Transform for usage examples). The old
under has been renamed to
ToPath class has been added. It takes path-like things (like lines, loops, trails, paths) and converts them to a
This is very different from the
TrailLike class, which is polymorphic in it’s result. Because both these classes are polymorphic, you can’t produce something with the
TrailLike class and consume it with
ToPath without specifying the type in between.
stroke now uses this class it can cause some ambiguity error for old code. The old (less polymorphic)
stroke has moved to
fsnotify for command line loop
--loop option for diagrams command line generation uses
fsnotify to watch the source file for changes. This means it should now work on Windows.
Additionally it now works in sandboxes and has a cleaner terminal output.
Segment intersections have been added to
Diagrams.TwoD.Segment. Functions for intersection points of path-like things are in
There’s a function for finding the convex hull for a list of 2D points in
Affine maps have been added to
Diagrams.AffineMap that can map between spaces. The
Deformable class has also been generalised to map between spaces. Helper functions have been added to
Diagrams.ThreeD.Projection for basic orthographic and perspective projections. These can’t be used on a
Diagram yet be can be used on path-like things.
Some extra functions have been added to
Diagrams.Model to help visualise the
Envelope of a diagram.
PGF is tex a macro package for creating graphics. It’s the low level backend for TikZ.
diagrams-pgf backend supports most of diagrams’ features including paths, images (external and embedded), gradients (partial support) and text. It also includes an experimental functions for retrieving the size of the bounding boxes for text (including formulas). See the examples page for more details.
texrunner to produce PDF files and parse tex’s output. Latex, Context and plain Tex outputs are supported.
The most important functions for use in diagrams
testSVG_ have been move out of the
ReadFont module into the
Text module. You can usually just import
Graphics.SVGFonts and have all of the functions you need.
textSVG' and friends now have the text as a separate argument, distinct from
TextOptions. So whereas before you might write:
textSVG' (TextOpts s lin2 INSIDE_H KERN False d d)
now you would write:
textSVG' (TextOpts lin2 INSIDE_H KERN False d d) s.
Dashinghas moved back to
- There is no longer a
Diagrams.Prelude.ThreeD. Instead all functions are exported by
Diagrams.Preludeand functions have had their types generalised to the
Data.Defaultare now exported from
Diagrams.Prelude. Some names from
- A new
Diagramsmodule now only exports functions defined in the diagrams library.
Diagrams.TwoD.Transform.ScaleInvhas moved to