Last active
February 14, 2018 16:56
Revisions
-
NeoTheFox revised this gist
Feb 13, 2018 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,6 @@ function printhelp echo "Example:" echo " glasscalc.sh 800x600" } if [ -z $1 ] then -
NeoTheFox revised this gist
Feb 13, 2018 . 1 changed file with 11 additions and 22 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,6 @@ #This is a simple calc for looking glass #Licenced by WTFPL #by NeoTheFox 2018 #USAGE: #glasscalc.sh WidthxHeight @@ -27,24 +26,14 @@ 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" -
NeoTheFox created this gist
Feb 13, 2018 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,50 @@ #!/bin/bash #This is a simple calc for looking glass #Licenced by WTFPL #by NeoTheFox 2018 #Some functions are from http://www.pixelbeat.org/ #USAGE: #glasscalc.sh WidthxHeight function printhelp { echo "Usage:" echo " glasscalc.sh widthxheight" echo "Example:" echo " glasscalc.sh 800x600" } power2() { echo "x=l($1)/l(2); scale=0; 2^((x+0.5)/1)" | bc -l; } 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) echo " define int(x) { auto old_scale /* variables global by default */ old_scale=scale /* scale is global */ scale=0; ret=x/1 scale=old_scale return ret } define ceil(x) { auto intx intx=int(x) if (intx<x) intx+=1 return intx } m=$WIDTH*$HEIGHT*4*2 m=m/1024/1024 m=2^ceil(l(m)/l(2)) m" | bc -l