| 1 |
%% Copyright 2017-2023 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 pixelart.sty, pixelart.lua, pixelart.tex. |
| 16 |
|
| 17 |
\NeedsTeXFormat{LaTeX2e} |
| 18 |
\ProvidesPackage{pixelart}[2023/02/20 v1.0.2 A package to draw pixel-art pictures] |
| 19 |
|
| 20 |
\RequirePackage{iftex} |
| 21 |
\ifluatex |
| 22 |
% Great! |
| 23 |
\else |
| 24 |
\PackageError{pixelart}{This package requires LuaTeX}{If you want to draw pixel-art pictures without LuaTeX, you can use either pixelart0 (outdated version of pixelart, bundled with this package), or pxpic} |
| 25 |
\fi |
| 26 |
|
| 27 |
\RequirePackage{luacode} |
| 28 |
\RequirePackage{tikz} |
| 29 |
\usetikzlibrary{patterns} |
| 30 |
|
| 31 |
\luadirect{require("pixelart")} |
| 32 |
|
| 33 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 34 |
% Package options |
| 35 |
\DeclareOption{draft}{\luadirect{pixelart._draft = true}} |
| 36 |
\ProcessOptions |
| 37 |
|
| 38 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 39 |
% Default style |
| 40 |
\tikzset{pixelart/.style={}} |
| 41 |
|
| 42 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 43 |
% Wrappers to Lua functions |
| 44 |
|
| 45 |
\newcommand{\pixelart}[2][]{\luadirect{pixelart.pixelart("\luatexluaescapestring{#2}", "\luatexluaescapestring{#1}")}} |
| 46 |
\newcommand{\tikzpixelart}[3][]{\luadirect{pixelart.tikzpixelart("\luatexluaescapestring{#2}", "\luatexluaescapestring{#3}", "\luatexluaescapestring{#1}")}} |
| 47 |
\newcommand{\newpixelartcolors}[2]{\luadirect{pixelart.newpixelartcolors("\luatexluaescapestring{#1}", "\luatexluaescapestring{#2}")}} |
| 48 |
\newcommand{\renewpixelartcolors}[2]{\luadirect{pixelart.renewpixelartcolors("\luatexluaescapestring{#1}", "\luatexluaescapestring{#2}")}} |
| 49 |
\newcommand{\setpixelartdefault}[1]{\luadirect{pixelart.setpixelartdefault("\luatexluaescapestring{#1}")}} |
| 50 |
\newcommand{\setpixelartdebugon}{\luadirect{pixelart.setpixelartdebug(true)}} |
| 51 |
\newcommand{\setpixelartdebugoff}{\luadirect{pixelart.setpixelartdebug(false)}} |
| 52 |
|
| 53 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 54 |
% Logos |
| 55 |
|
| 56 |
\makeatletter |
| 57 |
\newcommand{\pixelartlogo}[1][ |
| 58 |
colors={ |
| 59 |
A=red, |
| 60 |
B=orange, |
| 61 |
C=yellow, |
| 62 |
D=green, |
| 63 |
E=cyan, |
| 64 |
F=blue, |
| 65 |
G=purple, |
| 66 |
1=red, |
| 67 |
2={red!50!black}, |
| 68 |
3={pink}, |
| 69 |
4={pink!50!red}, |
| 70 |
}, |
| 71 |
stack, |
| 72 |
]{% |
| 73 |
\begin{tikzpicture}[scale={\f@size/400}] |
| 74 |
\draw (34, 0) node[opacity=0, anchor=south, inner sep=0pt]{\texttt{Pixel Art}}; |
| 75 |
\tikzpixelart[#1]{(0, 0)}{ |
| 76 |
AAAABB...CC...................FFE...............A...............E... |
| 77 |
.BA..AB..BC....................FF...12..12.....BBB.............DD... |
| 78 |
.BB..AA........................GF..13411112...CC.BB............CD... |
| 79 |
.CB..BA.AAB..BC....DD..EEEFF...GG.1341111112.DC...BB.BA.AAB..BCCCCD. |
| 80 |
.CCCBB...AA...BB..CC..DD...EF..FG.1341111112.DD...CC..BBA.AB...BC... |
| 81 |
.DC......BA....BBBC...DDDDEEE..FF.1341111112.EDDDDCC..BB..AA...BB... |
| 82 |
.DD......BB.....BB....CC.......EF..11111112..EE...DD..CC.......AB... |
| 83 |
.ED......CB....AAAB...CC.......EE...111112...FE...DD..CC.......AA... |
| 84 |
.EE......CC...BB..AA..BB...CD..DE....1112....FF...EE..DD.......BA.AA |
| 85 |
FFEE....DDCC.CB....AA..BBBCC..DDDD....12.....GF...EE.EDDD.......BBA. |
| 86 |
} |
| 87 |
\end{tikzpicture}% |
| 88 |
} |
| 89 |
|
| 90 |
\newcommand{\pixelartheart}[1][ |
| 91 |
colors={ |
| 92 |
1=red, |
| 93 |
2={red!50!black}, |
| 94 |
3={pink}, |
| 95 |
4={pink!50!red}, |
| 96 |
}, |
| 97 |
tikz={ |
| 98 |
scale={\f@size/300}, |
| 99 |
baseline=.1em, |
| 100 |
}, |
| 101 |
stack, |
| 102 |
]{% |
| 103 |
\pixelart[#1]{ |
| 104 |
..12..12.. |
| 105 |
.13411112. |
| 106 |
1341111112 |
| 107 |
1341111112 |
| 108 |
1341111112 |
| 109 |
.11111112. |
| 110 |
..111112.. |
| 111 |
...1112... |
| 112 |
....12.... |
| 113 |
}% |
| 114 |
} |
| 115 |
|
| 116 |
\newcommand{\pixelartname}[1][ |
| 117 |
colors={ |
| 118 |
A=red, |
| 119 |
B=orange, |
| 120 |
C=yellow, |
| 121 |
D=green, |
| 122 |
E=cyan, |
| 123 |
F=blue, |
| 124 |
G=purple, |
| 125 |
}, |
| 126 |
stack, |
| 127 |
]{% |
| 128 |
\begin{tikzpicture}[scale={\f@size/400}] |
| 129 |
\draw (28, 0) node[opacity=0, anchor=south, inner sep=0pt]{\texttt{PixelArt}}; |
| 130 |
\tikzpixelart[#1]{(0, 0)}{ |
| 131 |
AAAABB...CC...................FFE.....D...............B... |
| 132 |
.BA..AB..BC....................FF....EDD.............AB... |
| 133 |
.BB..AA........................GF...EE.ED............AA... |
| 134 |
.CB..BA.AAB..BC....DD..EEEFF...GG..FF...EE.DD.CCC..BBBAAA. |
| 135 |
.CCCBB...AA...BB..CC..DD...EF..FG..GF...EE..DDD.CC...BB... |
| 136 |
.DC......BA....BBBC...DDDDEEE..FF..GGGFFFF..EE..DD...CB... |
| 137 |
.DD......BB.....BB....CC.......EF..FG...FF..EE.......CC... |
| 138 |
.ED......CB....AAAB...CC.......EE..FF...GG..FF.......DC... |
| 139 |
.EE......CC...BB..AA..BB...CD..DE..EF...GG..FF.......DD.CC |
| 140 |
FFEE....DDCC.CB....AA..BBBCC..DDDD.EE...FF.GGGF.......DDD. |
| 141 |
} |
| 142 |
\end{tikzpicture}% |
| 143 |
} |
| 144 |
|
| 145 |
\newcommand{\pixelartlogobw}[1][colors=mono, stack]{% |
| 146 |
\begin{tikzpicture}[scale={\f@size/400}] |
| 147 |
\draw (33, 0) node[opacity=0, anchor=south, inner sep=0pt]{\texttt{PixelArt}}; |
| 148 |
\tikzpixelart[#1]{(0, 0)}{ |
| 149 |
111111...11...................111...............1...............1... |
| 150 |
.11..11..11....................11...11..11.....111.............11... |
| 151 |
.11..11........................11..11111111...11.11............11... |
| 152 |
.11..11.111..11....11..11111...11.1111111111.11...11.11.111..111111. |
| 153 |
.11111...11...11..11..11...11..11.1111111111.11...11..111.11...11... |
| 154 |
.11......11....1111...1111111..11.1111111111.1111111..11..11...11... |
| 155 |
.11......11.....11....11.......11..11111111..11...11..11.......11... |
| 156 |
.11......11....1111...11.......11...111111...11...11..11.......11... |
| 157 |
.11......11...11..11..11...11..11....1111....11...11..11.......11.11 |
| 158 |
1111....1111.11....11..11111..1111....11.....11...11.1111.......111. |
| 159 |
} |
| 160 |
\end{tikzpicture}% |
| 161 |
} |
| 162 |
|
| 163 |
\newcommand{\pixelartheartbw}[1][colors=mono, tikz={scale={\f@size/300}, baseline=.1em}, stack]{% |
| 164 |
\pixelart[#1]{ |
| 165 |
..11..11.. |
| 166 |
.11111111. |
| 167 |
1111111111 |
| 168 |
1111111111 |
| 169 |
1111111111 |
| 170 |
.11111111. |
| 171 |
..111111.. |
| 172 |
...1111... |
| 173 |
....11.... |
| 174 |
}% |
| 175 |
} |
| 176 |
|
| 177 |
\newcommand{\pixelartnamebw}[1][colors=mono, stack]{% |
| 178 |
\begin{tikzpicture}[scale={\f@size/400}] |
| 179 |
\draw (28, 0) node[opacity=0, anchor=south, inner sep=0pt]{\texttt{PixelArt}}; |
| 180 |
\tikzpixelart[#1]{(0, 0)}{ |
| 181 |
111111...11...................111.....1...............1... |
| 182 |
.11..11..11....................11....111.............11... |
| 183 |
.11..11........................11...11.11............11... |
| 184 |
.11..11.111..11....11..11111...11..11...11.11.111..111111. |
| 185 |
.11111...11...11..11..11...11..11..11...11..111.11...11... |
| 186 |
.11......11....1111...1111111..11..1111111..11..11...11... |
| 187 |
.11......11.....11....11.......11..11...11..11.......11... |
| 188 |
.11......11....1111...11.......11..11...11..11.......11... |
| 189 |
.11......11...11..11..11...11..11..11...11..11.......11.11 |
| 190 |
1111....1111.11....11..11111..1111.11...11.1111.......111. |
| 191 |
} |
| 192 |
\end{tikzpicture}% |
| 193 |
} |
| 194 |
|
| 195 |
\makeatother |