Merged with ahojnnes novice

This commit is contained in:
Michael Hansen
2014-03-19 20:58:44 -04:00
2 changed files with 13 additions and 5 deletions
+9 -5
View File
@@ -149,18 +149,22 @@ class Pixel(object):
if len(value) == 4:
self.rgba = value
else:
self._red, self._green, self._blue = (self._validate(v) for v in value)
self._red, self._green, self._blue \
= (self._validate(v) for v in value)
self._alpha = 255
self._setpixel()
@property
def rgba(self):
"""The RGB color and transparency components of the pixel (4 values 0-255)."""
"""The RGB color and transparency components of the pixel
(4 values 0-255).
"""
return (self.red, self.green, self.blue, self.alpha)
@rgba.setter
def rgba(self, value):
self._red, self._green, self._blue, self._alpha = (self._validate(v) for v in value)
self._red, self._green, self._blue, self._alpha \
= (self._validate(v) for v in value)
self._setpixel()
def _validate(self, value):
@@ -270,8 +274,8 @@ class Picture(object):
size : tuple
Width and height of the picture in pixels.
color : tuple or str
RGB or RGBA tuple with the fill color for the picture [0-255] or a valid
key in `color_dict`.
RGB or RGBA tuple with the fill color for the picture [0-255] or
a valid key in `color_dict`.
"""
if isinstance(color, six.string_types):
color = color_dict[color]
+4
View File
@@ -13,6 +13,10 @@ IMAGE_PATH = os.path.join(data_dir, "chelsea.png")
SMALL_IMAGE_PATH = os.path.join(data_dir, "block.png")
def _array_2d_to_RGBA(array):
return np.tile(array[:, :, np.newaxis], (1, 1, 4))
def _array_2d_to_RGBA(array):
return np.tile(array[:, :, np.newaxis], (1, 1, 4))