Compose.jl
                                
                                 Compose.jl copied to clipboard
                                
                                    Compose.jl copied to clipboard
                            
                            
                            
                        Rectangle update
- [x] I've updated the documentation to reflect these changes
- [x] I've updated the unit tests
- [x] I've run the regression tests
- [x] I've built the docs and confirmed these changes don't cause new errors
- [ ] I've tested Gadfly with this PR (tbd)
This PR:
- Fixes #133
Rectangles are now PolygonPrimitives, so they will obey Compose transformations:
θ = -π/10
img = compose(context(units=UnitBox(0,0,3,1)), fill(nothing), stroke("blue"),
    (context(), rectangle([0.3,1.3,2.3],[0.4],[0.4],[0.2]), stroke("silver")),
    (context(rotation=Rotation(-π/6,0.5,0.5)), rectangle(0.3,0.4,0.4,0.2)),
    (context(rotation=Rotation(θ,1.5,0.4)), line([(1.0,0.4),(2.0,0.4)]), stroke("black")),
    (context(mirror=Mirror(θ,1.5,0.4)), rectangle(1.3,0.4,0.4,0.2)),
    (context(shear=Shear(1.0,0.0,2.5,0.5)), rectangle(2.3,0.4,0.4,0.2)) 
)

Codecov Report
Merging #338 into master will increase coverage by
0.34%. The diff coverage is83.33%.
@@            Coverage Diff             @@
##           master     #338      +/-   ##
==========================================
+ Coverage   37.13%   37.47%   +0.34%     
==========================================
  Files          18       18              
  Lines        3089     3082       -7     
==========================================
+ Hits         1147     1155       +8     
+ Misses       1942     1927      -15
| Impacted Files | Coverage Δ | |
|---|---|---|
| src/cairo_backends.jl | 52.81% <ø> (-0.58%) | :arrow_down: | 
| src/pgf_backend.jl | 49.78% <ø> (+1.45%) | :arrow_up: | 
| src/svg.jl | 67.87% <ø> (-1.18%) | :arrow_down: | 
| src/form.jl | 49.76% <83.33%> (+0.46%) | :arrow_up: | 
| src/fontfallback.jl | 46.6% <0%> (-0.46%) | :arrow_down: | 
| src/measure.jl | 49.16% <0%> (-0.02%) | :arrow_down: | 
| src/Compose.jl | 15.11% <0%> (+3.06%) | :arrow_up: | 
| src/misc.jl | 61.17% <0%> (+28.41%) | :arrow_up: | 
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 8de6805...8a8a4fa. Read the comment docs.
i hesitate to get rid of RectanglePrimitive because both cairo and pgf have rectangle primitives that might be more performant than polygons.  is it too hard to support ~shear~ transformations for rectangles directly?
also, what about ~shear~ transformations for circles, ellipses, lines, curves, etc...
There are some potential issues with implementing transformations at backend level:
- a particular transformation might not exist for some backends
- a transformation (e.g. rotation) might be context independent at backend level
- nested transformation may not work (golden_rect.jl is an example of a nested transformation).
Compose avoids all these issues by implementing transformations at Compose level. The following code
shows that this works for most Forms (the exception is ellipse shear, I can do circle shear using ngon).
So rectangle is currently the odd shape out, and transformations of rectangle need to be supported at Compose level.
set_default_graphic_size(6.5inch, 6.5inch)
θ = -π/10
img1 = compose(context(units=UnitBox(0,0,3,1)), fill(nothing), stroke("blue"),
    (context(), circle([0.5,1.5,2.5],[0.5],[0.1]), stroke("silver")),
    (context(rotation=Rotation(-π/6,0.5,0.5)), ngon(0.5,0.5,0.1,30)),
    (context(rotation=Rotation(θ,1.5,0.4)), line([(1.0,0.4),(2.0,0.4)]), stroke("black")),
    (context(mirror=Mirror(θ,1.5,0.4)), circle(1.5,0.5,0.1)),
    (context(shear=Shear(1.0,0.0,2.5,0.5)), ngon(2.5,0.5,0.1,30)) 
)
img2 = compose(context(units=UnitBox(0,0,3,1)), fill(nothing), stroke("blue"),
    (context(), ellipse([0.5,1.5,2.5],[0.5],[0.2],[0.1]), stroke("silver")),
    (context(rotation=Rotation(-π/6,0.5,0.5)), ellipse(0.5,0.5,0.2,0.1)),
    (context(rotation=Rotation(θ,1.5,0.4)), line([(1.0,0.4),(2.0,0.4)]), stroke("black")),
    (context(mirror=Mirror(θ,1.5,0.4)), ellipse(1.5,0.5,0.2,0.1)),
    (context(shear=Shear(1.0,0.0,2.5,0.5)), ellipse(2.5,0.5,0.2,0.1)) 
)
X = [(x,y) for x in (0.5,1.5,2.5), y in (0.5, -0.5, 1.5, 0.5) ]
X[:,1] = [x.+(-0.2, 0.0) for x in X[:,1]]
X[:,4] = [x.+(0.2, 0.0) for x in X[:,4]]
img3 = compose(context(units=UnitBox(0,0,3,1)), fill(nothing), stroke("blue"),
    (context(), curve(X[:,1],X[:,2],X[:,3],X[:,4]), stroke("silver")),
    (context(rotation=Rotation(-π/6,0.5,0.5)), curve(X[1,:]...)),
    (context(rotation=Rotation(θ,1.5,0.4)), line([(1.0,0.4),(2.0,0.4)]), stroke("black")),
    (context(mirror=Mirror(θ,1.5,0.4)), curve(X[2,:]...)),
    (context(shear=Shear(1.0,0.0,2.5,0.5)), curve(X[3,:]...)) 
)
vstack(img1,img2,img3) 

Ran into errors testing on Gadfly with this PR.  Looks like PolygonPrimitives need extra support for DateTime types ...
do PolygonPrimitives work yet with DateTime types?