Selaa lähdekoodia

Please...

master
Ognjen Milan Robovic 8 kuukautta sitten
vanhempi
commit
41efa4a5f8
2 muutettua tiedostoa jossa 37 lisäystä ja 38 poistoa
  1. +37
    -38
      xuxuxu.c
  2. BIN
      xuxuxu.png

+ 37
- 38
xuxuxu.c Näytä tiedosto

@@ -44,19 +44,19 @@ static int fetch_width (char * data) {
int image_width = 0;
int count = 0;

for (; * data != '\0'; ++data) {
++count;

if (* data == '\t')
count += TAB_WIDTH - 1;

if (* data == '\n') {
do {
if (* data == '\t') {
count += TAB_WIDTH;
} else if (* data == '\n') {
++count;
image_width = (count > image_width)
? count
: image_width;
count = 0;
} else {
++count;
}
}
} while (* (++data) != '\0');

return (image_width - 1);
}
@@ -64,9 +64,11 @@ static int fetch_width (char * data) {
static int fetch_height (char * data) {
int image_height = 0;

for (; * data != '\0'; ++data)
if (* data == '\n')
image_height++;
do {
if (* data == '\n') {
++image_height;
}
} while (* (++data) != '\0');

return (image_height + 1);
}
@@ -107,55 +109,48 @@ static void fetch_font_glyph (unsigned int * glyph, const char character) {
0X000C18187018180C, 0X000000000062D68C, 0X0000000000000000
};

int byte_mark = 0;
int offset = 0;
unsigned long int font_code = 0;

font_code = font_code_list [(int) character];

for (byte_mark = 0; byte_mark != FONT_WIDTH * FONT_HEIGHT; ++byte_mark)
glyph [byte_mark] = ((font_code >> byte_mark) % 2)
? select
: BACKGROUND;
do {
glyph [offset] = ((font_code >> offset) & 1)
? select
: BACKGROUND;
} while (++offset != FONT_WIDTH * FONT_HEIGHT);
}

static void render_character (char character) {
unsigned int glyph [FONT_WIDTH * FONT_HEIGHT] = { 0 };

int i = 0;
int offset = 0;

fetch_font_glyph (glyph, character);

for (i = 0; i != FONT_WIDTH * FONT_HEIGHT; ++i) {
int u = i / FONT_WIDTH + y;
int v = i % FONT_WIDTH + x;
do {
int u = offset / FONT_WIDTH + y;
int v = offset % FONT_WIDTH + x;

render [u * width + v] = glyph [i];
}
render [u * width + v] = glyph [offset];
} while (++offset != FONT_WIDTH * FONT_HEIGHT);

x += FONT_WIDTH + 1;
}

static void render_string (char * string, int length) {
int i = 0;
int offset = 0;

for (i = 0; (i != string_length (string)) && (i != length); ++i) {
if (string [i] == '\t') {
do {
if (string [offset] == '\t') {
x += FONT_WIDTH * TAB_WIDTH;
} else if (string [i] == '\n') {
} else if (string [offset] == '\n') {
y += FONT_HEIGHT + 1;
x = 1;
x = 1;
} else {
render_character (string [i] - ' ');
render_character (string [offset] - ' ');
}
}
}

static void render_base (void) {
int i = 0;

for (i = 0; i != width * height; ++i) {
render [i] = BACKGROUND;
}
} while (++offset != length);
}

int main (void) {
@@ -197,7 +192,11 @@ int main (void) {

render = allocate (4 * width * height);

render_base ();
do {
render [offset] = BACKGROUND;
} while (++offset != width * height);

offset = 0;

do {
int colour = 0;


BIN
xuxuxu.png Näytä tiedosto

Before After
Width: 1351  |  Height: 2098  |  Size: 88KB Width: 1351  |  Height: 2089  |  Size: 88KB

Loading…
Peruuta
Tallenna