Hi everyone, i'm trying to find a way to do some kind of "complementary

Hi everyone, i’m trying to find a way to do some kind of “complementary color” function, working accordily with the rainbow function. It works with stationary color… but i don’t know how to do the complementary color rainbow effect… any advice?

for( int i = 0; i < NUM_LEDS1; i++) {
leds1[i] = ColorFromPalette( RainbowColors_p, colorIndex, brightness, BLEND);
// leds1[i] = CRGB(0,0,255); // with this line works althought without rainbow movement…
leds2[i] = CRGB(255-leds1[i].red, 255-leds1[i].green, 255-leds1[i].blue);

You can generate roughly-complementary colours by using a fixed hue offset – use the same saturation and value, and satisfy ((hue1 - hue2) == someConstant).

First, use CHSV instead of CRGB.

With CHSV, the Hue is represented by a value between 0-255 that will go through all the rainbow colors.

If you define hue as a byte variable…

You only need to add 128 to any hue value to get it’s exact opposite on the rainbow.

Of course you can play with that value as suggested above. That may give you an effect closer to what you are after.

Thankyou very much guys! I was playing now creating a custom palette, but tomorrow will give a try to you suggestion! as always, what a pleasure to be on this community!