I need some help with drawing a line segment of random color and random direction. Similar to the draw line function in processing. The random color is not hard but i have no idea how you could make the direction random. Each new line would be generated by a pushbutton and vanish at the end of the strip.
Is this for a 1d effect on a strip, or a 2d effect on a matrix?
1d effect on a strip
Jeremy’s suggestion is an interesting one. Always good to think about different sorts of efficiencies.
I’ve done something like in the past to get a random “forward” or “backward” direction.
int8_t delta = random8(0,2); //returns 0 or 1
if (delta == 0) { delta = -1; )
This leaves you with delta being either -1 or 1, which you can then use in an equation to drives something positive or negative via addition or multiplication.
Or you could just leave the above initial result as 0 or 1 and then use that to drive the correct if statement as needed.
if (delta == 0) {
//do negative direction stuff here
}
if (delta == 1) {
//do positive direction stuff here
}
Thanx! You guys are the best!