From 7c577804bb171d1502dcc14d0a966fb32bedfb3c Mon Sep 17 00:00:00 2001 From: facelessuser Date: Wed, 4 Dec 2024 20:36:39 -0700 Subject: [PATCH] Fix spelling and lint and types --- coloraide/average.py | 2 +- docs/src/markdown/about/changelog.md | 2 +- docs/src/markdown/average.md | 8 ++++---- tools/average_img.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/coloraide/average.py b/coloraide/average.py index 98d2a304..243be900 100644 --- a/coloraide/average.py +++ b/coloraide/average.py @@ -103,6 +103,6 @@ def average( w, b = cs.indexes()[1:] # type: ignore[attr-defined] if color[w] + color[b] < 1: color[w] = 1 - color[b] - elif math.isnan(color[hue_index]) and not math.isnan(color[cs.radial_index()]): + elif math.isnan(color[hue_index]) and not math.isnan(color[cs.radial_index()]): # type: ignore[attr-defined] color[cs.radial_index()] = 0 # type: ignore[attr-defined] return color diff --git a/docs/src/markdown/about/changelog.md b/docs/src/markdown/about/changelog.md index 5ebfd8ca..369a9f52 100644 --- a/docs/src/markdown/about/changelog.md +++ b/docs/src/markdown/about/changelog.md @@ -10,7 +10,7 @@ averaging, the color will be treated as if achromatic, setting saturation/chroma as necessary. This is needed to prevent serialization of achromatic colors to a non-achromatic color when undefined values are resolved. - **FIX**: Fully transparent colors should only contribute alpha in color averaging, regardless of `premultiply` - setting. This prevents fully transparent color channels, which provide no meaniful data, from distorting averages. + setting. This prevents fully transparent color channels, which provide no meaningful data, from distorting averages. - **FIX**: When averaging in a polar space, if a color is considered achromatic but does not have an undefined hue, the hue will be treated as undefined. Essentially the `powerless` parameter is now always `True`. This ensures that achromatic colors properly contribute to the average without distorting the hue. diff --git a/docs/src/markdown/average.md b/docs/src/markdown/average.md index 4d78a624..9915aec3 100644 --- a/docs/src/markdown/average.md +++ b/docs/src/markdown/average.md @@ -38,7 +38,7 @@ Color.average(['purple', 'green', 'blue']) Color.average(['purple', 'green', 'blue'], space='hsl') ``` -It should be noted that when averaging colors with hues which are evently distributed around the color wheel, the result +It should be noted that when averaging colors with hues which are evenly distributed around the color wheel, the result will produce an achromatic hue. When achromatic hues are produced during circular mean, the color will discard chroma/saturation information, producing an achromatic color. @@ -61,10 +61,10 @@ for i in range(12): There are cases where this approach of averaging may not be desired. It may be that color averaging is desired without considering transparency. If so, `premultiplied` can be disabled by setting it to `#!py False`. While the average of -transparency is calculated, it can be discared from the final result if desired. +transparency is calculated, it can be discarded from the final result if desired. It should be noted that when a color is fully transparent, its color components will be ignored, regardless of the -`premultiplied` parameter, as fully transparent colors provide no meaniful color information. +`premultiplied` parameter, as fully transparent colors provide no meaningful color information. ```py play for i in range(12): @@ -84,7 +84,7 @@ Color.average(['white', 'color(srgb 0 0 1)'], space='hsl') ``` When averaging hues in a polar space, implied achromatic hues are also treated as undefined as counting such hues would -distort the average in a non-meaniful way. +distort the average in a non-meaningful way. ```py play Color.average(['hsl(30 0 100)', 'hsl(240 100 50 / 1)'], space='hsl') diff --git a/tools/average_img.py b/tools/average_img.py index 7be79606..bfeeee99 100644 --- a/tools/average_img.py +++ b/tools/average_img.py @@ -60,7 +60,7 @@ def iter_image(img, space, no_resize): if im.mode not in ('RGBA',): im = im.convert('RGBA') - if not no_resize and im.size[0] > 500 or im.size[1] > 500: + if not no_resize and (im.size[0] > 500 or im.size[1] > 500): factor = 500 / max(im.size) new_im = im.resize((max(1, int(im.size[0] * factor)), max(1, int(im.size[1] * factor)))) else: