don't create rectangles with width or height being 0 (and some whitespace noise, sorry)
This commit is contained in:
parent
3536604fb6
commit
b4e5b60ffe
|
@ -201,11 +201,12 @@ static void rectangles()
|
||||||
clear_screen(blank);
|
clear_screen(blank);
|
||||||
for (unsigned char n = 0; n < 60; n++)
|
for (unsigned char n = 0; n < 60; n++)
|
||||||
{
|
{
|
||||||
// randomly chosen position, dimension and color
|
// randomly choose position, dimensions and color (the rectangle may
|
||||||
|
// exceed the actual screen size, only width and height have to be > 0)
|
||||||
unsigned char const x = random8() % NUM_COLS;
|
unsigned char const x = random8() % NUM_COLS;
|
||||||
unsigned char const y = random8() % NUM_ROWS;
|
unsigned char const y = random8() % NUM_ROWS;
|
||||||
unsigned char const h = random8() % NUM_COLS / 2;
|
unsigned char const w = random8() % (NUM_COLS / 2) + 1;
|
||||||
unsigned char const w = random8() % NUM_ROWS / 2;
|
unsigned char const h = random8() % (NUM_ROWS / 2) + 1;
|
||||||
unsigned char const color = random8() % (NUMPLANE + 1);
|
unsigned char const color = random8() % (NUMPLANE + 1);
|
||||||
|
|
||||||
filled_rectangle((pixel){x, y}, w, h, color);
|
filled_rectangle((pixel){x, y}, w, h, color);
|
||||||
|
@ -225,16 +226,16 @@ static void lines1()
|
||||||
clear_screen(blank);
|
clear_screen(blank);
|
||||||
for (unsigned char n = 0; n < 200; n++)
|
for (unsigned char n = 0; n < 200; n++)
|
||||||
{
|
{
|
||||||
// randomly chosen position, dimension and color
|
// randomly choose position, length and color
|
||||||
unsigned char const x = random8() % NUM_COLS;
|
unsigned char const x1 = random8() % NUM_COLS;
|
||||||
unsigned char const y = random8() % NUM_ROWS;
|
unsigned char const y1 = random8() % NUM_ROWS;
|
||||||
unsigned char const h = random8() % NUM_COLS;
|
unsigned char const x2 = random8() % NUM_COLS;
|
||||||
unsigned char const w = random8() % NUM_ROWS;
|
unsigned char const y2 = random8() % NUM_ROWS;
|
||||||
unsigned char const color = random8() % (NUMPLANE + 1);
|
unsigned char const color = random8() % (NUMPLANE + 1);
|
||||||
|
|
||||||
line((pixel){x, y}, (pixel){w, h}, color);
|
line((pixel){x1, y1}, (pixel){x2, y2}, color);
|
||||||
wait(random8()); // wait up to 250 ms
|
wait(random8()); // wait up to 250 ms
|
||||||
line((pixel){x, y}, (pixel){w, h}, blank);
|
line((pixel){x1, y1}, (pixel){x2, y2}, blank);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,7 +265,7 @@ static void dots1()
|
||||||
wait(glimmer_delay);
|
wait(glimmer_delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait up to 2500 ms until the next dot is drawn
|
// wait up to 2.5 seconds until the next dot is drawn
|
||||||
wait(random8() * 10);
|
wait(random8() * 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue