|
|
@ -13,12 +13,12 @@ class Pixel(namedtuple('Pixel', ['r', 'g', 'b'])):
|
|
|
|
self.b + other.b,
|
|
|
|
self.b + other.b,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
def __mul__(self, other):
|
|
|
|
def __mul__(self, other):
|
|
|
|
if not isinstance(other, int) or not isinstance(other, float):
|
|
|
|
if not isinstance(other, int) and not isinstance(other, float):
|
|
|
|
raise ValueError('Can only multiply by number')
|
|
|
|
raise ValueError('Can only multiply by number')
|
|
|
|
return Pixel(
|
|
|
|
return Pixel(
|
|
|
|
other*pixel.r,
|
|
|
|
other*self.r,
|
|
|
|
other*pixel.g,
|
|
|
|
other*self.g,
|
|
|
|
other*pixel.b,
|
|
|
|
other*self.b,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def weighted_average(p1, w1, p2, w2):
|
|
|
|
def weighted_average(p1, w1, p2, w2):
|
|
|
|