diff --git a/discord/colour.py b/discord/colour.py index 8f0426873..d91aa2a1e 100644 --- a/discord/colour.py +++ b/discord/colour.py @@ -24,6 +24,8 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ +import colorsys + class Colour: """Represents a Discord role colour. This class is similar to an (red, green, blue) :class:`tuple`. @@ -104,6 +106,12 @@ class Colour: """Constructs a :class:`Colour` from an RGB tuple.""" return cls((r << 16) + (g << 8) + b) + @classmethod + def from_hsv(cls, h, s, v): + """Constructs a :class:`Colour` from an HSV tuple.""" + rgb = colorsys.hsv_to_rgb(h, s, v) + return cls.from_rgb(*(int(x * 255) for x in rgb)) + @classmethod def default(cls): """A factory method that returns a :class:`Colour` with a value of 0."""