Cairo.jl icon indicating copy to clipboard operation
Cairo.jl copied to clipboard

CairoSurface using Float64 for width and height

Open Cruor opened this issue 5 years ago • 5 comments

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.

Cruor avatar May 21 '20 21:05 Cruor

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)

lobingera avatar May 22 '20 05:05 lobingera

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.

Vexatos avatar May 22 '20 08:05 Vexatos

Does storing Float64 introduce problems in your code?

lobingera avatar May 22 '20 13:05 lobingera

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.

Vexatos avatar May 22 '20 13:05 Vexatos

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.

donm avatar Jul 31 '20 12:07 donm