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

lib/draw should accept FP coordinates/values #130

Open
maximecb opened this issue Jul 19, 2014 · 4 comments
Open

lib/draw should accept FP coordinates/values #130

maximecb opened this issue Jul 19, 2014 · 4 comments

Comments

@maximecb
Copy link
Contributor

I ran into an issue while using lib/draw, particularly the drawPoint function. I was supplying integer coordinates, but the values were internally stored as the f64 type (output of Math.floor). The calls to drawPoint simply didn't draw anything on the screen.

I remembered a previous discussion we had and use a trick to force an integer conversion. However, I think this issue needs to be fixed. Newbies will surely find it very confusing.

@maximecb maximecb changed the title draw lib should accept FP coordinates lib/draw should accept FP coordinates Jul 19, 2014
@maximecb maximecb changed the title lib/draw should accept FP coordinates lib/draw should accept FP coordinates/values Jul 19, 2014
@bFraley
Copy link
Contributor

bFraley commented May 29, 2015

ES6 has Math.fround, but on every call to drawPoint rounding and conversion may get expensive.
Maybe parseInt on xy if it contains "." ? May be the least complicated fix ?

Not sure the efficiency of parseInt, or match on every call either.

Oh, and I'm referring to only the drawPoint function

@maximecb
Copy link
Contributor Author

Both of these are unfortunately pretty slow. I particularly care about the performance of drawPoint, so I would have that one directly use $ir_is_int32(x) before making a call. The other functions could use $rt_toInt32(x).

@bFraley
Copy link
Contributor

bFraley commented May 30, 2015

Hmm..im thinking those IR functions may beat other FP to int conversion methods, like Mozillas fround..possibly

@maximecb
Copy link
Contributor Author

They're more direct ways of telling Higgs what you want to do. The parseInt function is not optimized for performance, and there's some dynamic lookup overhead.

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

No branches or pull requests

2 participants