displayio: Improve docs about Colorspaces

This commit is contained in:
Jeff Epler 2021-04-23 09:57:24 -05:00
parent 34c4cc1bd9
commit 05a81a066e
2 changed files with 11 additions and 12 deletions

View File

@ -40,15 +40,14 @@
//| class ColorConverter:
//| """Converts one color format to another."""
//|
//| def __init__(self, *, dither: bool = False) -> None:
//| """Create a ColorConverter object to convert color formats. Only supports RGB888 to RGB565
//| currently.
//| def __init__(self, *, colorspace: Colorspace=Colorspace.RGB888, dither: bool = False) -> None:
//| """Create a ColorConverter object to convert color formats.
//|
//| :param Colorspace colorspace: The source colorspace, one of the Colorspace constants
//| :param bool dither: Adds random noise to dither the output image"""
//| ...
//|
// TODO(tannewt): Add support for other color formats.
//|
STATIC mp_obj_t displayio_colorconverter_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum { ARG_dither, ARG_input_colorspace };
@ -68,7 +67,7 @@ STATIC mp_obj_t displayio_colorconverter_make_new(const mp_obj_type_t *type, siz
}
//| def convert(self, color: int) -> int:
//| """Converts the given RGB888 color to RGB565"""
//| """Converts the given color to RGB565 according to the Colorspace"""
//| ...
//|
STATIC mp_obj_t displayio_colorconverter_obj_convert(mp_obj_t self_in, mp_obj_t color_obj) {

View File

@ -72,22 +72,22 @@ MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB555, DISPLAY
MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB555_SWAPPED, DISPLAYIO_COLORSPACE_RGB555_SWAPPED);
//| class Colorspace:
//| """The colorspace for a ColorConverter to operate in"""
//| """The colorspace for a `ColorConverter` to operate in"""
//|
//| RGB888: object
//| """The standard 24-bit colorspace"""
//| """The standard 24-bit colorspace. Bits 0-7 are blue, 8-15 are green, and 16-24 are red. (0xRRGGBB)"""
//|
//| RGB565: object
//| """The standard 16-bit colorspace"""
//| """The standard 16-bit colorspace. Bits 0-4 are blue, bits 5-10 are green, and 11-15 are red (0bRRRRRGGGGGGBBBBB)"""
//|
//| RGB565_SWAPPED: object
//| """The standard 16-bit colorspace, with low and high bytes swapped"""
//| """The swapped 16-bit colorspace. First, the high and low 8 bits of the number are swapped, then they are interpreted as for RGB565"""
//|
//| RGB555: object
//| """The standard 15-bit colorspace"""
//| """The standard 15-bit colorspace. Bits 0-4 are blue, bits 5-9 are green, and 11-14 are red. The top bit is ignored. (0bxRRRRRGGGGGBBBBB)"""
//|
//| RGB555_SWAPPED: object
//| """The standard 15-bit colorspace, with low and high bytes swapped"""
//| """The swapped 15-bit colorspace. First, the high and low 8 bits of the number are swapped, then they are interpreted as for RGB555"""
//|
MAKE_ENUM_MAP(displayio_colorspace) {
MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB888),