aboutsummaryrefslogtreecommitdiff
path: root/src/character.c
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2020-05-12 00:25:42 +0200
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2020-05-12 00:25:42 +0200
commit28baa52191099820ed2d1d5a33a0d29e50d82033 (patch)
tree5dd899ef4bc2d557e906e2f33c0a9808cf110760 /src/character.c
parent44cecf8d0b792c69cdfc398761d2ad27b05a122e (diff)
downloadAsciiMap-28baa52191099820ed2d1d5a33a0d29e50d82033.tar.gz
Added custom character palette
Diffstat (limited to 'src/character.c')
-rw-r--r--src/character.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/character.c b/src/character.c
index 658f0be..8a42370 100644
--- a/src/character.c
+++ b/src/character.c
@@ -1,10 +1,12 @@
#include "character.h"
-const char character_luminance_map [] = {' ', ' ', '.', ',', '`', '-', '~', '"', '*', ':', ';', '<', '!', '/', '?', '%', '&', '=', '$', '#'};
-//const char map[] = {' ', '`', '.', ',', ':', ';', '\"', '+', '#', '@'};
+const char *default_character_map=" .,-~\"*:;<!/?%&=$#";
+//const char *default_character_map=" `.,:;/+#@";
-char calc_char(uint8_t _c , uint8_t _min, uint8_t _max)
+char calc_char(uint8_t _c , uint8_t _min, uint8_t _max, char *_custom_map)
{
- float c = (float)(_c) / (_max - _min);
- return character_luminance_map [(int)((sizeof(character_luminance_map)-1) * (c))];
+ const char *map = _custom_map == 0 ? default_character_map : _custom_map;
+
+ float c = (float)(_c) / (_max - _min);
+ return map [(int)( strlen( map ) * (c))];
}