I’ve been experimenting, trying to add a dynamic range of color to my code. Early on I found that I could only change the color of the stroke line in its entirety, which didn’t really create the effect I was looking for.
With Tim’s help, I managed to get the line color changing a little more dynamically by mapping the amplitude data into the stroke color values, so that the colors would have different saturation and brightness depending on the notes of the song.
stroke(20, 0, map(volhistory[i], 0, 1, 100, 250));
I quickly figured out that even with this, the output still looked a bit flat. So to get the effect I wanted I reiterated the stroke line multiple times and then gave each version of the line its own values, so that there was a more cohesive color palette.
Finally I have the output looking more how I’d like it to:
Both are based off different songs. The colors have been picked manually mostly, but the addition of the data mapping makes it so that when the code runs the colors change with the song.
My goal initially was to have the stroke line draw color continuously (so that with each vertex reached, that portion of the stroke line would be a different color according to the data), rather than keep each stroke line a solid color. When I researched this though I found out that it’s not possible in p5, as it only uses the canvas renderer, which doesn’t allow for that effect.