def _update_bg(self, background): """ Parses several valid inputs including: None, Path, Color (of any valid to_normRGB() type, ndarray, (Color, Resolution).""" if background is None: self._background = self.color_background self._bgstyle = 'default' elif isinstance(background, Grid): self._background = bgu.from_grid(background) self._bgstyle = 'grid' elif isinstance(background, np.ndarray): self._background = background self._bgstyle = 'ndarray' # colorstring or hex elif isinstance(background, basestring): self._background = bgu.from_string(background, self.rx, self.ry) self._bgstyle = 'file/colorstring/url' # If not array, color is assume as valid to_norm_rgb(color) arg # It will raise its own error if failure occurs else: self._background = bgu.from_color_res(background, self.rx, self.ry) self._bgstyle = 'color' # Float-color convert array self._background = any2rgb(self._background, 'background')
def color_background(self): """ Generate a colored background at current resolution """ return bgu.from_color_res(BGCOLOR, self.rx, self.ry)