fogleman / gg

Go Graphics - 2D rendering in Go with a simple API.
https://godoc.org/github.com/fogleman/gg
MIT License
4.37k stars 354 forks source link

[Question] Float coordinate values for DrawImage? (sub-pixel positioning) #144

Open HeCorr opened 3 years ago

HeCorr commented 3 years ago

Hello! I was wondering why there's no current way (that I know of) of drawing images in float coordinates since DrawImage and DrawImageAnchored both take ints for the X and Y.

I think float values would work alright since they apparently get converted to float internally anyway.

I'd create a PR and try something out but I'm usure about how to call the new functions.. DrawImageFloat sounds really bad..

It would make more sense if they just accepted floats (like DrawRectangle) since int to float conversion doesn't mess with the values (5 -> 5.00) so one could just use float64(x), float64(y) but that would definitely break backwards-compatibility, which nobody wants.

Ideas?

HeCorr commented 3 years ago

I did some testing and it actually seems to not work as expected.

Instead of smoothly moving from 0.00 to 1.00 in 0.10 increments, the drawn image just jumps once it reaches 1.00, staying in the same position as 0.00 with the other values.

Is sub-pixel positioning not possible after all?