-
Notifications
You must be signed in to change notification settings - Fork 0
/
letterrender.c
96 lines (92 loc) · 1.99 KB
/
letterrender.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
* $Id: letterrender.c 264 2005-11-06 17:43:44Z mrbrown $
*
* Copyright 2002 Kenta Cho. All rights reserved.
*/
/**
* Letter render.
*
* @version $Revision: 264 $
*/
#include "screen.h"
#include "letterrender.h"
#include "letterdata.h"
void drawLetter(int idx, int lx, int ly, int ltSize, int d,
int r, int g, int b) {
int i;
float x, y, length, size, t;
int deg;
for ( i=0 ; ; i++ ) {
deg = (int)spData[idx][i][4];
if ( deg > 99990 ) break;
x = -spData[idx][i][0]; y = -spData[idx][i][1];
size = spData[idx][i][2]; length = spData[idx][i][3];
size *= 0.66f; length *= 0.6f;
switch ( d ) {
case 0:
x = -x; y = y;
break;
case 1:
t = x; x = -y; y = -t;
deg += 90;
break;
case 2:
x = x; y = -y;
deg += 180;
break;
case 3:
t = x; x = y; y = t;
deg += 270;
break;
}
deg %= 180;
if ( deg <= 45 || deg > 135 ) {
drawBox((int)(x*ltSize)+lx, (int)(y*ltSize)+ly,
(int)(size*ltSize), (int)(length*ltSize), r, g, b);
} else {
drawBox((int)(x*ltSize)+lx, (int)(y*ltSize)+ly,
(int)(length*ltSize), (int)(size*ltSize), r, g, b);
}
}
}
void drawString(char *str, int lx, int ly, int ltSize, int d,
int r, int g, int b) {
int x = lx, y = ly;
int i, c, idx;
for ( i=0 ; ; i++ ) {
if ( str[i] == '\0' ) break;
c = str[i];
if ( c != ' ' ) {
if ( c >= '0' && c <='9' ) {
idx = c-'0';
} else if ( c >= 'A' && c <= 'Z' ) {
idx = c-'A'+10;
} else if ( c >= 'a' && c <= 'z' ) {
idx = c-'a'+10;
} else if ( c == '.' ) {
idx = 36;
} else if ( c == '-' ) {
idx = 38;
} else if ( c == '+' ) {
idx = 39;
} else {
idx = 37;
}
drawLetter(idx, x, y, ltSize, d, r, g, b);
}
switch ( d ) {
case 0:
x += ltSize*1.7f;
break;
case 1:
y += ltSize*1.7f;
break;
case 2:
x -= ltSize*1.7f;
break;
case 3:
y -= ltSize*1.7f;
break;
}
}
}