| 1 |
%% Copyright 2017-2022 Louis Paternault |
| 2 |
%% |
| 3 |
%% This work may be distributed and/or modified under the |
| 4 |
%% conditions of the LaTeX Project Public License, either version 1.3 |
| 5 |
%% of this license or (at your option) any later version. |
| 6 |
%% The latest version of this license is in |
| 7 |
%% http://www.latex-project.org/lppl.txt |
| 8 |
%% and version 1.3 or later is part of all distributions of LaTeX |
| 9 |
%% version 2005/12/01 or later. |
| 10 |
%% |
| 11 |
%% This work has the LPPL maintenance status `maintained'. |
| 12 |
%% |
| 13 |
%% The Current Maintainer of this work is Louis Paternault |
| 14 |
%% |
| 15 |
%% This work consists of the files pixelart0.sty and pixelart0.tex. |
| 16 |
|
| 17 |
\NeedsTeXFormat{LaTeX2e} |
| 18 |
\ProvidesPackage{pixelart0} |
| 19 |
[2022/11/16 v0.3.0 A package to draw pixel-art pictures] |
| 20 |
|
| 21 |
\RequirePackage{pgf} |
| 22 |
\RequirePackage{pgfopts} |
| 23 |
\usepgfmodule{parser} |
| 24 |
\RequirePackage{tikz} |
| 25 |
\usetikzlibrary{calc} |
| 26 |
\RequirePackage{pgfkeys} |
| 27 |
\RequirePackage{etoolbox} |
| 28 |
|
| 29 |
\makeatletter |
| 30 |
|
| 31 |
\newif\ifpixelart@draft |
| 32 |
\pgfkeys{ |
| 33 |
/PIXELART/.cd, |
| 34 |
draft/.is if=pixelart@draft, |
| 35 |
draft=false, |
| 36 |
} |
| 37 |
\ProcessPgfPackageOptions{/PIXELART} |
| 38 |
\pgfkeys{ |
| 39 |
/PIXELART/BWPIXELART/.is family, |
| 40 |
/PIXELART/BWPIXELART, |
| 41 |
scale/.value required, |
| 42 |
scale/.code={\pgfkeyssetvalue{/PIXELART/BWPIXELART/scale}{#1}}, |
| 43 |
scale=1, |
| 44 |
raise/.code={\pgfkeyssetvalue{/PIXELART/BWPIXELART/raise}{#1}}, |
| 45 |
raise/.value required, |
| 46 |
raise=0pt, |
| 47 |
color/.value required, |
| 48 |
color/.code={\pgfkeyssetvalue{/PIXELART/BWPIXELART/color}{#1}}, |
| 49 |
color=black, |
| 50 |
} |
| 51 |
|
| 52 |
\pgfkeys{ |
| 53 |
/PIXELART/TIKZBWPIXELART/.is family, |
| 54 |
/PIXELART/TIKZBWPIXELART, |
| 55 |
scale/.value required, |
| 56 |
scale/.code={\pgfkeyssetvalue{/PIXELART/TIKZBWPIXELART/scale}{#1}}, |
| 57 |
scale=1, |
| 58 |
color/.value required, |
| 59 |
color/.code={\pgfkeyssetvalue{/PIXELART/TIKZBWPIXELART/color}{#1}}, |
| 60 |
color=black, |
| 61 |
} |
| 62 |
|
| 63 |
\pgfparserdef{@bwpixelart}{initial}{blank space \space}{ |
| 64 |
\@bwpa@newline |
| 65 |
} |
| 66 |
\pgfparserdef{@bwpixelart}{initial}{the character 0}{ |
| 67 |
\coordinate (@pixelart) at ($(@pixelart) + (1, 0)$); |
| 68 |
} |
| 69 |
\pgfparserdef{@bwpixelart}{initial}{the character 1}{ |
| 70 |
\fill (@pixelart) rectangle ++(1, 1); |
| 71 |
\coordinate (@pixelart) at ($(@pixelart) + (1, 0)$); |
| 72 |
} |
| 73 |
\pgfparserdef{@bwpixelart}{initial}{the letter @}{ |
| 74 |
\pgfparserswitch{final} |
| 75 |
} |
| 76 |
|
| 77 |
\newcommand{\@bwpa@newline}{ |
| 78 |
\coordinate (@pixelart) at ($(@pixelart@startline) + (0, -1)$); |
| 79 |
\coordinate (@pixelart@startline) at (@pixelart); |
| 80 |
} |
| 81 |
|
| 82 |
\newcommand{\bwpixelart}[2][]{{% |
| 83 |
\pgfkeys{/PIXELART/BWPIXELART, #1}% |
| 84 |
\raisebox{\pgfkeysvalueof{/PIXELART/BWPIXELART/raise}}{% |
| 85 |
\tikz[ |
| 86 |
scale=\pgfkeysvalueof{/PIXELART/BWPIXELART/scale}, |
| 87 |
]{ |
| 88 |
\tikzbwpixelart[% |
| 89 |
color=\pgfkeysvalueof{/PIXELART/BWPIXELART/color}, |
| 90 |
]{(0, 0)}{#2} |
| 91 |
}% |
| 92 |
}% |
| 93 |
}} |
| 94 |
|
| 95 |
\newcommand{\tikzbwpixelart}[3][]{ |
| 96 |
\pgfkeys{/PIXELART/TIKZBWPIXELART, #1} |
| 97 |
\ifpixelart@draft |
| 98 |
% Draft mode. Nothing to parse, nothing to show! |
| 99 |
\else |
| 100 |
\begin{scope}[shift={#2}] |
| 101 |
\begin{scope}[#1] |
| 102 |
\coordinate (@pixelart) at (0, 1); |
| 103 |
\coordinate (@pixelart@startline) at (@pixelart); |
| 104 |
|
| 105 |
\pgfparserparse{@bwpixelart} |
| 106 |
#3 @ |
| 107 |
\end{scope} |
| 108 |
\end{scope} |
| 109 |
\fi |
| 110 |
} |
| 111 |
|
| 112 |
\makeatother |
| 113 |
|
| 114 |
\endinput |