Skip to content

Instantly share code, notes, and snippets.

@NeoTheFox
Last active February 14, 2018 16:56
Show Gist options
  • Save NeoTheFox/c867fbfcaea74749e96f3006b12675fb to your computer and use it in GitHub Desktop.
Save NeoTheFox/c867fbfcaea74749e96f3006b12675fb to your computer and use it in GitHub Desktop.
#!/bin/bash
#This is a simple calc for looking glass
#Licenced by WTFPL
#by NeoTheFox 2018
#USAGE:
#glasscalc.sh WidthxHeight
function printhelp
{
echo "Usage:"
echo " glasscalc.sh widthxheight"
echo "Example:"
echo " glasscalc.sh 800x600"
}
if [ -z $1 ]
then
echo "No arguments provided"
printhelp
exit 0
fi
WIDTH=$(echo $1 | cut -d "x" -f1)
HEIGHT=$(echo $1 | cut -d "x" -f2)
((M=$WIDTH*HEIGHT*4*2))
((M=M/1024/1024))
((M+=1))
((M|=M>>1))
((M|=M>>2))
((M|=M>>4))
((M|=M>>8))
((M|=M>>16))
((M+=1))
echo "$M"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment