-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNombres.cpp
147 lines (126 loc) · 2.8 KB
/
Nombres.cpp
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#define TOPLEFT 0
#define TOPMIDDLE 1
#define TOPRIGHT 2
#define CENTERLEFT 3
#define CENTER 4
#define CENTERRIGHT 5
#define BOTTOMLEFT 6
#define BOTTOMMIDDLE 7
#define BOTTOMRIGHT 8
private int Dessin::segments(char *chaine, int x, int y, int taille, uint color)
{
// Taille = hauteur du caractère en nombre de pixels
// Taille mini = 9
double unite = taille / 18.0;
int i,j;
int x1, x2, x3, y1, y2, y3;
while (*chaine != '\0')
{
switch *chaine:
{
case 'a':
x1 = (int)round(unite) + x;
x2 = (int)round(unite*8) + x;
y1 = y;
y2 = (int)round(unite) + y;
y3 = (int)round(unite*2) + y;
for (y=y1, y<y2; y++)
{
LigneHor(x1, x2, y, color);
x1--;
x2++;
}
for (y=y2, y<=y3; y++)
{
LigneHor(x1, x2, y, color);
x1++;
x2--;
}
break;
case 'b';
x1 = (int)round(unite*8) + x;
x2 = (int)round(unite*9) + x;
x3 = (int)round(unite*10) + x;
y1 = (int)round(unite*2) + y;
y2 = (int)round(unite*8) + y;
for (x=x1; x<x2; x++)
{
LigneVer(y1, y2, x, color);
y1--;
y2++;
}
for (x=x2; x<=x3; x++)
{
LigneVer(y1, y2, x, color);
y1++;
y2--;
}
break;
case 'c':
break;
case 'd';
break;
case 'e':
break;
case 'f';
break;
case 'g':
break;
}
chaine++;
}
}
private int Dessin::chiffre(char c, int x, int y, int taille, uint color)
{
char chaine[9];
if (taille < 9)
return 1;
if (c > '9' || c < '0')
return 1;
// a
// # # #
// # #
// #f #b
// # g #
// # # #
// # #
// #e #c
// # # dp
// # # # #
// d
switch (c)
{
case '0': strcpy(chaine, "abcdef"); break;
case '1': strcpy(chaine, "bc"); break;
case '2': strcpy(chaine, "abdeg"); break;
case '3': strcpy(chaine, "abcdg"); break;
case '4': strcpy(chaine, "bcfg"); break;
case '5': strcpy(chaine, "acdfg"); break;
case '6': strcpy(chaine, "acdef"); break;
case '7': strcpy(chaine, "abc"); break;
case '8': strcpy(chaine, "abcdefg"); break;
case '9': strcpy(chaine, "abcdfg"); break;
}
segments(chaine, x, y, taille, align, color);
}
int Dessin::nombre(char *nombre, int x, int y, int taille, int align, uint color)
{
char c;
int i = 0;
if (taille < 9)
return 1;
while ((c = *nombre) != '\0')
{
chiffre(c, x, y, taille);
#TODO : décaler x !!!!
nombre++;
}
}
int Dessin::nombre(int nombre, int x, int y, int taille, int align, uint color)
{
if (taille < 9)
return 1;
char str[11] = "";
sprintf(str, "%d", nombre);
nombre(str, x, y, taille, align, color);
}