Difference between revisions of "Diagrams/Dev/Migrate1.3"
JRosenbluth (talk  contribs) 
JRosenbluth (talk  contribs) 

Line 84:  Line 84:  
== New Backends == 
== New Backends == 

+  
+  == SVGFonts == 

== Reorganisation == 
== Reorganisation == 
Revision as of 19:29, 28 March 2015
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.
Contents
Linear
The linear algebra package has moved from vectorspace
to linear
.
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
The 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
where V b
is the default space and N b
is the default number type for backend b
.
linear
’s functions are very similar to vectorspace
. 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 vectorspace
’s lerp.
The old HasX
, HasY
and HasZ
classes have been replaced by linear’s R1
, R2
and R3
.
Direction type
A new Direction
type has been added to Diagrams.Direction
. A Direction
is a vector that has forgot its magnitude. Certain functions include arc
, 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. arcCW
and arcCCW
give a clockwise or counter clockwise arc between two directions.
angleBetween
is commutative (and always positive).
Measure changes
The internal representation of Measure
has now changed. The old constructor cannot be used anymore. Instead the have been replaced by:

Normalized > normalized
ornormalised

Local > local

Global > global

Output > output
SizeSpec
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 > dims

Width > mkWidth

Height > mkHeight

Absolute > absolute
mkWidth
and mkHeight
are in Diagrams.TwoD.Size
.
Names
The qualify with name operator (>)
has moved to (.>>)
to make room for lenses snoc operator (>)
(which now works on Line
s).
ToPath class
A new ToPath
class has been added. It takes pathlike things (like lines, loops, trails, paths) and converts them to a Path
.
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.
Because stroke
now uses this class it can cause some ambiguity error for old code. The old (less polymorphic) stroke
has moved to strokePath
(or strokeP
).
fsnotify for command line loop
The 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.
diagramssvg
New features
Segment intersections have been added to Diagrams.TwoD.Segment
. Functions for intersection points of pathlike things are in Diagrams.TwoD.Path
.
There’s a function for finding the convex hull for a list of 2D points in Diagrams.TwoD.Points
.
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 pathlike things.
Some extra functions have been added to Diagrams.Model
to help visualise the Trace
and Envelope
of a diagram.
New Backends
SVGFonts
Reorganisation

LineWidth
andDashing
has moved back toDiagrams.Attributes
.  There is no longer a
Diagrams.Prelude.ThreeD
. Instead all functions are exported byDiagrams.Prelude
and functions have had their types generalised to theR1
,R2
andR3
classes. 
Control.Lens
andData.Default
are now exported fromDiagrams.Prelude
. Some names fromControl.Lens
where hidden.  A new
Diagrams
module now only exports functions defined in the diagrams library. 
Diagrams.TwoD.Transform.ScaleInv
has moved toDiagrams.Transform.ScaleInv
.