Skip to content

Instantly share code, notes, and snippets.

@petrkutalek
Created July 5, 2020 21:43
Show Gist options
  • Save petrkutalek/93b7eebf22f4dbcfab8cd80a91fd27a8 to your computer and use it in GitHub Desktop.
Save petrkutalek/93b7eebf22f4dbcfab8cd80a91fd27a8 to your computer and use it in GitHub Desktop.
Adding an EURion constellation to A4 PDF
#!/bin/bash
if [[ "$#" -ne 1 ]]; then
echo "Usage: $0 filename" >&2
exit 1
fi
if [[ ! -e "$1" ]]; then
echo "$1 not found" >&2
exit 1
fi
RAND=$(awk 'BEGIN {srand(); printf("%u", 1048576*rand());}')
gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pdfwrite \
-dPDFSETTINGS=/prepress -dEmbedAllFonts=true -dSubsetFonts=true \
-dCompatibilityLevel=1.6 -dCompressPages=true -sOutputFile="${1%.*}_e.pdf" -_ "${1}" <<EOT
%!PS
% https://en.wikipedia.org/wiki/EURion_constellation
% http://www.bbc.com/future/story/20150624-the-secret-codes-of-british-banknotes
% this script presumes that your input has DIN/A4 paper dimensions (i.e. 595/842 points)
${RAND} srand
<< /BeginPage {
pop
gsave
matrix defaultmatrix setmatrix
1 1 20 {
pop
gsave
rand 595 mod rand 842 mod translate
rand 360 mod rotate
2.8346 2.8346 scale
0 0.1933 0.5714 0.0667 setcmykcolor
.3 setlinewidth
0 0 .4 0 360 arc stroke
2.5 0 .4 0 360 arc stroke
78 rotate 2.6 0 .4 0 360 arc stroke
110 rotate 4.0 0 .4 0 360 arc stroke
70 rotate 3.8 0 .4 0 360 arc stroke
grestore
} for
grestore
} bind
>> setpagedevice
EOT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment