aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-10-08 00:57:54 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-10-08 00:57:54 +0200
commitf431d42a5eb582a190abcd4ca1e12f1e9794f688 (patch)
tree94389535e753ed3aaa597fae23ddf3b53db7e2e4
parent4bd0256448a5b0d6f4ecf02f224c48d66d7b4ef4 (diff)
WIP epic title page
-rw-r--r--.gitignore4
-rw-r--r--assets/.gitignore1
-rw-r--r--assets/pictochat-lena.pngbin0 -> 7926 bytes
-rw-r--r--assets/pictochat-logo.pdfbin0 -> 1189 bytes
-rw-r--r--docs/cover/.gitignore1
-rw-r--r--docs/cover/author-frame.pdfbin0 -> 2043 bytes
-rw-r--r--docs/cover/date-frame.pdfbin0 -> 1086 bytes
-rw-r--r--docs/cover/lena.pngbin0 -> 16250 bytes
-rw-r--r--docs/cover/log-bottom.pdfbin0 -> 1781 bytes
-rw-r--r--docs/cover/log-top.pdfbin0 -> 1178 bytes
-rw-r--r--docs/cover/title-frame.pdfbin0 -> 1103 bytes
-rw-r--r--docs/doc.cls285
-rw-r--r--docs/glossary.bib0
-rw-r--r--docs/main.tex35
-rw-r--r--docs/time.txt1
-rw-r--r--docs/titlepage.tex101
-rwxr-xr-xexperiments/conv/png2pc6
-rwxr-xr-xexperiments/crop-melon10
18 files changed, 409 insertions, 35 deletions
diff --git a/.gitignore b/.gitignore
index ef45c97..c5f0ffc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,6 +11,7 @@
*.synctex.gz
*.toc
*.pdf
+*-SAVE-ERROR
# microsoft
*.docx
@@ -19,5 +20,6 @@
roms/
copyright/
-# drawio
+# temp files
.$*.bkp
+*~
diff --git a/assets/.gitignore b/assets/.gitignore
new file mode 100644
index 0000000..13f0a16
--- /dev/null
+++ b/assets/.gitignore
@@ -0,0 +1 @@
+!*.pdf
diff --git a/assets/pictochat-lena.png b/assets/pictochat-lena.png
new file mode 100644
index 0000000..6d653c0
--- /dev/null
+++ b/assets/pictochat-lena.png
Binary files differ
diff --git a/assets/pictochat-logo.pdf b/assets/pictochat-logo.pdf
new file mode 100644
index 0000000..c6576d8
--- /dev/null
+++ b/assets/pictochat-logo.pdf
Binary files differ
diff --git a/docs/cover/.gitignore b/docs/cover/.gitignore
new file mode 100644
index 0000000..13f0a16
--- /dev/null
+++ b/docs/cover/.gitignore
@@ -0,0 +1 @@
+!*.pdf
diff --git a/docs/cover/author-frame.pdf b/docs/cover/author-frame.pdf
new file mode 100644
index 0000000..fc43e48
--- /dev/null
+++ b/docs/cover/author-frame.pdf
Binary files differ
diff --git a/docs/cover/date-frame.pdf b/docs/cover/date-frame.pdf
new file mode 100644
index 0000000..54ff64f
--- /dev/null
+++ b/docs/cover/date-frame.pdf
Binary files differ
diff --git a/docs/cover/lena.png b/docs/cover/lena.png
new file mode 100644
index 0000000..a8ba256
--- /dev/null
+++ b/docs/cover/lena.png
Binary files differ
diff --git a/docs/cover/log-bottom.pdf b/docs/cover/log-bottom.pdf
new file mode 100644
index 0000000..8ec8333
--- /dev/null
+++ b/docs/cover/log-bottom.pdf
Binary files differ
diff --git a/docs/cover/log-top.pdf b/docs/cover/log-top.pdf
new file mode 100644
index 0000000..04e94d2
--- /dev/null
+++ b/docs/cover/log-top.pdf
Binary files differ
diff --git a/docs/cover/title-frame.pdf b/docs/cover/title-frame.pdf
new file mode 100644
index 0000000..8609330
--- /dev/null
+++ b/docs/cover/title-frame.pdf
Binary files differ
diff --git a/docs/doc.cls b/docs/doc.cls
new file mode 100644
index 0000000..1a5ea68
--- /dev/null
+++ b/docs/doc.cls
@@ -0,0 +1,285 @@
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesClass{doc}[2024-10-07 class doc]
+
+% based on article
+\LoadClass{article}
+
+% default word page setup
+\PassOptionsToPackage{margin=1in}{geometry}
+\PassOptionsToPackage{a4paper}{geometry}
+% confusing to acrobat/firefox users
+\PassOptionsToPackage{hidelinks}{hyperref}
+\PassOptionsToPackage{english}{babel}
+\PassOptionsToPackage{noabbrev}{cleveref}
+\PassOptionsToPackage{nosort}{cleveref}
+\PassOptionsToPackage{nameinlink}{cleveref}
+\PassOptionsToPackage{obeyspaces}{url}
+\PassOptionsToPackage{toc=false}{glossaries}
+\PassOptionsToPackage{record}{glossaries-extra}
+\PassOptionsToPackage{backend=biber}{biblatex}
+\PassOptionsToPackage{bibencoding=utf8}{biblatex}
+\PassOptionsToPackage{style=iso-numeric}{biblatex}
+\PassOptionsToPackage{autocite=plain}{biblatex}
+\PassOptionsToPackage{most}{tcolorbox}
+
+% frequently used packages
+\RequirePackage{geometry}
+\RequirePackage{float}
+\RequirePackage{babel}
+\RequirePackage{siunitx}
+\RequirePackage{csquotes}
+\RequirePackage{url}
+\RequirePackage{fancyvrb}
+\RequirePackage{parskip}
+\RequirePackage{fontspec}
+\RequirePackage{tabularx}
+\RequirePackage{booktabs}
+\RequirePackage{needspace}
+\RequirePackage{xr-hyper}
+\RequirePackage{hyperref}
+\RequirePackage{microtype}
+\RequirePackage{xcolor}
+\RequirePackage{etoolbox}
+\RequirePackage{graphicx}
+\RequirePackage{unicode-math}
+\RequirePackage{amsmath}
+\RequirePackage{cleveref}
+\RequirePackage{adjustbox}
+\RequirePackage{xparse}
+\RequirePackage{biblatex}
+\RequirePackage{glossaries}
+\RequirePackage{glossaries-extra}
+\RequirePackage{ifdraft}
+\RequirePackage{enumitem}
+\RequirePackage{subcaption}
+\RequirePackage{multicol}
+\RequirePackage{xstring}
+\RequirePackage{tcolorbox}
+
+% font style
+\setmainfont{TeX Gyre Schola}
+\setmathfont{TeX Gyre Schola Math}
+\setsansfont{Inter}
+\setmonofont[Scale=0.85]{JetBrains Mono}
+
+% fix fonts w/ siunitx
+\sisetup{detect-all = true}
+
+% no indented paragraphs, just skip
+\parindent=0mm
+\bigskipamount=7mm
+\medskipamount=4mm
+
+% number paragraphs by default
+\setcounter{secnumdepth}{4}
+
+% section placement / appearance
+\newlength{\sectionpenalty}
+\newlength{\subsectionpenalty}
+\newlength{\subsubsectionpenalty}
+\setlength{\sectionpenalty}{0.4\textheight}
+\setlength{\subsectionpenalty}{0.1\textheight}
+\setlength{\subsubsectionpenalty}{0pt}
+\def\penaltycheck#1{\ifdimgreater{#1}{0pt}{\needspace{#1}}{}}
+\ifdraft{\def\penaltycheck#1{\relax}}{}
+\makeatletter
+\renewcommand\section{%
+ \@startsection{section}{1}%
+ {0pt}%
+ {1.50em}%
+ {1.50ex}%
+ {\penaltycheck{\sectionpenalty}\normalfont\bfseries\Large}%
+}
+\renewcommand\subsection{%
+ \@startsection{subsection}{2}%
+ {0pt}%
+ {1.25em}%
+ {1.25ex}%
+ {\penaltycheck{\subsectionpenalty}\normalfont\bfseries\large}%
+}
+\renewcommand\subsubsection{%
+ \@startsection{subsubsection}{2}%
+ {0pt}%
+ {1.00em}%
+ {1.00ex}%
+ {\penaltycheck{\subsubsectionpenalty}\normalfont\bfseries\normalsize}%
+}
+\makeatother
+
+% default tight list spacing
+\makeatletter
+\newlength{\style@parsep}
+\newlength{\style@itemsep}
+\newlength{\style@itemizemargin}
+\setlength{\style@parsep}{1mm}
+\setlength{\style@itemsep}{1mm}
+\setlength{\style@itemizemargin}{2mm}
+\setlist{
+ topsep=\dimexpr\style@itemizemargin-\parskip\relax,
+ itemsep=\dimexpr\style@itemsep-\style@parsep\relax,
+ parsep=\style@parsep,
+}
+\def\projdoc@description@before{%
+ \renewcommand\makelabel[1]{%
+ {\bfseries ##1}:%
+ }%
+}
+\newlength\projdoc@description@leftmargin%
+\projdoc@description@leftmargin=3em%
+\newlength\projdoc@description@labelindent%
+\projdoc@description@labelindent=3ex%
+\def\projdoc@setdescriptionstyle{%
+ \setdescription{
+ before={\projdoc@description@before},
+ leftmargin=\projdoc@description@leftmargin,
+ labelindent=\projdoc@description@labelindent,
+ }%
+}
+\projdoc@setdescriptionstyle%
+\makeatother
+
+% create a label using \customlabel[<creftype>]{<refname>}{<reftext>} that displays
+% <reftext> when \ref{<refname>} is used, or <creftype> <reftext> when
+% \cref{<refname>} is used
+\makeatletter
+\NewDocumentCommand{\customlabel}{omm}{%
+ \begingroup
+ \cref@constructprefix{#1}{\cref@result}%
+ \protected@edef\@currentlabel{#3}%
+ \protected@edef\@currentlabelname{#3}%
+ \protected@edef\cref@currentlabel{[#1][][\cref@result]#3}
+ \label[#1]{#2}%
+ \endgroup
+}
+\makeatother
+
+% float here by default
+\usepackage{float}
+\makeatletter
+\def\fps@figure{H}
+\def\fps@table{H}
+\makeatother
+
+% bibliography
+\addbibresource{refs.bib}
+
+% glossary
+\GlsXtrLoadResources[
+ src={./glossary.bib},
+ selection={recorded and deps and see},
+]
+
+% default document header/trailer
+\makeatletter
+\def\projdoc@header{
+ % start with title page
+ \clearpage
+ \begin{titlepage}
+ \maketitle
+ \thispagestyle{empty}
+ \end{titlepage}
+}
+\newbool{projdoc@used@cite}
+\newbool{projdoc@used@gls}
+\apptocmd{\abx@aux@cite}{\global\booltrue{projdoc@used@cite}}{}{}
+\apptocmd{\glsxtr@record}{\global\booltrue{projdoc@used@gls}}{}{}
+\def\projdoc@trailer{
+ % bibliography (if citations used)
+ \ifbool{projdoc@used@cite}{%
+ \hfuzz=50pt% reduce overfull hbox warnings for bibliography (mostly URLs)
+ \printbibliography%
+ }{}%
+ % glossary
+ \ifbool{projdoc@used@gls}{%
+ \projdoc@description@leftmargin=2ex%
+ \projdoc@description@labelindent=0pt%
+ \projdoc@setdescriptionstyle%
+ \section*{Glossary}%
+ \begin{multicols}{2}%
+ \renewcommand{\glossarysection}[2][]{}%
+ \printunsrtglossary%
+ \end{multicols}%
+ }{}%
+}
+\AtBeginDocument{\projdoc@header}
+\AtEndDocument{\projdoc@trailer}
+\makeatother
+
+% store figure/table count in macros
+\makeatletter
+\def\figurecount{0}%
+\def\tablecount{0}%
+\def\pagecount{0}%
+\AtEndDocument{
+ \immediate\write\@mainaux{\string\global\string\def\string\figurecount{\the\value{figure}}}
+ \immediate\write\@mainaux{\string\global\string\def\string\tablecount{\the\value{table}}}
+ \immediate\write\@mainaux{\string\global\string\def\string\pagecount{\thepage}}
+}
+\makeatother
+
+% generate table of contents, figures, tables
+\def\tablestables{%
+ \tableofcontents%
+ \label{sec:toc}%
+ \ifnumgreater{\figurecount}{0}{\listoffigures}{}%
+ \label{sec:lof}%
+ \ifnumgreater{\tablecount}{0}{\listoftables}{}%
+ \label{sec:lot}%
+}
+
+% code
+\DeclareUrlCommand\codeinline{%
+ \urlstyle{tt}%
+ \def\codebreak{\discretionary{\hbox{~\textbackslash{}}}{\hbox{~~}}{}}%
+ \def\UrlSpecials{%
+ \do\/{\hbox{/}\codebreak}%
+ \do\_{\hbox{\_}\codebreak}%
+ \do\ {\hbox{\ }\codebreak}%
+ \do\-{\hbox{-}\codebreak}%
+ }%
+ \def\UrlNoBreaks{%
+ \do\+%
+ \do\.%
+ \do\[%
+ \do\]%
+ }%
+ \def\UrlLeft{\hbox{\,}}%
+ \def\UrlRight{\hbox{\,}}%
+}
+\DefineVerbatimEnvironment{blockcode}{Verbatim}{
+ tabsize=2,
+ obeytabs,
+}
+
+% scale down image if it exceeds page margins
+\newcommand{\fitimg}[1]{%
+ \adjustbox{max width=\linewidth}{#1}%
+}
+
+% adjust scale for puml diagrams
+\newcommand{\includepumldiag}[1]{%
+ \StrSubstitute{#1}{.puml}{.eps}[\filename]%
+ \fitimg{\includegraphics[scale=0.75]{\filename}}%
+}
+
+% prevent page break between two paragraphs
+\makeatletter
+\newcommand\noparbreak{\par\nobreak\@afterheading}
+\makeatother
+
+\newtcbox{\hide}{blank,opacitytext=0}
+\def\pictochat{%
+ \strut%
+ \adjustbox{%
+ foreground={%
+ \hide{PictoChat}%
+ }%
+ }{%
+ \includegraphics[%
+ height=0.73em, % about height of X in TeX Gyre Schola
+ ]{../assets/pictochat-logo.pdf}%
+ }%
+ \strut%
+}
+\ifdraft{\def\pictochat{PictoChat}}{}%
+
diff --git a/docs/glossary.bib b/docs/glossary.bib
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/docs/glossary.bib
diff --git a/docs/main.tex b/docs/main.tex
index ff058e4..18dfe0a 100644
--- a/docs/main.tex
+++ b/docs/main.tex
@@ -1,37 +1,10 @@
-\documentclass[a4paper, english, draft]{article}
-\usepackage{geometry}
+\documentclass[draft]{doc}
+\input{titlepage.tex}
-\usepackage{float}
-\usepackage{babel}
-\usepackage{siunitx}
-\usepackage{amsmath}
-\usepackage{csquotes}
-\usepackage{parskip}
-\usepackage{unicode-math}
-\usepackage{fontspec}
-\usepackage{tabularx}
-\usepackage{booktabs}
-\usepackage{needspace}
-\usepackage[hidelinks]{hyperref}
-\usepackage[backend=biber,
- bibencoding=utf8,
- style=apa
-]{biblatex}
-\addbibresource{refs.bib}
-
-\setmainfont{TeX Gyre Schola}
-\setmathfont{TeX Gyre Schola Math}
-\sisetup{
- group-separator = {.},
- output-decimal-marker = {,}
-}
-
-\title{Reverse engineering PictoChat}
+\title{Reverse engineering \pictochat}
\author{Loek Le Blansch}
\begin{document}
-\begin{titlepage}
-\maketitle
-\end{titlepage}
+WIP
\end{document}
diff --git a/docs/time.txt b/docs/time.txt
index cf27eff..4a32815 100644
--- a/docs/time.txt
+++ b/docs/time.txt
@@ -29,3 +29,4 @@
2024-10-04 2h10m: reverse message serialization
2024-10-05 1h50m: debugging fiddled messages being ignored
2024-10-06 30m: debugging fiddled messages being ignored
+2024-10-07 20m: fix small bugs and add proof of concept image
diff --git a/docs/titlepage.tex b/docs/titlepage.tex
new file mode 100644
index 0000000..985ea91
--- /dev/null
+++ b/docs/titlepage.tex
@@ -0,0 +1,101 @@
+\usepackage{tikz}
+\usetikzlibrary{patterns,patterns.meta}
+
+\newlength\pixelsize%
+\newlength\tpwidth%
+
+\def\pixelscale{1.5}%
+\pixelsize=1.5pt
+\tpwidth=35em
+
+\definecolor{bgfill}{HTML}{a9aaa9}
+\definecolor{bgline}{HTML}{bbbbbb}
+
+\makeatletter
+\def\@maketitle@pretty{%
+ \begin{tikzpicture}[
+ remember picture,
+ overlay,
+ yscale=-1,
+ inner sep=0pt,
+ ]%
+ % background
+ \fill[bgfill] (current page.north west) rectangle (current page.south east);
+ \draw[
+ pattern color=bgline,
+ pattern={Lines[distance=6pt,line width=1.5pt]}
+ ] (current page.north west) rectangle (current page.south east);
+
+ % sidebar
+ \fill[white] (current page.north west) rectangle
+ ++(19pt*\pixelscale,\pdfpageheight);
+ \node[anchor=north west] at (current page.north west)
+ {\includegraphics[scale=\pixelscale]{cover/log-top.pdf}};
+ \node[anchor=south west] at (current page.south west)
+ {\includegraphics[scale=\pixelscale]{cover/log-bottom.pdf}};
+
+ % title frame
+ \draw (current page.north) ++ (0pt,2in)
+ ++ (0pt,0pt*\pixelscale) node (titleframe) [anchor=north]
+ {\includegraphics[scale=\pixelscale]{cover/title-frame.pdf}};
+ % author frame
+ \draw (titleframe.south)
+ ++ (0pt,2pt*\pixelscale) node (authorframe) [anchor=north]
+ {\includegraphics[scale=\pixelscale]{cover/author-frame.pdf}};
+ % lena message
+ \draw (authorframe.south)
+ ++ (0pt,2pt*\pixelscale) node (lena) [anchor=north]
+ {\includegraphics[scale=\pixelscale]{cover/lena.png}};
+ % date frame
+ \draw (lena.south east)
+ ++ (0pt,2pt*\pixelscale) node (dateframe) [anchor=north east]
+ {\includegraphics[scale=\pixelscale]{cover/date-frame.pdf}};
+
+ % title content
+ \node[anchor=north west, inner sep=8pt*\pixelscale] at (titleframe.north west)
+ {%
+ \color{white}%
+ \parbox{224\pixelsize}{%
+ \flushleft%
+ \Huge%
+ \strut\@title\strut%
+ }%
+ };
+ % author content
+ \draw (authorframe.west) ++ (88pt*\pixelscale,0pt) node [anchor=west]
+ {\color{white}\strut\@author\strut};
+ % date content
+ \draw (dateframe.east) ++ (-6pt*\pixelscale,0pt) node [anchor=east]
+ {\color{white}\strut\@date\strut};
+ \end{tikzpicture}%
+}
+
+\def\@maketitle@draft{%
+ \centering%
+ \parskip=0pt%
+ \vspace*{1in}%
+ \def\tpwidth{35em}%
+ \parbox{\tpwidth}{%
+ \flushleft%
+ \par{%
+ \Huge%
+ \strut\@title\strut%
+ }%
+ \vspace{5mm}%
+ \par{%
+ \strut\@author\strut%
+ }%
+ }%
+ \vfill%
+ \parbox{\tpwidth}{%
+ \flushright%
+ \par\strut\@date\strut%
+ \par(DRAFT)%
+ }%
+ \par\vspace*{1in}%
+}
+
+\ifdraft{\let\@maketitle\@maketitle@draft}{\let\@maketitle\@maketitle@pretty}
+
+\makeatother
+
diff --git a/experiments/conv/png2pc b/experiments/conv/png2pc
index 21b3b29..8d7a808 100755
--- a/experiments/conv/png2pc
+++ b/experiments/conv/png2pc
@@ -38,9 +38,9 @@ def png2pc(data):
img = img.quantize(palette=palette_img)
draw = ImageDraw.Draw(img)
- draw.rectangle(((0, 0), (24, img.height)), fill=0)
- draw.rectangle(((252, 0), (256, img.height)), fill=0)
- draw.rectangle(((24, 0), (79, 16)), fill=0)
+ draw.rectangle(((0, 0), (23, img.height - 1)), fill=0)
+ draw.rectangle(((252, 0), (255, img.height - 1)), fill=0)
+ draw.rectangle(((24, 0), (78, 15)), fill=0)
output = b""
for tile_idx in range(tile_count):
diff --git a/experiments/crop-melon b/experiments/crop-melon
new file mode 100755
index 0000000..5beb634
--- /dev/null
+++ b/experiments/crop-melon
@@ -0,0 +1,10 @@
+#!/bin/sh
+input_file="$1"
+output_base="${input_file%.*}-crop.png"
+magick "$input_file" \
+ -gravity North -chop 0x20 \
+ -crop 256x192 \
+ "$output_base"
+
+
+