Repository navigation
Clamp finite negative alpha values to zero - #288
Open
Aschenbath wants to merge 1 commit into
Open
Aschenbath wants to merge 1 commit into
Aschenbath wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Finite negative alpha values now clamp to
0instead of becoming1. For example,tinycolor("red").setAlpha(-0.5).toRgbString()returns"rgba(255, 0, 0, 0)"; the same correction applies to RGBA/HSLA/HSVA strings, object inputs, andfromRatio().This intentionally changes the old negative-alpha behavior, which existing tests explicitly expected. Values above
1still become1, and non-numeric values,NaN, and both infinities retain the existing fallback of1. Update those old expectations, add boundary and input-format regressions, document the normalization rules, and regenerate the distributed CJS/ESM/UMD copies.Fixes #287.
Validation: 47 tests passed with 1 existing
polyadskip in Deno 1.46.3 and 2.9.8, and in the generated CJS/ESM runners on Node 18.20.8 and 24.22.0. The new expectations produced 5 failures before the fix. Checkout and installed-package consumer checks passed 87,948 assertions across 36 entrypoint runs, including browser UMD realms and unchanged in-range color operations. Package-namerequire()andimport()also passed.Build note: the historical esm.sh Babel URLs no longer match the checked-in lock hashes. Distribution files were generated with the unchanged
build.js, mapping those two imports to the same pinned npm versions (@babel/core@7.20.12,@babel/preset-env@7.20.2) and starting from a copy of the repository lockfile. The resulting library differences are limited toboundAlpha()and its comment; the repository build configuration and lockfile are unchanged.Implemented and tested with OpenAI Codex, including an independent agent review.