Add Colour.from_rgb.

This commit is contained in:
Rapptz 2017-05-15 03:36:47 -04:00
parent c1130d2879
commit 6f53491f9a

View File

@ -97,6 +97,11 @@ class Colour:
"""Returns an (r, g, b) tuple representing the colour.""" """Returns an (r, g, b) tuple representing the colour."""
return (self.r, self.g, self.b) return (self.r, self.g, self.b)
@classmethod
def from_rgb(cls, r, g, b):
"""Constructs a :class:`Colour` from an RGB tuple."""
return cls((r << 16) + (g << 8) + b)
@classmethod @classmethod
def default(cls): def default(cls):
"""A factory method that returns a :class:`Colour` with a value of 0.""" """A factory method that returns a :class:`Colour` with a value of 0."""