Is it possible to transform images (as shown below) via matrices with Compose.jl? If so, could you please provide a simple example?
I'm aware of the rotation
keyword argument in the Compose.context
method, but I was wondering if there was something similar for general affine transformations. Thanks!
You can use Shear
. For example, you can transform
from the tutorials (code below)
julia> composition = compose(context(),
(context(units=UnitBox(0, 0, 1000, 1000)),
polygon([(0, 1000), (500, 1000), (500, 0)]),
fill("tomato")),
(context(),
polygon([(1, 1), (0.5, 1), (0.5, 0)]),
fill("bisque")))
and shear it with
julia> composition_sheared = compose(context(shear=Shear(0.3,0.0,0.5,1.0)),
(context(units=UnitBox(0, 0, 1000, 1000)),
polygon([(0, 1000), (500, 1000), (500, 0)]),
fill("tomato")),
(context(),
polygon([(1, 1), (0.5, 1), (0.5, 0)]),
fill("bisque")))
to obtain
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With