Conversation
|
Thanks for your contribution! This is just a comment, not an approval nor a request of changes. I would like other developers to discuss and give their opinion on this change.
IMO, it does work as intended. If one would want to create a gradient of 5 colors between, say, color_gradient([RED, RED.lighter(blend_variation)], 5)which is roughly equivalent to your proposal color_gradient([RED], 5, "lighter", blend_variation) |
|
The way i see it, the method's name has the word gradient in it. So, the output of this method must be some sort of gradient. If that isn't happening, when only 1 color has been provided, then why would anyone invoke this method for 1 color. That would me that the user would be forced to look for some other way to make gradient of a single color. The way I've refactored it, is more useful. Irrespective of 1 color or many, it gives a gradient of colors. |
Overview: What does this pull request change?
This PR refactors the color_gradient method in core.py. It introduces two new parameters: transition_mode and blend_variation for the case when number_of_colors_provided = 1.
Motivation and Explanation: Why and how do your changes improve the library?
The code of color_gradient of main branch doesn't work as intended for the case when number of colors provided is 1. It returns back the same color, same brightness.
The PR makes it possible that when number of color provided is 1, then either the colors can be progressively lighter or darker as chosen, but the color itself will be of same hue. Also the brightness of successive colors can be varied using blend_variation. See the output below:
I used this code to test:
Here's the output of the main branch: All the squares have same colors and same brightness. That means no gradient at all. Since the method's name is color_gradient, the effect should have gradient.

Here's the output given by PR branch:

When transition_mode = "lighter". Each next square is lighter than the previous one.
When transition_mode = "darker". Each next square is darker than the previous one.

Reviewer Checklist