noise / torn paper experiments

This commit is contained in:
nobody 2024-12-15 00:20:47 +01:00
parent 6475efca6c
commit 53a83d838b
3 changed files with 129 additions and 18 deletions

2
.gitignore vendored
View file

@ -1,9 +1,11 @@
*.aux *.aux
*.auxlock
*.hd *.hd
*.log *.log
*.out *.out
*.toc *.toc
*.pdf *.pdf
*.pyg
_minted-* _minted-*
cccbform-examples cccbform-examples
*.fdb_latexmk *.fdb_latexmk

View file

@ -12,7 +12,7 @@ clean:
distclean: distclean:
latexmk -C latexmk -C
rm -fr _minted-doku cccbform-examples doku.hd rm -fr _minted-doku cccbform-examples doku.hd doku.auxlock doku.pyg
doku.pdf: doku.tex cccbform.cls logo.pdf doku.pdf: doku.tex cccbform.cls logo.pdf
latexmk -g -pdflua -lualatex="lualatex --shell-escape %O %S" $< latexmk -g -pdflua -lualatex="lualatex --shell-escape %O %S" $<

143
doku.tex
View file

@ -1,10 +1,12 @@
%% NB: Dieses Dokument baut so 3-10 Minuten je nach Dateisystem-Performance… %% NB: Dieses Dokument baut beim ersten Mal so 3-10 Minuten je nach
%% (Sehr viele Beispiele die jeweils komplette eigenständige Dokumente sind.) %% Dateisystem-Performance… (Sehr viele Beispiele die jeweils komplette
%% eigenständige Dokumente sind.) Danach sollte es gehen.
\documentclass[ngerman,10pt]{scrreprt} \documentclass[ngerman,10pt]{scrreprt}
\setcounter{secnumdepth}{\subsubsectionnumdepth} \setcounter{secnumdepth}{\subsubsectionnumdepth}
\setcounter{tocdepth}{\subsubsectiontocdepth} \setcounter{tocdepth}{\subsubsectiontocdepth}
\KOMAoptions{BCOR=1cm,DIV=10,open=any} \KOMAoptions{BCOR=1cm,DIV=10,open=any}
\usepackage{calc,tikz,minted,fontspec,luacode,babel,csquotes,hyperref} \usepackage{calc,tikz,minted,unicode-math,fontspec,luacode,babel,csquotes,hyperref}
\usetikzlibrary{calc}
\hypersetup{colorlinks,urlcolor={magenta!75!black},linkcolor={green!50!black}} \hypersetup{colorlinks,urlcolor={magenta!75!black},linkcolor={green!50!black}}
\linespread{1.05} \linespread{1.05}
% font definition (same as cccbform.cls) % font definition (same as cccbform.cls)
@ -24,6 +26,19 @@
BoldItalicFeatures={RawFeature={+axis={MONO=0.0,CASL=0.2,slnt=-15,CRSV=1,wght=700}}}, BoldItalicFeatures={RawFeature={+axis={MONO=0.0,CASL=0.2,slnt=-15,CRSV=1,wght=700}}},
ItalicFeatures={RawFeature={+axis={MONO=0.0,CASL=0.2,slnt=-15,CRSV=1,wght=400}}} ItalicFeatures={RawFeature={+axis={MONO=0.0,CASL=0.2,slnt=-15,CRSV=1,wght=400}}}
]{Recursive} ]{Recursive}
\setmathfont[
Renderer=HarfBuzz,
ItalicFont=Recursive,
BoldFont=Recursive,
BoldItalicFont=Recursive,
UprightFeatures={
RawFeature={+ss01,+ss02,+ss08},
RawFeature={+axis={MONO=0.0,CASL=0.2,slnt=0,CRSV=0,wght=400}}
},
BoldFeatures={RawFeature={+axis={MONO=0.0,CASL=0.2,slnt=0,CRSV=0,wght=700}}},
BoldItalicFeatures={RawFeature={+axis={MONO=0.0,CASL=0.2,slnt=-15,CRSV=1,wght=700}}},
ItalicFeatures={RawFeature={+axis={MONO=0.0,CASL=0.2,slnt=-15,CRSV=1,wght=400}}}
]{Recursive}
\setmonofont[ \setmonofont[
Renderer=HarfBuzz, Renderer=HarfBuzz,
ItalicFont=Recursive, ItalicFont=Recursive,
@ -53,7 +68,7 @@
\usepackage{microtype} \usepackage{microtype}
% set up example build directory % set up example build directory
\directlua{ os.execute "mkdir -p cccbform-examples" } \directlua{ os.execute "mkdir -p ./cccbform-examples/" }
\directlua{ os.execute "cp cccbform.cls logo.pdf cccbform-examples/" } \directlua{ os.execute "cp cccbform.cls logo.pdf cccbform-examples/" }
% stuff to add before/after examples to form a full document % stuff to add before/after examples to form a full document
\begin{luacode*} \begin{luacode*}
@ -68,6 +83,84 @@ FOOTER = [[
]] ]]
\end{luacode*} \end{luacode*}
\begin{luacode*}
-- PARAM: number of layers, resulting in 2^LAYERS points
local LAYERS = 8
-- PARAM: per layer, multiply component by (1/(2^K))^weight
-- (1 = default, larger = smoother, smaller = rougher)
local weight = 1.00
N = 1 << LAYERS
function smoothstep( a, b, t )
local t = t*t*(3-2*t)
return a + (b-a)*t
end
function REFRESH_POINTS()
POINTS = { }
for i = 1, N do
POINTS[i] = (2*math.random()-1)/N^weight -- + 0.125*math.sin( 2*math.pi*i/N )
end
for l = 2, LAYERS-1 do
local K = 1<<l
local len = N//K
local RNG = { }
for i = 1, K do RNG[i] = 2*math.random()-1 end
RNG[0] = RNG[K]
for seg = 1, K do
local lseg, rseg = (seg-1)*len, seg*len
local lRNG, rRNG = RNG[seg-1], RNG[seg]
for j = lseg+1, rseg do
local t = (j-lseg)/len
POINTS[j] = POINTS[j] + smoothstep(lRNG, rRNG, t)/K^weight
end
end
end
POINTS[0] = POINTS[N]
end
function getPoints()
REFRESH_POINTS()
local buf = { }
for i = 0, #POINTS do buf[i+1] = ("%.4fcm"):format( POINTS[i]/4 ) end
buf = table.concat( buf, ", " )
tex.print( [[\def\perturbationPoints{ ]]..buf.." }" )
tex.print( [[\def\numPoints{ ]]..(#POINTS+1).." }" )
end
function plotPoints( x1, x2, y1, y2, smooth_top )
x1, x2 = tonumber( (x1:sub(1,-3)) ), tonumber( (x2:sub(1,-3)) )
y1, y2 = tonumber( (y1:sub(1,-3)) ), tonumber( (y2:sub(1,-3)) )
local dx = (x2-x1)/(N)
local buf = { }
local SCALE = 10
local P0 = 0
if smooth_top then
SCALE = SCALE * 2.5
buf[#buf+1] = ("(%.4fpt, %.4fpt)"):format( x1, y1 )
buf[#buf+1] = ("(%.4fpt, %.4fpt)"):format( x2, y1 )
else
REFRESH_POINTS()
for i = 0, #POINTS do
buf[#buf+1] = ("(%.4fpt, %.4fpt)"):format( x1 + i*dx, y1 + POINTS[i]*SCALE )
end
P0 = POINTS[0]
end
REFRESH_POINTS()
for i = #POINTS, 0, -1 do
buf[#buf+1] = ("(%.4fpt, %.4fpt)"):format( x1 + i*dx, y2 + POINTS[N-i]*SCALE )
end
buf[#buf+1] = ("(%.4fpt, %.4fpt)"):format( x1, y1 + P0*SCALE )
buf = table.concat( buf, " -- " )
tex.print( buf )
end
\end{luacode*}
\begin{luacode*} \begin{luacode*}
function makeVerb( envname ) function makeVerb( envname )
local buf local buf
@ -114,11 +207,19 @@ FOOTER = [[
\directlua{ ShortExampleStart, ShortExampleEnd = makeVerb "ShortExample" } \directlua{ ShortExampleStart, ShortExampleEnd = makeVerb "ShortExample" }
\NewDocumentEnvironment{ShortExample}{O{} m m}{ \makeatletter
\newcommand{\gettikzxy}[3]{%
\tikz@scan@one@point\pgfutil@firstofone#1\relax
\edef#2{\the\pgf@x}%
\edef#3{\the\pgf@y}%
}
\makeatother
\NewDocumentEnvironment{ShortExample}{s O{} m m}{
\addvspace{1em} \addvspace{1em}
\directlua{ShortExampleStart()} \directlua{ShortExampleStart()}
}{ }{
\directlua{ EndExample( ShortExampleEnd, "#1", "#2" ) } \directlua{ EndExample( ShortExampleEnd, "#2", "#3" ) }
\par\noindent \par\noindent
\null\hspace*{-2cm} \null\hspace*{-2cm}
\rlap{ \rlap{
@ -128,18 +229,25 @@ FOOTER = [[
\node[anchor=north east] (code) at (-0.5ex,0) { \node[anchor=north east] (code) at (-0.5ex,0) {
\begin{minipage}[t]{0.5\textwidth - 3ex} \begin{minipage}[t]{0.5\textwidth - 3ex}
\vspace{-2ex} \vspace{-2ex}
\inputminted[firstline=\ls,lastline=\lc]{tex}{cccbform-examples/#2.tex} \inputminted[firstline=\ls,lastline=\lc]{tex}{cccbform-examples/#3.tex}
\end{minipage} \end{minipage}
}; };
\node[anchor=north west, draw=black!50] (output) at (0.5ex,0) { \node[anchor=north west] (output) at (0.5ex,0) {
\begin{minipage}[t]{0.5\textwidth - 2ex} \begin{minipage}[t]{0.5\textwidth - 2ex}
\includegraphics[width=\linewidth]{cccbform-examples/#2.pdf} \includegraphics[width=\linewidth]{cccbform-examples/#3.pdf}
\end{minipage} \end{minipage}
}; };
\gettikzxy{(output.north west)}{\xl}{\yt}
\gettikzxy{(output.south east)}{\xr}{\yb}
\IfBooleanTF{#1}{
\draw \directlua{ plotPoints( "\xl", "\xr", "\yt", "\yb", true ) };
}{
\draw \directlua{ plotPoints( "\xl", "\xr", "\yt", "\yb", false ) };
}
\end{tikzpicture} \end{tikzpicture}
\par \par
\vspace{-2ex} \vspace{-2ex}
{\null\hfill\bfseries #3 \hfill\null} {\null\hfill\bfseries #4 \hfill\null}
\end{minipage} \end{minipage}
} }
\par \par
@ -289,13 +397,14 @@ einzelnes Dokument gebaut werden, so sollte \texttt{make foo.pdf} zu einem
\emph{Wirklich} alle Dokumente zu bauen dürfte beim ersten Mal mehrere Minuten \emph{Wirklich} alle Dokumente zu bauen dürfte beim ersten Mal mehrere Minuten
dauern. (Diese Dokumentation hier enthält viele Beispiele, die tatsächlich dauern. (Diese Dokumentation hier enthält viele Beispiele, die tatsächlich
eigenständige Dokumente sind. Der Overhead für alle je $2\times$ eigenständige Dokumente sind. Der Overhead für alle je 2× \texttt{lualatex} zu
\texttt{lualatex} zu starten, mehrere temporäre Dateien zu schreiben, etc. etc. starten, mehrere temporäre Dateien zu schreiben, etc. etc. kann gut 3--10
kann gut 3--10 Minuten fressen.) Minuten fressen.)
\chapter{Befehle} \chapter{Befehle}
Bereitgestellte Befehle fallen grob in 4 Kategorien -- Titel, Inhalt, Struktur, Hervorhebung. Zusätzlich hat die Klasse selbst ein paar Optionen. Bereitgestellte Befehle fallen grob in 4 Kategorien -- Titel, Inhalt, Struktur,
Hervorhebung. Zusätzlich hat die Klasse selbst ein paar Optionen.
\section{Klassen-Optionen} \section{Klassen-Optionen}
@ -335,14 +444,14 @@ also nicht beim verarbeiten des restlichen Inhalts.)
\subsection{\texcode{\LogoTitle{Titel}}} \subsection{\texcode{\LogoTitle{Titel}}}
\begin{ShortExample}[4.953cm]{logotitle}{Die einfache Variante -- Titel links, Logo rechts.} \begin{ShortExample}*[4.953cm]{logotitle}{Die einfache Variante -- Titel links, Logo rechts.}
\LogoTitle{Beispieltitel} \LogoTitle{Beispieltitel}
\Text{(...und hier geht's weiter.)} \Text{(...und hier geht's weiter.)}
\end{ShortExample} \end{ShortExample}
\subsection{\texcode{\AddressTitle{Titel}}} \subsection{\texcode{\AddressTitle{Titel}}}
\begin{ShortExample}[8.865cm]{addresstitle}{Titel und Adresse} \begin{ShortExample}*[8.865cm]{addresstitle}{Titel und Adresse}
\AddressTitle{Beispieltitel} \AddressTitle{Beispieltitel}
\Text{(...und hier geht's weiter.)} \Text{(...und hier geht's weiter.)}
\end{ShortExample} \end{ShortExample}
@ -353,7 +462,7 @@ also nicht beim verarbeiten des restlichen Inhalts.)
Es gibt auch die Variante mit \texttt{*}, welche zusätzlich das Logo einbettet. Es gibt auch die Variante mit \texttt{*}, welche zusätzlich das Logo einbettet.
\nopagebreak[2] \nopagebreak[2]
\begin{ShortExample}[8.865cm]{addresstitlestar}{Titel, Adresse und Logo} \begin{ShortExample}*[8.865cm]{addresstitlestar}{Titel, Adresse und Logo}
\AddressTitle*{Beispieltitel} \AddressTitle*{Beispieltitel}
\Text{(...und hier geht's weiter.)} \Text{(...und hier geht's weiter.)}
\end{ShortExample} \end{ShortExample}