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

Use ansi block characters to make smoother progressbars #4

Open
Micket opened this issue Aug 8, 2020 · 3 comments
Open

Use ansi block characters to make smoother progressbars #4

Micket opened this issue Aug 8, 2020 · 3 comments

Comments

@Micket
Copy link

Micket commented Aug 8, 2020

I think it would be as simple as just replacing the if-else block and using something like

partials = (
    FULL_BLOCK,
    LEFT_SEVEN_EIGHTHS_BLOCK,
    LEFT_THREE_QUARTERS_BLOCK,
    LEFT_HALF_BLOCK,
    LEFT_FIVE_EIGHTHS_BLOCK,
    LEFT_THREE_EIGHTHS_BLOCK,
    LEFT_ONE_QUARTER_BLOCK,
    LEFT_ONE_EIGHTH_BLOCK,
    ' ',
    )

...
    width = (right(inner_area) - left(inner_area) + 1)
    for y in top(inner_area):bottom(inner_area)
        for x in left(inner_area):right(inner_area)
            symbol = clamp(round(Int, (x - r * width) * 8), 0, 8) + 1
            set(buf, x, y, crayon, partials[symbol])
        end
    end

Would also make the output more copy friendly.

@kdheepak
Copy link
Owner

kdheepak commented Aug 9, 2020

Interesting idea! If you'd like to submit a PR I'd be open to reviewing :) If not no worries, I'll look into it this week. I had some other ideas for improving the progress bar as well that I think I'd like to implement.

@Micket
Copy link
Author

Micket commented Aug 9, 2020

The reason I didn't get around to submitting a PR, is because I couldn't get the package working at all right now (due to #3 ), so I just tried to write the code above blind (so it's untested)

@kdheepak
Copy link
Owner

kdheepak commented Aug 9, 2020

Okay, thanks for the suggestion! I'll look into 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

2 participants