Color lights/led strip brightness change affect color

I have a script for “slow dim” of color led strip.
The script is changing brightness only.
But really it changes both brightness and all type of colors (rgb, xy, hs).

If I start with some custom color for example:
image

I’m changing on the “brightness” parameter, but all other affected as well:
image

Another try:
image

If I dim to much lower brightness it change the value dramaticly:
image

Can you suggest how I can still use the dim/set brightness and to keep the actual color?

Thanks!