-
-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[@thi.ng/color] mix() updates input color #387
Comments
Sorry, @cdaein - this needs to be added to the docs! Since the colors are all "vector" based, the behavior of this function (and possibly others in the color package) is the same as most of the functions in the https://thi.ng/vectors package:
So in your case this would mean if the 1st arg to Another important addition for these functions in the colors package (e.g. also const a = hsv(0,1,1);
const b = hsv(0.5, 0.5, 0.5);
// result written to a (i.e. res === a)
const res = mix(null, a, b, 0.1);
// result written to a new hsv color
const res = mix(hsv(), a, b, 0.1);
// result written to new untyped raw color array, then wrapped as hsv
const res = hsv(mix([], a, b, 0.1));
// result written to a new color w/ same mode as `a`
// (useful if you don't know what mode/space a is in originally)
const res = mix(a.empty(), a, b, 0.1);
// similar to previous, but using ICopy interface instead
const res = mix(a.copy(), a, b, 0.1); Btw. The last two examples are making use of the general Hth! Will add docs for this ASAP - sorry for the confusion! |
Oh, I have missed that.. Thank you very much for the clarification and the clear examples! 🙏 |
Not your fault to miss that little note! Just pushed a commit (cda14bf) making this behavior (hopefully) more obvious in the doc strings for all relevant functions... More pkg updates incoming (oklch support and some other improvements), new version soon! |
Hi,
I am using
mix()
in@thi.ng/color
to manually lerp colors. After using it, when I check the original input color, it has been transformed.It works fine if I reuse the same color object:
I'm wondering if I am missing anything.
Thank you!
The text was updated successfully, but these errors were encountered: