From 930059814d16a33a2e83f15e45fdbbf338f02813 Mon Sep 17 00:00:00 2001 From: Esteban Gehring Date: Mon, 4 Jan 2021 13:42:15 +0100 Subject: [PATCH 1/5] docs: add alpha channel to supported hex color specifiers --- docs/reference/ImageColor.rst | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/reference/ImageColor.rst b/docs/reference/ImageColor.rst index e32a77b54..9730bd28f 100644 --- a/docs/reference/ImageColor.rst +++ b/docs/reference/ImageColor.rst @@ -16,8 +16,17 @@ Color Names The ImageColor module supports the following string formats: -* Hexadecimal color specifiers, given as ``#rgb`` or ``#rrggbb``. For example, - ``#ff0000`` specifies pure red. +* Hexadecimal color specifiers, given as ``#rgb``, ``#rgba``, ``#rrggbb`` or ``#rrggbbaa``, + with the following placeholders: + - ``r``: red + - ``g``: green + - ``b``: blue + - ``a``: alpha / opacity (can be used in combination with ``mode="RGBA"`` in :py:mod:`~PIL.ImageDraw`) + + Examples: + - ``#ff0000`` specifies pure red. + - ``#ff0000aa`` specifies pure red with an opacity of 66.66% (aa = 170, opacity = 170/255). + * RGB functions, given as ``rgb(red, green, blue)`` where the color values are integers in the range 0 to 255. Alternatively, the color values can be given From 497f9e27642f6ce421ed3f7cf7038cfa12ef4af2 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Fri, 8 Jan 2021 00:06:18 +1100 Subject: [PATCH 2/5] Fixed unexpected indentation [ci skip] --- docs/reference/ImageColor.rst | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/docs/reference/ImageColor.rst b/docs/reference/ImageColor.rst index 9730bd28f..457f166b4 100644 --- a/docs/reference/ImageColor.rst +++ b/docs/reference/ImageColor.rst @@ -16,16 +16,20 @@ Color Names The ImageColor module supports the following string formats: -* Hexadecimal color specifiers, given as ``#rgb``, ``#rgba``, ``#rrggbb`` or ``#rrggbbaa``, - with the following placeholders: - - ``r``: red - - ``g``: green - - ``b``: blue - - ``a``: alpha / opacity (can be used in combination with ``mode="RGBA"`` in :py:mod:`~PIL.ImageDraw`) - +* Hexadecimal color specifiers, given as ``#rgb``, ``#rgba``, ``#rrggbb`` or + ``#rrggbbaa``, with the following placeholders: + + - ``r`` red + - ``g`` green + - ``b`` blue + - ``a`` alpha / opacity (can be used in combination with ``mode="RGBA"`` in + :py:mod:`~PIL.ImageDraw`) + Examples: - - ``#ff0000`` specifies pure red. - - ``#ff0000aa`` specifies pure red with an opacity of 66.66% (aa = 170, opacity = 170/255). + + - ``#ff0000`` specifies pure red. + - ``#ff0000aa`` specifies pure red with an opacity of 66.66% (aa = 170, opacity = + 170/255). * RGB functions, given as ``rgb(red, green, blue)`` where the color values are From e4a8783e8864cddb885fdda85d01e771f2135493 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Tue, 9 Feb 2021 19:44:51 +1100 Subject: [PATCH 3/5] Changed example value to avoid using "a" --- docs/reference/ImageColor.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/reference/ImageColor.rst b/docs/reference/ImageColor.rst index 457f166b4..23b46b06c 100644 --- a/docs/reference/ImageColor.rst +++ b/docs/reference/ImageColor.rst @@ -28,8 +28,8 @@ The ImageColor module supports the following string formats: Examples: - ``#ff0000`` specifies pure red. - - ``#ff0000aa`` specifies pure red with an opacity of 66.66% (aa = 170, opacity = - 170/255). + - ``#ff0000cc`` specifies pure red with an opacity of 80% (cc = 204, opacity = + 204/255). * RGB functions, given as ``rgb(red, green, blue)`` where the color values are From 6c0af0fdfbea899e3e6a6beb3a7f94e4fedc0003 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Tue, 9 Feb 2021 19:46:07 +1100 Subject: [PATCH 4/5] Removed ImageDraw reference --- docs/reference/ImageColor.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/reference/ImageColor.rst b/docs/reference/ImageColor.rst index 23b46b06c..95ed17438 100644 --- a/docs/reference/ImageColor.rst +++ b/docs/reference/ImageColor.rst @@ -22,8 +22,7 @@ The ImageColor module supports the following string formats: - ``r`` red - ``g`` green - ``b`` blue - - ``a`` alpha / opacity (can be used in combination with ``mode="RGBA"`` in - :py:mod:`~PIL.ImageDraw`) + - ``a`` alpha / opacity Examples: From e64d62e568b4674dd91d7b330fc83060d4cd31fb Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Tue, 9 Feb 2021 19:47:40 +1100 Subject: [PATCH 5/5] Adjusted formatting [ci skip] --- docs/reference/ImageColor.rst | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/docs/reference/ImageColor.rst b/docs/reference/ImageColor.rst index 95ed17438..20237eccf 100644 --- a/docs/reference/ImageColor.rst +++ b/docs/reference/ImageColor.rst @@ -17,19 +17,10 @@ Color Names The ImageColor module supports the following string formats: * Hexadecimal color specifiers, given as ``#rgb``, ``#rgba``, ``#rrggbb`` or - ``#rrggbbaa``, with the following placeholders: - - - ``r`` red - - ``g`` green - - ``b`` blue - - ``a`` alpha / opacity - - Examples: - - - ``#ff0000`` specifies pure red. - - ``#ff0000cc`` specifies pure red with an opacity of 80% (cc = 204, opacity = - 204/255). - + ``#rrggbbaa``, where ``r`` is red, ``g`` is green, ``b`` is blue and ``a`` is + alpha (also called 'opacity'). For example, ``#ff0000`` specifies pure red, + and ``#ff0000cc`` specifies red with 80% opacity (``cc`` is 204 in decimal + form, and 204 / 255 = 0.8). * RGB functions, given as ``rgb(red, green, blue)`` where the color values are integers in the range 0 to 255. Alternatively, the color values can be given