-
-
Notifications
You must be signed in to change notification settings - Fork 257
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
Implements Color Incrementation #187
Conversation
# Ensuring that we're incrementing when needed and decrementing to the correct positions. | ||
|
||
# Handle the fringe cases for the Fore and Back ANSI codes to jump to the non-standard codes | ||
color_num = color_num + 53 if color_num == 47 or color_num == 37 else\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no easy way to handle the incrementation with a shorthand logic, circular buffers fail as they still require some sense of what number is & isn't in a given set.
Therefore the only simple solution is to use this long spaghetti logic.
I'm afraid I don't see a clear, general use case for this, and the function is too littered with magic numbers and specifics for how to generate the rainbow effect. IMO this sort of code belongs in the application(s) using this package, instead of in the package itself. btw, demo01.py also outputs a sort of rainbow of colors, but goes about it very differently. |
The use case is when you want to increment a color in value, as if it were a number
They're not magic, but I wasn't able to put end of line comments for the assignment statement due to
That's not true at all, the comments explain how the numbers bounce back and forth for the 3 different classes that define color constants; with no reference to any sort of "rainbow effect". Secondly, if verbosity is an issue, I can always just reduce the amount of comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what this function does but I am positive that this will be useful? And if there is an increment, would it be a decrement function too?
1 if color_num == 22 else\ | ||
2 if color_num == 1 else\ | ||
22 if color_num == 2 else\ | ||
1 if color_num == 0 else color_num + 51 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get the idea of what these operations does, yet is there a better way to implement this? I mean on the aspect of readability and all those magic numbers.
Hey. FYI, Yesterday I created a PR to test releases before we push them to PyPI. When that is merged, I'll be more confident about resuming merges and releases. I'll try to look at this PR soon. Thank you for creating it! |
This is a beautiful idea, but I tend to agree with wiggin's judgement that it's probably better done by the application, rather than in Colorama. I'm really loathe to extend the functionality of Colorama where we don't need to, because we have a lot of dependencies, and everything we add will need to be supported forever, and supporting this already takes more time than we have. With sincere apologies I'm going to decline to merge this new feature. Hugs! |
This is a simply function added to
ansi.py
which allows users to increment colors to allow users to create rainbow-like outputs. This would be beneficial as it would allow users to implement features to distinguish mundane outputs from one another.Personally I'm amazed that this wasn't already implemented as color codes should be treated as numbers because they fundamentally are, if you strip away the extra ANSI codes.