add Color.random

This commit is contained in:
iDutchy
2020-11-19 18:46:42 -06:00
parent b61b5b7414
commit 725f08e45d
4 changed files with 12 additions and 5 deletions

View File

@@ -25,6 +25,7 @@ DEALINGS IN THE SOFTWARE.
"""
import colorsys
import random
class Colour:
"""Represents a Discord role colour. This class is similar
@@ -118,6 +119,11 @@ class Colour:
rgb = colorsys.hsv_to_rgb(h, s, v)
return cls.from_rgb(*(int(x * 255) for x in rgb))
@classmethod
def random(cls):
"""A factory method that returns a :class:`Colour` with a random value."""
return cls.from_hsv(random.random(), 1, 1)
@classmethod
def default(cls):
"""A factory method that returns a :class:`Colour` with a value of ``0``."""