-
Notifications
You must be signed in to change notification settings - Fork 0
/
text.c
46 lines (43 loc) · 802 Bytes
/
text.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "text.h"
#include "mylib.h"
void drawChar(int x, int y, char ch, unsigned short color)
{
int x1, y1;
for(x1=0; x1<6; x1++)
{
for(y1=0; y1<8; y1++)
{
if(fontdata_6x8[OFFSET2(x1, y1, 6)+ch*48])
{
setPixel(x+x1, y+y1, color);
}
}
}
}
/*
*
* I didn't code this in class but I will go over it next lecture
*
* You can call it like this:
*
* drawString(10, 10, "Hello!", YELLOW);
*
* or like this:
*
* char *message = "This is a message.";
* drawString(20, 5, message, RED);
*
* or like this:
*
* char buffer[41] = "This is a char array!";
* drawString(30, 5, buffer, GREEN);
*
*/
void drawString(int x, int y, char *str, unsigned short color)
{
while(*str)
{
drawChar(x, y, *str++, color);
x +=6;
}
}