mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
LOLWUT: version 6: improve rithm of the image.
This commit is contained in:
parent
c10889150e
commit
58cdc054e3
@ -62,8 +62,8 @@ static sds renderCanvas(lwCanvas *canvas) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Draw a skyscraper on the canvas, according to the parameters in the
|
/* Draw a skyscraper on the canvas, according to the parameters in the
|
||||||
* 'skyscraper' structure. Window colors are random and are always selected
|
* 'skyscraper' structure. Window colors are random and are always one
|
||||||
* to be different than the color of the skyscraper itsefl. */
|
* of the two grays. */
|
||||||
struct skyscraper {
|
struct skyscraper {
|
||||||
int xoff; /* X offset. */
|
int xoff; /* X offset. */
|
||||||
int width; /* Pixels width. */
|
int width; /* Pixels width. */
|
||||||
@ -100,7 +100,7 @@ void generateSkyscraper(lwCanvas *canvas, struct skyscraper *si) {
|
|||||||
* (characters) are not square. */
|
* (characters) are not square. */
|
||||||
if (relx/2 % 2 && rely % 2) {
|
if (relx/2 % 2 && rely % 2) {
|
||||||
do {
|
do {
|
||||||
color = rand() % 4;
|
color = 1 + rand() % 2;
|
||||||
} while (color == si->color);
|
} while (color == si->color);
|
||||||
/* Except we want adjacent pixels creating the same
|
/* Except we want adjacent pixels creating the same
|
||||||
* window to be the same color. */
|
* window to be the same color. */
|
||||||
@ -117,17 +117,25 @@ void generateSkyline(lwCanvas *canvas) {
|
|||||||
struct skyscraper si;
|
struct skyscraper si;
|
||||||
|
|
||||||
/* First draw the background skyscraper without windows, using the
|
/* First draw the background skyscraper without windows, using the
|
||||||
* two different grays. */
|
* two different grays. We use two passes to make sure that the lighter
|
||||||
si.color = 1;
|
* ones are always in the background. */
|
||||||
for (int offset = -10; offset < canvas->width;) {
|
for (int color = 2; color >= 1; color--) {
|
||||||
offset += rand() % 8;
|
si.color = color;
|
||||||
si.xoff = offset;
|
for (int offset = -10; offset < canvas->width;) {
|
||||||
si.width = 10 + rand()%9;
|
offset += rand() % 8;
|
||||||
si.height = canvas->height/2 + rand()%canvas->height/2;
|
si.xoff = offset;
|
||||||
si.windows = 0;
|
si.width = 10 + rand()%9;
|
||||||
si.color = si.color == 1 ? 2 : 1;
|
if (color == 2)
|
||||||
generateSkyscraper(canvas, &si);
|
si.height = canvas->height/2 + rand()%canvas->height/2;
|
||||||
offset += si.width/2;
|
else
|
||||||
|
si.height = canvas->height/2 + rand()%canvas->height/3;
|
||||||
|
si.windows = 0;
|
||||||
|
generateSkyscraper(canvas, &si);
|
||||||
|
if (color == 2)
|
||||||
|
offset += si.width/2;
|
||||||
|
else
|
||||||
|
offset += si.width+1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now draw the foreground skyscraper with the windows. */
|
/* Now draw the foreground skyscraper with the windows. */
|
||||||
@ -137,10 +145,10 @@ void generateSkyline(lwCanvas *canvas) {
|
|||||||
si.xoff = offset;
|
si.xoff = offset;
|
||||||
si.width = 5 + rand()%14;
|
si.width = 5 + rand()%14;
|
||||||
if (si.width % 4) si.width += (si.width % 3);
|
if (si.width % 4) si.width += (si.width % 3);
|
||||||
si.height = canvas->height/2 + rand()%canvas->height/2;
|
si.height = canvas->height/3 + rand()%canvas->height/2;
|
||||||
si.windows = 1;
|
si.windows = 1;
|
||||||
generateSkyscraper(canvas, &si);
|
generateSkyscraper(canvas, &si);
|
||||||
offset += si.width+1;
|
offset += si.width+5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user