Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
imgviz.tint(image, color, alpha=0.3)for a whole-image color wash, e.g. flagging a thumbnail in a tile sheet by red-tinting it:out = (1-alpha)*image + alpha*solid_color.coloraccepts anycmap-compatible value (name, hex, or (r, g, b) tuple; ints in [0, 255] or floats in [0, 1]), parsed viacmap.Color.alpha=0returns the input unchanged,alpha=1the solid color; out-of-[0, 1] alpha raises. Supports uint8 [0, 255] and float [0, 1] with@overloaddtype preservation. RGB-only, with an error pointing toimgviz.asrgb.Test plan
tests/unit/_tint_test.py— wash changes pixels, alpha=0 returns an unchanged copy, alpha=1 is the solid color, color formats (name/hex/tuple), float dtype preserved, and guards for non-RGB shape / invalid dtype / invalid alpha (negative, >1, NaN)uv run python examples/tint.py --save; README table refreshed viagenerate_readme.pyuv run pytest tests/unit/_tint_test.py— 13 passeduv run ruff check/uv run ruff format --check/uv run ty checkclean on touched files (incl. test + example)Closes #130