JuliaGraphics / Luxor.jl

Simple drawings using vector graphics; Cairo "for tourists!"
http://juliagraphics.github.io/Luxor.jl/
Other
588 stars 71 forks source link

Is there a way to redefine coordinates via `transform` without causing distortion? #243

Closed davibarreira closed 1 year ago

davibarreira commented 2 years ago

Suppose I have a drawing 200 by 200. I then want to draw circles inside this drawing, but I want to use a new coordinate system... Here is an example:

drawheight = 400
drawwidth = 400
d = Drawing(drawheight,drawwidth,:svg)
background("antiquewhite")
sethue("lightgrey")

translate(200,200)
Luxor.transform([2 1 1 -1 0 0]) 
rulers()
circle(Point(10,10),10,:fill)

finish()
d

The problem with this is that it distorts things... I mean, the behavior I'm looking for would be achieved by using rescale within the placement point of the circle. But I don't what to have to write rescale for every case.

cormullion commented 2 years ago

I'm not sure what you want - but isn't the distortion because you've got 2 and -1 on the diagonal, rather than 2 and -2?

julia> cairotojuliamatrix([2 1 1 -1 0 0])
3×3 Matrix{Float64}:
 2.0   1.0  0.0
 1.0  -1.0  0.0
 0.0   0.0  1.0

but I don't know too much about matrices...

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

davibarreira commented 1 year ago

Yeah. Don't worry. It's actually defining a way to rescale objects by the positions, similar to D3. But this is not a simple issue.