Given integer values of Red, Green, Blue, return a color string "#RRGGBB" :param red: Red portion from 0 to 255 :type red: (int) :param green: Green portion from 0 to 255 :type green: (int) :param blue: Blue portion from 0 to 255 :type blue: (int) :return:
(red, green, blue)
| 628 | # One-liner functions that are handy as f_ck # |
| 629 | # ====================================================================== # |
| 630 | def rgb(red, green, blue): |
| 631 | """ |
| 632 | Given integer values of Red, Green, Blue, return a color string "#RRGGBB" |
| 633 | :param red: Red portion from 0 to 255 |
| 634 | :type red: (int) |
| 635 | :param green: Green portion from 0 to 255 |
| 636 | :type green: (int) |
| 637 | :param blue: Blue portion from 0 to 255 |
| 638 | :type blue: (int) |
| 639 | :return: A single RGB String in the format "#RRGGBB" where each pair is a hex number. |
| 640 | :rtype: (str) |
| 641 | """ |
| 642 | red = min(int(red), 255) if red > 0 else 0 |
| 643 | blue = min(int(blue), 255) if blue > 0 else 0 |
| 644 | green = min(int(green), 255) if green > 0 else 0 |
| 645 | return '#%02x%02x%02x' % (red, green, blue) |
| 646 | |
| 647 | |
| 648 | # ====================================================================== # |