Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: why are numerical values typed as int? #76

Open
vibridi opened this issue Oct 3, 2024 · 2 comments
Open

Question: why are numerical values typed as int? #76

vibridi opened this issue Oct 3, 2024 · 2 comments

Comments

@vibridi
Copy link

vibridi commented Oct 3, 2024

For example the signature of Rect is:

Rect(x int, y int, w int, h int, s ...string)

This function, like all other ones, declare int as parameter type. Why? Computation of point coordinates is usually done with floats, why does the library forces to lose precision when using these convenience functions?

I know I can use Path instead and format the d attribute however I like, but it's very inconvenient.

Can someone shed light on this design decision?
Thank you.

@ajstarks
Copy link
Owner

ajstarks commented Oct 4, 2024

That was an early design decision. If you want floats you can use "github.com/ajstarks/svgo/float" or better yet "github.com/ajstarks/gensvg"

The Path function is used a fallback when the higher level functions for example like the various Bezier curves are not sufficient

@jjcazau
Copy link

jjcazau commented Oct 11, 2024

That was an early design decision. If you want floats you can use "github.com/ajstarks/svgo/float" or better yet "github.com/ajstarks/gensvg"

The Path function is used a fallback when the higher level functions for example like the various Bezier curves are not sufficient

@ajstarks Thanks ive changed to github.com/ajstarks/svgo/float. I make SVG map overlays by converting lat lng to floats and i was loosing precision by being forced into integers. Maybe some documentation about its existance on the readme could help.

curious as to why you say "better yet" to "github.com/ajstarks/gensvg". Looks almost identical to this package, is there any difference between that package and this one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants