| 1 |
%% eurion.sty -- EURion constellation overlay for LaTeX documents |
| 2 |
%% v0.1.0, 2026-04-26 |
| 3 |
%% Copyright (C) 2026 originalsouth <[email protected]> |
| 4 |
%% |
| 5 |
%% License: WTFPL (see LICENSE). The author does not endorse this |
| 6 |
%% license; it was picked because CTAN distribution requires *some* |
| 7 |
%% license to be selected. |
| 8 |
%% |
| 9 |
%% Draws the five-circle "EURion" anti-photocopy pattern across document |
| 10 |
%% pages. Visual reproduction only -- not a real anti-counterfeiting feature. |
| 11 |
%% |
| 12 |
%% Usage: |
| 13 |
%% \usepackage{eurion} % default scatter, gold |
| 14 |
%% \usepackage[scatter, color=yellow]{eurion} |
| 15 |
%% \usepackage[corner=top-right, color=green]{eurion} |
| 16 |
%% \usepackage[manual]{eurion} % then call \eurion[..]{x,y} |
| 17 |
%% |
| 18 |
%% References used to derive the geometry: |
| 19 |
%% - https://gist.github.com/petrkutalek/93b7eebf22f4dbcfab8cd80a91fd27a8 |
| 20 |
%% - https://en.wikipedia.org/wiki/EURion_constellation |
| 21 |
%% - https://everything2.com/user/spiregrain/writeups/EURion+Constellation |
| 22 |
|
| 23 |
\NeedsTeXFormat{LaTeX2e} |
| 24 |
\ProvidesPackage{eurion}[2026/04/26 v0.1.0 EURion constellation overlay] |
| 25 |
|
| 26 |
\RequirePackage{xkeyval} |
| 27 |
\RequirePackage{tikz} |
| 28 |
\RequirePackage{eso-pic} |
| 29 |
|
| 30 |
%% --- color presets ------------------------------------------------------- |
| 31 |
\definecolor{eurion@gold}{cmyk}{0,0.1933,0.5714,0.0667}% kutalek default |
| 32 |
\definecolor{eurion@yellow}{rgb}{1,0.85,0} |
| 33 |
\definecolor{eurion@green}{rgb}{0.45,0.75,0.3} |
| 34 |
\definecolor{eurion@orange}{rgb}{1,0.6,0.1} |
| 35 |
|
| 36 |
%% --- option storage with defaults --------------------------------------- |
| 37 |
\def\eurion@mode{scatter} |
| 38 |
\def\eurion@color{eurion@gold} |
| 39 |
\def\eurion@size{1} |
| 40 |
\def\eurion@density{20} |
| 41 |
\def\eurion@rotate{random} |
| 42 |
\def\eurion@corner{north east} |
| 43 |
\def\eurion@seed{1} |
| 44 |
|
| 45 |
\def\eurion@rot@random{random} |
| 46 |
\def\eurion@rot@none{none} |
| 47 |
|
| 48 |
%% --- corner-name parser (top-right -> north east, etc.) ---------------- |
| 49 |
\def\eurion@parsecorner#1{% |
| 50 |
\def\eurion@tmp{#1}% |
| 51 |
\def\eurion@TL{top-left}\def\eurion@TR{top-right}% |
| 52 |
\def\eurion@BL{bottom-left}\def\eurion@BR{bottom-right}% |
| 53 |
\ifx\eurion@tmp\eurion@TL \def\eurion@corner{north west}\else |
| 54 |
\ifx\eurion@tmp\eurion@TR \def\eurion@corner{north east}\else |
| 55 |
\ifx\eurion@tmp\eurion@BL \def\eurion@corner{south west}\else |
| 56 |
\ifx\eurion@tmp\eurion@BR \def\eurion@corner{south east}\else |
| 57 |
\def\eurion@corner{north east}% |
| 58 |
\fi\fi\fi\fi} |
| 59 |
|
| 60 |
%% --- color-name resolver (preset vs user xcolor expr) ------------------ |
| 61 |
\def\eurion@parsecolor#1{% |
| 62 |
\@ifundefined{\string\color @eurion@#1}% |
| 63 |
{\def\eurion@color{#1}}% user color or xcolor expression |
| 64 |
{\def\eurion@color{eurion@#1}}}% built-in preset |
| 65 |
|
| 66 |
%% --- runtime keyval keys (used by \eurion[...] at point of call) ------- |
| 67 |
\define@key{eurion}{color}{\eurion@parsecolor{#1}} |
| 68 |
\define@key{eurion}{size}{\def\eurion@size{#1}} |
| 69 |
\define@key{eurion}{density}{\def\eurion@density{#1}} |
| 70 |
\define@key{eurion}{rotate}{\def\eurion@rotate{#1}} |
| 71 |
\define@key{eurion}{seed}{\def\eurion@seed{#1}} |
| 72 |
\define@key{eurion}{corner}{\eurion@parsecorner{#1}} |
| 73 |
\define@key{eurion}{mode}{\def\eurion@mode{#1}} |
| 74 |
|
| 75 |
%% --- package options (load-time) --------------------------------------- |
| 76 |
\DeclareOptionX{scatter}[]{\def\eurion@mode{scatter}} |
| 77 |
\DeclareOptionX{manual}[]{\def\eurion@mode{manual}} |
| 78 |
\DeclareOptionX{corner}[__flag__]{% |
| 79 |
\def\eurion@tmpa{#1}\def\eurion@tmpb{__flag__}% |
| 80 |
\ifx\eurion@tmpa\eurion@tmpb |
| 81 |
\def\eurion@mode{corner}% |
| 82 |
\else |
| 83 |
\eurion@parsecorner{#1}% |
| 84 |
\def\eurion@mode{corner}% |
| 85 |
\fi} |
| 86 |
\DeclareOptionX{mode}{\def\eurion@mode{#1}} |
| 87 |
\DeclareOptionX{color}{\eurion@parsecolor{#1}} |
| 88 |
\DeclareOptionX{size}{\def\eurion@size{#1}} |
| 89 |
\DeclareOptionX{density}{\def\eurion@density{#1}} |
| 90 |
\DeclareOptionX{rotate}{\def\eurion@rotate{#1}} |
| 91 |
\DeclareOptionX{seed}{\def\eurion@seed{#1}} |
| 92 |
\DeclareOptionX*{\PackageWarning{eurion}{Unknown option `\CurrentOption' ignored}} |
| 93 |
\ProcessOptionsX |
| 94 |
|
| 95 |
%% --- the constellation itself ------------------------------------------ |
| 96 |
%% Polar centers (from petrkutalek): (0,0), (2.5,0deg), (2.6,78deg), |
| 97 |
%% (4.0,188deg), (3.8,258deg), all in mm. Stroked 0.4mm rings. |
| 98 |
%% Public lore: 1mm circle diameter, ~4mm max spread, squared distances |
| 99 |
%% reportedly form integer ratios (Andrew Steer); the exact spec is secret. |
| 100 |
\newcommand{\eurion@constellation}{% |
| 101 |
\draw (0mm,0mm) circle (0.4mm); |
| 102 |
\draw (2.5mm,0mm) circle (0.4mm); |
| 103 |
\begin{scope}[rotate=78] |
| 104 |
\draw (2.6mm,0mm) circle (0.4mm); |
| 105 |
\begin{scope}[rotate=110] |
| 106 |
\draw (4.0mm,0mm) circle (0.4mm); |
| 107 |
\begin{scope}[rotate=70] |
| 108 |
\draw (3.8mm,0mm) circle (0.4mm); |
| 109 |
\end{scope} |
| 110 |
\end{scope} |
| 111 |
\end{scope}% |
| 112 |
} |
| 113 |
|
| 114 |
%% --- rotation resolver ------------------------------------------------- |
| 115 |
%% Sets \eurion@theta from \eurion@rotate ("random" / "none" / number). |
| 116 |
\newcommand{\eurion@computetheta}{% |
| 117 |
\ifx\eurion@rotate\eurion@rot@random |
| 118 |
\pgfmathsetmacro{\eurion@theta}{rnd*360}% |
| 119 |
\else |
| 120 |
\ifx\eurion@rotate\eurion@rot@none |
| 121 |
\def\eurion@theta{0}% |
| 122 |
\else |
| 123 |
\edef\eurion@theta{\eurion@rotate}% |
| 124 |
\fi |
| 125 |
\fi |
| 126 |
} |
| 127 |
|
| 128 |
%% --- scatter background ----------------------------------------------- |
| 129 |
\newcommand{\eurion@scatterpage}{% |
| 130 |
\begin{tikzpicture}[remember picture, overlay] |
| 131 |
\pgfmathsetseed{\numexpr\eurion@seed + \value{page}\relax}% |
| 132 |
\pgfmathsetmacro{\eurion@pw}{\paperwidth}% |
| 133 |
\pgfmathsetmacro{\eurion@ph}{\paperheight}% |
| 134 |
\foreach \eurion@i in {1,...,\eurion@density}{% |
| 135 |
\pgfmathsetmacro{\eurion@x}{rnd*\eurion@pw}% |
| 136 |
\pgfmathsetmacro{\eurion@y}{rnd*\eurion@ph}% |
| 137 |
\eurion@computetheta |
| 138 |
\begin{scope}[shift={(\eurion@x pt, \eurion@y pt)}, |
| 139 |
rotate=\eurion@theta, |
| 140 |
scale=\eurion@size, |
| 141 |
draw=\eurion@color, |
| 142 |
line width=0.3mm] |
| 143 |
\eurion@constellation |
| 144 |
\end{scope}% |
| 145 |
}% |
| 146 |
\end{tikzpicture}% |
| 147 |
} |
| 148 |
|
| 149 |
%% --- corner background ------------------------------------------------ |
| 150 |
\newcommand{\eurion@cornerpage}{% |
| 151 |
\begin{tikzpicture}[remember picture, overlay] |
| 152 |
\begin{scope}[shift={([shift={(\eurion@dx,\eurion@dy)}]current page.\eurion@corner)}, |
| 153 |
scale=\eurion@size, |
| 154 |
draw=\eurion@color, |
| 155 |
line width=0.3mm] |
| 156 |
\eurion@constellation |
| 157 |
\end{scope} |
| 158 |
\end{tikzpicture}% |
| 159 |
} |
| 160 |
|
| 161 |
%% --- install background hook based on selected mode -------------------- |
| 162 |
\AtBeginDocument{% |
| 163 |
\def\eurion@modes{scatter}% |
| 164 |
\def\eurion@modec{corner}% |
| 165 |
\def\eurion@modem{manual}% |
| 166 |
\ifx\eurion@mode\eurion@modes |
| 167 |
\AddToShipoutPictureBG{\eurion@scatterpage}% |
| 168 |
\else |
| 169 |
\ifx\eurion@mode\eurion@modec |
| 170 |
\def\eurion@nw{north west}\def\eurion@ne{north east}% |
| 171 |
\def\eurion@sw{south west}\def\eurion@se{south east}% |
| 172 |
\ifx\eurion@corner\eurion@nw \def\eurion@dx{ 15mm}\def\eurion@dy{-15mm}\else |
| 173 |
\ifx\eurion@corner\eurion@ne \def\eurion@dx{-15mm}\def\eurion@dy{-15mm}\else |
| 174 |
\ifx\eurion@corner\eurion@sw \def\eurion@dx{ 15mm}\def\eurion@dy{ 15mm}\else |
| 175 |
\ifx\eurion@corner\eurion@se \def\eurion@dx{-15mm}\def\eurion@dy{ 15mm}\else |
| 176 |
\def\eurion@dx{-15mm}\def\eurion@dy{-15mm}% |
| 177 |
\fi\fi\fi\fi |
| 178 |
\AddToShipoutPictureBG{\eurion@cornerpage}% |
| 179 |
\fi |
| 180 |
\fi |
| 181 |
} |
| 182 |
|
| 183 |
%% --- public macro: \eurion[opts]{coord-or-x,y} ------------------------- |
| 184 |
%% The user passes a TikZ coordinate (e.g. "current page.center" or |
| 185 |
%% "5cm,3cm"); the macro draws one constellation there in an overlay. |
| 186 |
\newcommand{\eurion}[2][]{% |
| 187 |
\begingroup |
| 188 |
\setkeys{eurion}{#1}% |
| 189 |
\eurion@computetheta |
| 190 |
\begin{tikzpicture}[remember picture, overlay] |
| 191 |
\begin{scope}[shift={(#2)}, |
| 192 |
rotate=\eurion@theta, |
| 193 |
scale=\eurion@size, |
| 194 |
draw=\eurion@color, |
| 195 |
line width=0.3mm] |
| 196 |
\eurion@constellation |
| 197 |
\end{scope} |
| 198 |
\end{tikzpicture}% |
| 199 |
\endgroup |
| 200 |
} |
| 201 |
|
| 202 |
\endinput |