I try to find a more compact way for creating a custom 'pixel' font (because I need to process a whole alphabet this way).
When i select a character (
c='a') I want to loop the corresponding array with the
for loop. Now I have a seperate
rect for each character, because I don't know how to use the value of
c as the name of the array (so I can say
if value of c[i][j]{}).
Is this possible?
the 'problem' part:
- if (c=='a') {
- if (a[i][j]==1) {
- rect(x+j*40, i*40, 20, 20);
- }
- }
full code:
c = 'a';- int[][] a = {
- {0,0,0,0,0},
- {0,0,0,0,0},
- {0,1,1,1,0},
- {0,0,0,0,1},
- {0,1,1,1,1},
- {1,0,0,0,1},
- {0,1,1,1,1},
- {0,0,0,0,0},
- {0,0,0,0,0}
- };
- int[][] b = {
- {1,0,0,0,0},
- {1,0,0,0,0},
- {1,1,1,1,0},
- {1,0,0,0,1},
- {1,0,0,0,1},
- {1,0,0,0,1},
- {1,1,1,1,0},
- {0,0,0,0,0},
- {0,0,0,0,0}
- };
- for (int i = 0; i < 9; i++) {
- for (int j = 0; j < 5; j++) {
- if (c=='a') {
- if (a[i][j]==1) {
- rect(x+j*40, i*40, 20, 20);
- }
- }
- if (c=='b') {
- if (b[i][j]==1) {
- rect(x+j*40, i*40, 20, 20);
- }
- }
- }
- }
1