Add Colour.from_rgb.
This commit is contained in:
parent
c1130d2879
commit
6f53491f9a
@ -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."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user