def _get_output_letter(rgb): """ Produce a letter for the given Rgb. Returns "?" for unknown colours. """ if rgb == Rgb.pastel_purple(): return "p" elif rgb == Rgb.pastel_yellow(): return "y" elif rgb == Rgb.pastel_green(): return "g" elif rgb == Rgb.pastel_blue(): return "b" elif rgb == Rgb.strong_red(): return " " return "?"
def _draw_red(self, intrusion): """ Draw a red area in the center based on the intrusion level. """ if intrusion is None: return if intrusion not in self.POSSIBLE_INTRUSION_LEVELS: raise ValueError( "Given value [{}] for argument \"intrusion\" is invalid". format(intrusion)) from_point = Point(0, 0) to_point = Point(0, 0) colour = Rgb() assert (len(self.POSSIBLE_INTRUSION_LEVELS) == 3) # Easy: 40 % strong_red / 316 * 316 if intrusion == self.POSSIBLE_INTRUSION_LEVELS[0]: from_point = Point(92, 92) to_point = Point(407, 407) colour = Rgb.strong_red() # Medium: 20 % med_red / 224 * 224 elif intrusion == self.POSSIBLE_INTRUSION_LEVELS[1]: from_point = Point(138, 138) to_point = Point(361, 361) colour = Rgb.med_red() # Hard: 5 % light_red / 112 * 112 elif intrusion == self.POSSIBLE_INTRUSION_LEVELS[2]: from_point = Point(194, 194) to_point = Point(305, 305) colour = Rgb.light_red() else: raise NotImplementedError( "draw_red: Intrusion level not implemented") # TODO TEMP Currently intruded means ALL is red! from_point = Point(0, 0) to_point = Point(499, 499) self._draw_area(colour, from_point, to_point)