>>> Burkes.get_greyscale(3, 4, 5) 4.185 >>> Burkes.get_greyscale(0, 0, 0) 0.0 >>> Burkes.get_greyscale(255, 255, 255) 255.0
(cls, blue: int, green: int, red: int)
| 38 | |
| 39 | @classmethod |
| 40 | def get_greyscale(cls, blue: int, green: int, red: int) -> float: |
| 41 | """ |
| 42 | >>> Burkes.get_greyscale(3, 4, 5) |
| 43 | 4.185 |
| 44 | >>> Burkes.get_greyscale(0, 0, 0) |
| 45 | 0.0 |
| 46 | >>> Burkes.get_greyscale(255, 255, 255) |
| 47 | 255.0 |
| 48 | """ |
| 49 | """ |
| 50 | Formula from https://en.wikipedia.org/wiki/HSL_and_HSV |
| 51 | cf Lightness section, and Fig 13c. |
| 52 | We use the first of four possible. |
| 53 | """ |
| 54 | return 0.114 * blue + 0.587 * green + 0.299 * red |
| 55 | |
| 56 | def process(self) -> None: |
| 57 | for y in range(self.height): |