summaryrefslogtreecommitdiff
path: root/graphics/pgf/contrib/puyotikz/puyotikz.sty
blob: 4a5c4dd200583888f202e7ebdd07ea015bf1a48c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
% PuyoTikZ package for LaTeX.
% Created by amosborne (GitHub) / terramyst (Twitter).
% MIT License

\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{puyotikz}[2020/12/23 v1.0.0 PuyoTikZ]

\RequirePackage{pythontex}
\RequirePackage{tikz}
\RequirePackage{keyval}

\pyc{import puyotikz as puyo}

\def\puyosmallscale{0.34}
\def\puyobigscale{0.65}

\newenvironment{puyotikz}[1][\puyobigscale]
	{\begin{tikzpicture}[scale=#1, every node/.style={transform shape}]}
	{\end{tikzpicture}}

\define@key{puyoboard}{ncols}{\def\puyo@ncols{#1}}
\define@key{puyoboard}{nrows}{\def\puyo@nrows{#1}}
\define@key{puyoboard}{nhidrows}{\def\puyo@nhidrows{#1}}
\define@key{puyoboard}{showlabels}{\def\puyo@showlabels{#1}}
\setkeys{puyoboard}{ncols=6, nrows=12, nhidrows=1, showlabels=True}

\setpythontexcontext{
	ncols=\puyo@ncols,
	nrows=\puyo@nrows,
	nhidrows=\puyo@nhidrows,
	showlabels=\puyo@showlabels
}

\newcommand{\puyoboard}[3][]{
	\setkeys{puyoboard}{#1}
	\pyc{puyo.puyoboard(cols=int(pytex.context.ncols), %
		                rows=int(pytex.context.nrows), %
		                hrows=int(pytex.context.nhidrows), %
		                boardpuyos="#2", %
		                nextpuyos="#3", %
		                label=pytex.context.showlabels=="True")}
}

\newcommand{\puyomarker}[1]{\pyc{puyo.puyomarker("#1")}}

\newcommand{\puyogrid}[2][]{
	\setkeys{puyoboard}{nhidrows=0, showlabels=False}
	\begin{puyotikz}[\puyosmallscale]
		\puyoboard[#1]{#2}{}
	\end{puyotikz}
}

\newcommand{\puyocolor}[2]{
	\definecolor{#1puyo}{RGB}{#2}
	\colorlet{dark#1puyo}{#1puyo!80!black}
}
\puyocolor{red}{255,82,98}
\puyocolor{green}{82,213,98}
\puyocolor{blue}{32,115,213}
\puyocolor{yellow}{255,220,24}
\puyocolor{purple}{131,90,213}
\puyocolor{gray}{180,172,189}

\endinput