def _make_text(self): """Make elements of a duration with label and text.""" DynamicFancyText.add(self, self.label_fmt.format(self.label), colors.rgb_from_name(self.label_color)) val = self.value() if callable(self.value) else self.value # pylint: disable=not-callable if val is None: color = colors.interpolate_color(self.low_val, self.low_val, self.high_val, self.cmap) text = 'N/A' else: color = colors.interpolate_color(val, self.low_val, self.high_val, self.cmap) text = self.val_fmt.format(val) self.last_val = val DynamicFancyText.add(self, text, color)
def rainbow_text(self, font, x, y, text, box=True): """Make rainbow text.""" x_orig = x for i, char in enumerate(text): r, g, b = colors.interpolate_color(float(i) / len(text), cmap=cm.gist_rainbow) # pylint: disable=no-member x += self.text(font, x, y, r, g, b, char) if box: self.draw_box(x_orig - 2, y - font.height + 2, x, y + 2)