| 1 |
% PuyoTikZ package for LaTeX. |
| 2 |
% Created by amosborne (GitHub) / terramyst (Twitter). |
| 3 |
% MIT License |
| 4 |
|
| 5 |
\NeedsTeXFormat{LaTeX2e}[1994/06/01] |
| 6 |
\ProvidesPackage{puyotikz}[2020/12/28 v1.0.1 PuyoTikZ] |
| 7 |
|
| 8 |
\RequirePackage{pythontex} |
| 9 |
\RequirePackage{tikz} |
| 10 |
\RequirePackage{keyval} |
| 11 |
|
| 12 |
\begin{pycode} |
| 13 |
import sys, subprocess |
| 14 |
ptha = subprocess.check_output(['kpsewhich', '-var-value=TEXMFDIST'], universal_newlines=True) |
| 15 |
ptha = ptha.rstrip('\n') |
| 16 |
pthb = ptha + '/scripts/puyotikz' |
| 17 |
sys.path.append(pthb) |
| 18 |
|
| 19 |
import puyotikz as puyo |
| 20 |
\end{pycode} |
| 21 |
|
| 22 |
\def\puyosmallscale{0.34} |
| 23 |
\def\puyobigscale{0.65} |
| 24 |
|
| 25 |
\newenvironment{puyotikz}[1][\puyobigscale] |
| 26 |
{\begin{tikzpicture}[scale=#1, every node/.style={transform shape}]} |
| 27 |
{\end{tikzpicture}} |
| 28 |
|
| 29 |
\define@key{puyoboard}{ncols}{\def\puyo@ncols{#1}} |
| 30 |
\define@key{puyoboard}{nrows}{\def\puyo@nrows{#1}} |
| 31 |
\define@key{puyoboard}{nhidrows}{\def\puyo@nhidrows{#1}} |
| 32 |
\define@key{puyoboard}{showlabels}{\def\puyo@showlabels{#1}} |
| 33 |
\setkeys{puyoboard}{ncols=6, nrows=12, nhidrows=1, showlabels=True} |
| 34 |
|
| 35 |
\setpythontexcontext{ |
| 36 |
ncols=\puyo@ncols, |
| 37 |
nrows=\puyo@nrows, |
| 38 |
nhidrows=\puyo@nhidrows, |
| 39 |
showlabels=\puyo@showlabels |
| 40 |
} |
| 41 |
|
| 42 |
\newcommand{\puyoboard}[3][]{ |
| 43 |
\setkeys{puyoboard}{#1} |
| 44 |
\pyc{puyo.puyoboard(cols=int(pytex.context.ncols), % |
| 45 |
rows=int(pytex.context.nrows), % |
| 46 |
hrows=int(pytex.context.nhidrows), % |
| 47 |
boardpuyos="#2", % |
| 48 |
nextpuyos="#3", % |
| 49 |
label=pytex.context.showlabels=="True")} |
| 50 |
} |
| 51 |
|
| 52 |
\newcommand{\puyomarker}[1]{\pyc{puyo.puyomarker("#1")}} |
| 53 |
|
| 54 |
\newcommand{\puyogrid}[2][]{ |
| 55 |
\setkeys{puyoboard}{nhidrows=0, showlabels=False} |
| 56 |
\begin{puyotikz}[\puyosmallscale] |
| 57 |
\puyoboard[#1]{#2}{} |
| 58 |
\end{puyotikz} |
| 59 |
} |
| 60 |
|
| 61 |
\newcommand{\puyocolor}[2]{ |
| 62 |
\definecolor{#1puyo}{RGB}{#2} |
| 63 |
\colorlet{dark#1puyo}{#1puyo!80!black} |
| 64 |
} |
| 65 |
\puyocolor{red}{255,82,98} |
| 66 |
\puyocolor{green}{82,213,98} |
| 67 |
\puyocolor{blue}{32,115,213} |
| 68 |
\puyocolor{yellow}{255,220,24} |
| 69 |
\puyocolor{purple}{131,90,213} |
| 70 |
\puyocolor{gray}{180,172,189} |
| 71 |
|
| 72 |
\endinput |