allow choice of background
This commit is contained in:
parent
218dd8d7b0
commit
ddc125a57d
17
latexpic
17
latexpic
|
@ -2,9 +2,20 @@
|
|||
|
||||
set -e
|
||||
|
||||
if [ "$#" -ne 2 ]; then
|
||||
echo "Usage: `basename $0` COLOR LATEXSRC"
|
||||
echo
|
||||
echo "with COLOR being either a single color for text on transparent background or 'color1 on color2'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
color=$1
|
||||
input=$2
|
||||
|
||||
fg="${color% on *}"
|
||||
bg="${color##* on }"
|
||||
|
||||
outpdf="/tmp/latexpic.pdf"
|
||||
outpng="/tmp/latexpic.png"
|
||||
|
||||
|
@ -19,12 +30,16 @@ cat <<EOF | pdflatex --output-directory /tmp --jobname latexpic --
|
|||
\usepackage{amssymb}
|
||||
\usepackage{graphicx}
|
||||
|
||||
\color{$1}
|
||||
\color{$fg}
|
||||
|
||||
\begin{document}
|
||||
$input
|
||||
\end{document}
|
||||
EOF
|
||||
|
||||
if [ "$fg" = "$bg" ]; then
|
||||
convert -density 600 "$outpdf" -quality 90 "$outpng"
|
||||
else
|
||||
convert -background "$bg" -flatten -density 600 "$outpdf" -quality 90 "$outpng"
|
||||
fi
|
||||
xdg-open "$outpng"
|
||||
|
|
Loading…
Reference in New Issue
Block a user