summaryrefslogtreecommitdiff
path: root/bbrll
diff options
context:
space:
mode:
Diffstat (limited to 'bbrll')
-rwxr-xr-xbbrll59
1 files changed, 43 insertions, 16 deletions
diff --git a/bbrll b/bbrll
index e94c1e8..5f3324f 100755
--- a/bbrll
+++ b/bbrll
@@ -53,31 +53,58 @@ function print_sin_braille() {
#6 7
#reverse
#(1,3)(0,3)(1,2)(1,1)(1,0)(0,2)(0,1)(0,0)
-
- b0=${rawbuff[((0+4*$2))]:((0+2*$1)):1}
- b1=${rawbuff[((1+4*$2))]:((0+2*$1)):1}
- b2=${rawbuff[((2+4*$2))]:((0+2*$1)):1}
- b3=${rawbuff[((0+4*$2))]:((1+2*$1)):1}
- b4=${rawbuff[((1+4*$2))]:((1+2*$1)):1}
- b5=${rawbuff[((2+4*$2))]:((1+2*$1)):1}
- b6=${rawbuff[((3+4*$2))]:((0+2*$1)):1}
- b7=${rawbuff[((3+4*$2))]:((1+2*$1)):1}
-
+ num=0
+ if [ "${rawbuff[((0+4*$2))]:((0+2*$1)):1}" == "1" ]; then
+ num=$(($num + 1))
+ fi
+ if [ "${rawbuff[((1+4*$2))]:((0+2*$1)):1}" == "1" ];then
+ num=$(($num + 2))
+ fi
+ if [ "${rawbuff[((2+4*$2))]:((0+2*$1)):1}" == "1" ];then
+ num=$(($num + 4))
+ fi
+ if [ "${rawbuff[((0+4*$2))]:((1+2*$1)):1}" == "1" ];then
+ num=$(($num + 8))
+ fi
+ if [ "${rawbuff[((1+4*$2))]:((1+2*$1)):1}" == "1" ];then
+ num=$(($num + 16))
+ fi
+ if [ "${rawbuff[((2+4*$2))]:((1+2*$1)):1}" == "1" ];then
+ num=$(($num + 32))
+ fi
+ if [ "${rawbuff[((3+4*$2))]:((0+2*$1)):1}" == "1" ];then
+ num=$(($num + 256))
+ fi
+ if [ "${rawbuff[((3+4*$2))]:((1+2*$1)):1}" == "1" ];then
+ num=$(($num + 512))
+ fi
#ors it with the utf-8 hex value of the empty braille character
#the two spaces assume aht the encoding is utf-8, convoluted bitwise OR
#and coversion between character and number stuff
- echo "obase=16;$(( 2#$b7${b6}00$b5$b4$b3$b2$b1$b0 | 0xE2A080 ))"|bc | xxd --reverse -ps
+ #echo "obase=16;$(( 2#$b7${b6}00$b5$b4$b3$b2$b1$b0 | 0xE2A080 ))"|bc | xxd --reverse -ps
+ echo "obase=16;$(( $num | 0xE2A080 ))"|bc | xxd --reverse -ps
}
function print_braille() {
#I do the lazy thing and just test the first line
w=${#rawbuff[0]}
h=${#rawbuff[@]}
- #conver to braille coords, we do not want to try to print incomplete
- #characters because they will break with our optimization, so rounding
- #down is good
- w=$((w/2))
- h=$((h/4))
+
+ #conver to braille coords, since bash rounds down, account for when
+ #there a braille character that will not be completely filled(it can
+ #handle this fine because of how the sed pattern was constructed in
+ #print_sin_braille)
+ if [ $((w % 2)) -gt 0 ]; then
+ w=$((w/2+1))
+ else
+ w=$((w/2))
+ fi
+ if [ $((h % 4)) -gt 0 ]; then
+ h=$((h/4+1))
+ else
+ h=$((h/4))
+ fi
+
i=0
j=0
while [ $i -lt $h ]; do