2 solid colors on one strip

Hi I’m very new to coding and can’t seem to figure out the basic of this. Can someone give me an example of code so I can have half my strip blue and the other half purple? I know how to change color but can’t figure this out thanks!

For sure!

Would you also do me a favor and try out the “An Intro to Pixelblaze Code” pattern in the library and DM me any feedback you have?

There’s a related thread on two-color gradients that you might like to check out as well.

This should do the trick for your specific need:

blue = .6
purple = .8
export function render(index) {
  if (index < pixelCount / 2) {
    hue = blue
  } else {
    hue = purple
  }
  hsv(hue, 1, 1)
}

or succinctly,

export function render(index) {
  left = index < pixelCount / 2
  hsv(left ? .6 : .8, 1, 1)
}
2 Likes

OK tired both and they both show as just blue am I missing a step?

OK turns out it is doing it but the preview isn’t showing it

Hey Jesse! The previews only show the results of the pattern for the first 100 LEDs, so that explains why if you have over 200 LEDs configured, the preview will show all-blue.