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

Non-fractional ouput? #6

Open
c0bra opened this issue May 25, 2018 · 3 comments
Open

Non-fractional ouput? #6

c0bra opened this issue May 25, 2018 · 3 comments

Comments

@c0bra
Copy link

c0bra commented May 25, 2018

Hi! Thanks for the great library.

Quick question: I'd like to use this to output treemaps on the terminal, where I don't have the capability to render at fractional points. What would be the safest way to handle this? Just giving it the barest of glances I think I could round things down and add the remainders back to the final elements. Wouldn't be perfect but could work.

Thoughts?

@huy-nguyen
Copy link
Owner

huy-nguyen commented May 25, 2018

Thanks for your interest. That’s the classic rasterization problem in computer graphics. I haven’t dealt a lot with fractional pixels but I think a bulletproof solution would blend the colors of two adjacent cells based on how much of that row/column is occupied by each cell. A good-enough solution might give the row/column the color of the cell that occupies the most area in that row/column.

One concern that I have about rounding down all cells and giving the leftover pixels to the last cells in a row/column is that this algorithm tends to put the smallest cells on the bottom right corner so if you give those small cells the leftover pixels, these cells may be a lot larger (percentage-wise) than their correct size. However, if you think the cells in your tree map won’t be of radically different sizes (say, a factor of 100 or 1000) then that approach might work quite well.

@alana314
Copy link

alana314 commented Sep 5, 2018

@c0bra can I have whatever you're building?

@c0bra
Copy link
Author

c0bra commented Sep 7, 2018

@Jordan314 I was wanting to do a package size analysis plugin for rollup, I think, but I never got around to it.

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