JuliaGraphics / Cairo.jl

Bindings to the Cairo graphics library.
Other
87 stars 57 forks source link

CairoSurface using Float64 for width and height #321

Open Cruor opened 4 years ago

Cruor commented 4 years ago

Is there a specific reason why they are stored as Float64s?. The documentation for Cairo uses integers for these. For example cairo-image-surface-get-height.

lobingera commented 4 years ago

I think it's because the surface type is used for all surfaces and the vector surfaces like SVG and PDF are created in Float64 dimensions (https://www.cairographics.org/manual/cairo-SVG-Surfaces.html#cairo-svg-surface-create)

Vexatos commented 4 years ago

In that case it would probably be better to either have two separate types or to allow the type to accept either int or float values, not convert everything to float.

lobingera commented 4 years ago

Does storing Float64 introduce problems in your code?

Vexatos commented 4 years ago

Having to convert between integers and floats a lot can be a minor performance issue when done a lot of times. And that kind of thing has to be done when doing maths involving exact pixels.

donm commented 4 years ago

FWIW, I was about to ask the same thing before I saw this issue. The Real and Float64 annotations made it harder for me to guess the purpose of those values, both investigating stuff at the REPL and when reading the code.