texlive[57225] Master: puyotikz (25dec20)

commits+karl at tug.org commits+karl at tug.org
Fri Dec 25 23:03:53 CET 2020


Revision: 57225
          http://tug.org/svn/texlive?view=revision&revision=57225
Author:   karl
Date:     2020-12-25 23:03:53 +0100 (Fri, 25 Dec 2020)
Log Message:
-----------
puyotikz (25dec20)

Modified Paths:
--------------
    trunk/Master/tlpkg/bin/tlpkg-ctan-check
    trunk/Master/tlpkg/libexec/ctan2tds
    trunk/Master/tlpkg/tlpsrc/collection-pictures.tlpsrc

Added Paths:
-----------
    trunk/Master/texmf-dist/doc/latex/puyotikz/
    trunk/Master/texmf-dist/doc/latex/puyotikz/LICENSE
    trunk/Master/texmf-dist/doc/latex/puyotikz/README.md
    trunk/Master/texmf-dist/doc/latex/puyotikz/puyotikz.pdf
    trunk/Master/texmf-dist/doc/latex/puyotikz/puyotikz.tex
    trunk/Master/texmf-dist/tex/latex/puyotikz/
    trunk/Master/texmf-dist/tex/latex/puyotikz/puyotikz.py
    trunk/Master/texmf-dist/tex/latex/puyotikz/puyotikz.sty
    trunk/Master/tlpkg/tlpsrc/puyotikz.tlpsrc

Added: trunk/Master/texmf-dist/doc/latex/puyotikz/LICENSE
===================================================================
--- trunk/Master/texmf-dist/doc/latex/puyotikz/LICENSE	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/puyotikz/LICENSE	2020-12-25 22:03:53 UTC (rev 57225)
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2020 amosborne
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.

Added: trunk/Master/texmf-dist/doc/latex/puyotikz/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/puyotikz/README.md	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/puyotikz/README.md	2020-12-25 22:03:53 UTC (rev 57225)
@@ -0,0 +1,21 @@
+# PuyoTikZ
+
+A LaTeX package for quickly typesetting board states of Puyo Puyo games.
+
+Supports large and small boards with arbitrary shape, hidden rows, current and next puyos, labels and move planning markers. Source code available for download on [GitHub](https://github.com/amosborne/puyotikz) or your favorite TeX repository. Package requires [Python3](https://www.python.org/) in support of scripts driven by [PythonTeX](https://github.com/gpoore/pythontex).
+
+Please see the PuyoTikZ documentation for more details on usage, installation, and known limitations.
+
+Created by [terramyst](https://twitter.com/terramyst1).
+
+MIT License.
+
+```tex
+% Example usage.
+\begin{puyotikz}[\puyosmallscale]
+    \puyoboard{rg/rgr/br/g}{rr/rb/gg}
+    \puyomarker{e1rA/e2rA/f1bB/f2rB}
+\end{puyotikz}
+
+\puyogrid[nrows=4, ncols=4]{bbb/rrrb/gggr/yyyg}
+```


Property changes on: trunk/Master/texmf-dist/doc/latex/puyotikz/README.md
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/latex/puyotikz/puyotikz.pdf
===================================================================
(Binary files differ)

Index: trunk/Master/texmf-dist/doc/latex/puyotikz/puyotikz.pdf
===================================================================
--- trunk/Master/texmf-dist/doc/latex/puyotikz/puyotikz.pdf	2020-12-25 22:01:58 UTC (rev 57224)
+++ trunk/Master/texmf-dist/doc/latex/puyotikz/puyotikz.pdf	2020-12-25 22:03:53 UTC (rev 57225)

Property changes on: trunk/Master/texmf-dist/doc/latex/puyotikz/puyotikz.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/latex/puyotikz/puyotikz.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/puyotikz/puyotikz.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/puyotikz/puyotikz.tex	2020-12-25 22:03:53 UTC (rev 57225)
@@ -0,0 +1,206 @@
+% PuyoTikZ package for LaTeX.
+% Created by amosborne (GitHub) / terramyst (Twitter).
+% MIT License
+
+\documentclass{article}
+\usepackage{puyotikz}
+\usepackage[hidelinks]{hyperref}
+\usepackage{xspace}
+\usepackage{ifmtarg}
+\usepackage{listings}
+\usepackage{graphicx}
+
+\lstset{basicstyle=\footnotesize\ttfamily,%
+	    language=[LaTeX]{TeX},%
+	    commentstyle=\color{darkpurplepuyo},%
+	    tabsize=4
+}
+
+\newcommand{\latex}{\LaTeX\xspace}
+\newcommand{\tex}{\TeX\xspace}
+\newcommand{\parline}{\vspace{\baselineskip}}
+\newcommand{\parlineskip}{\par \parline}
+\newcommand{\link}[2]{\href{#1}{\color{darkbluepuyo}#2}}
+
+\newcommand{\code}[1]{{\small\texttt{#1}}}
+\newcommand{\cmd}[1]{{\small\textbackslash\texttt{#1}}}
+\newcommand{\codepar}[2]{\paragraph{\color{darkgreenpuyo}\code{#1} #2.}\mbox{}\par}
+
+\newcommand{\github}{\link{https://github.com/amosborne/puyotikz}{GitHub}\xspace}
+\newcommand{\python}{\link{https://www.python.org/download/releases/3.0/}{Python3}\xspace}
+\newcommand{\anaconda}{\link{https://www.anaconda.com/products/individual}{Anaconda}\xspace}
+\newcommand{\pypygments}{\link{https://pygments.org/}{Pygments}\xspace}
+\newcommand{\pynumpy}{\link{https://numpy.org/}{Numpy}\xspace}
+\newcommand{\pythontex}{\link{https://ctan.org/pkg/pythontex?lang=en}{Python\tex}\xspace}
+\newcommand{\tikzpgf}{\link{https://ctan.org/pkg/pgf?lang=en}{TikZ}\xspace}
+
+\makeatletter
+\newenvironment{halfpage}[1][]
+	{\noindent\begin{minipage}{0.5\textwidth}\@ifmtarg{#1}{}{\begin{center}\Huge#1\end{center}}}
+	{\end{minipage}}
+\makeatother
+
+\lstnewenvironment{puyolisting}{\parline}{\parline}
+
+\begin{document}
+
+\begin{halfpage}
+	\begin{puyotikz}
+		\puyoboard{rbbggppbgggbr/rbrngbpn/yrynbb/yybrrn/bbpryyn/pbppryn}{rr/gg/yr}
+		\puyomarker{f8rA/f9rA/d7gB/d8gB/e8yC/e9rC}
+	\end{puyotikz}
+\end{halfpage}%
+\begin{halfpage}[PuyoTikZ]
+	A \latex package for quickly typesetting board states of Puyo Puyo games.\parlineskip
+	Supports large and small boards with arbitrary shape, hidden rows, current and next puyos, labels and move planning markers.\parlineskip
+	Source code available for download on \github or your favorite \tex repository. Package requires \python in support of scripts driven by \pythontex.\parlineskip
+	Move planning markers shown at left. Tailing variations on the Great Tanaka Rensa (GTR) shown below.\parlineskip
+	Created by \link{https://twitter.com/terramyst1}{terramyst}.
+\end{halfpage}\\ \\
+
+\noindent\makebox[\textwidth][c]{%
+	\puyogrid[nrows=6, ncols=6]{grr/grg/bgb/pbrg/pbprg/prrgg}%
+	\puyogrid[nrows=6, ncols=6]{grr/grg/bgb/pbrgg/pbrg/rrppg}%
+	\puyogrid[nrows=6, ncols=6]{grr/grg/bgb/pbgg/pbprg/rrrpg}%
+	\puyogrid[nrows=6, ncols=6]{grr/grg/bgb/pbrg/pbrpg/rrgpg}%
+	\puyogrid[nrows=6, ncols=6]{grr/grg/bgb/pbrg/pbrgp/rggrp}%
+}\\
+
+\noindent\makebox[\textwidth][c]{%
+	\puyogrid[nrows=6, ncols=6]{grr/grg/bgb/pbrg/pbprg/rprgg}%
+	\puyogrid[nrows=6, ncols=6]{grr/grg/bgb/pbrg/rbrpg/rppgg}%
+	\puyogrid[nrows=6, ncols=6]{grr/grg/bgb/pbgg/pbgrp/rrrpg}%
+	\puyogrid[nrows=6, ncols=6]{grr/grg/bgb/rbpg/pbprg/rprgg}%
+	\puyogrid[nrows=6, ncols=6]{grr/grg/bgb/gbrg/pbrpg/rrppg}%
+}\\
+		
+\noindent\makebox[\textwidth][c]{%
+	\puyogrid[nrows=6, ncols=6]{grr/grg/bgb/pbpg/rbprg/rprgg}%
+	\puyogrid[nrows=6, ncols=6]{grr/grg/bgb/pbgg/pbrrg/rrppg}%
+	\puyogrid[nrows=6, ncols=6]{grr/grg/bgb/gbpg/pbprg/rrrgp}%
+	\puyogrid[nrows=6, ncols=6]{grr/grg/bgb/pbbg/rggrp/rgrpp}%
+	\puyogrid[nrows=6, ncols=6]{grr/grg/rgb/pbgr/pbgrr/gbgpp}%
+}\\
+
+\noindent\makebox[\textwidth][c]{%
+	\puyogrid[nrows=6, ncols=6]{grr/grg/bgb/pbpg/rbrpg/rrpgg}%
+	\puyogrid[nrows=6, ncols=6]{grr/grg/bgb/pbrg/rbrpg/rppgg}%
+	\puyogrid[nrows=6, ncols=6]{grr/grg/bgb/pbrg/pbprg/prggr}%
+	\puyogrid[nrows=6, ncols=6]{grr/grg/bgb/bbpg/ppgrg/rprrg}%
+	\puyogrid[nrows=6, ncols=6]{grr/grg/bgb/brgp/brrgp/rgppg}%
+}
+
+\section{Installation}
+\subsection{Python3 and PythonTeX}
+Installing this package should be straightforward through the user's \tex package manager. \python will additionally need to be installed; it is recommended to use a virtual environment management tool such as \anaconda. The Python environment will need packages \pypygments and \pynumpy installed.\par
+Compiling the document requires inserting a new command into the build sequence. \pythontex must run \code{pythontex.py} in between two separate runs of the \tex engine (see documentation for more detail).
+
+\section{Usage}
+This package provides an environment and three macros for typesetting Puyo Puyo boards for inclusion in \latex documents.
+
+\codepar{puyotikz}{environment}
+The \code{puyotikz} environment is simply a wrapper for the \code{tikzpicture} environment. The user is therefore able to use additional \tikzpgf macros inside this environment if they wish to augment whatever graphics are already provided by this package.\par
+The \code{puyotikz} environment takes a single numeric argument which is passed to the \code{tikzpicture} environment as the scaling parameter. This package provides two scaling parameter definitions for convenience, \cmd{puyosmallscale} and \cmd{puyobigscale} (the default).
+
+\begin{puyolisting}
+	% example usage
+	\begin{puyotikz}[\puyosmallscale]
+		% content... 
+	\end{puyotikz}
+\end{puyolisting}
+
+For the traditional colors of red, yellow, green, blue, purple, and gray this package also provides new color definitions such as \code{bluepuyo} and \code{darkredpuyo}.
+
+\pagebreak
+\codepar{puyoboard}{macro}
+The \cmd{puyoboard} macro takes 2 arguments and 4 optional parameters and must be used inside the \code{puyotikz} environment.\par
+Puyos are specified in format strings by column (bottom-up, left-to-right). Each puyo is identified by a single letter (\code{r}, \code{y}, \code{g}, \code{b}, \code{p}, \code{n}). Columns (or next puyos) are separated by \code{/}. Columns are labeled numerically and rows and next puyos are labeled alphabetically (lowercase and uppercase, respectively).
+
+\begin{puyolisting}
+	% parameters
+	%	- ncols: number of columns (default 6)
+	%	- nrows: number of visible rows (default 12)
+	%	- nhidrows: number of hidden rows (default 1)
+	%	- showlabels: display coordinate labels (default True)
+	
+	% arguments
+	%	- #1: board format string
+	%	- #2: next puyos format string
+	
+	% example usage (see image below)
+	\begin{puyotikz}
+		\puyoboard[ncols=12, nrows=6, nhidrows=0]
+			{/rr/brbb/ggbg/rrg//yb/ggy}
+			{yy/yr}
+	\end{puyotikz}
+\end{puyolisting}
+
+\begin{center}
+	\begin{puyotikz}
+		\puyoboard[ncols=12, nrows=6, nhidrows=0]
+			{/rr/brbb/ggbg/rrg//yb/ggy}
+			{yy/yr}
+	\end{puyotikz}
+\end{center}
+
+\pagebreak
+\codepar{puyomarker}{macro}
+The \cmd{puyomarker} macro takes 1 argument and must be used inside the \code{puyotikz} environment following a \cmd{puyoboard} macro.
+
+Puyo markers are specified in a single format string, separated by \code{/}. A single marker is a concatenation of the row label (lowercase letter), column label (number), puyo color (lowercase letter) and puyo label (uppercase letter).
+
+\begin{puyolisting}
+	% arguments
+	%	- #1: marker format string
+	
+	% example usage (see image below)
+	\begin{puyotikz}
+		\puyoboard[ncols=12, nrows=6, nhidrows=0]
+			{/rr/brbb/ggbg/rrg//yb/ggy}
+			{yy/yr}
+		\puyomarker{a1yA/a2yA/b3yB/b4rB}
+	\end{puyotikz}
+\end{puyolisting}
+
+\begin{center}
+	\begin{puyotikz}
+		\puyoboard[ncols=12, nrows=6, nhidrows=0]
+			{/rr/brbb/ggbg/rrg//yb/ggy}
+			{yy/yr}
+		\puyomarker{a1yA/a2yA/b3yB/b4rB}
+	\end{puyotikz}
+\end{center}
+
+\pagebreak
+\codepar{puyogrid}{macro}
+The \cmd{puyogrid} macro is provided as an example derived from \cmd{puyoboard}. It assumes a \cmd{puyosmallscale} \code{puyotikz} environment and only provides a single argument for the board format string (assuming no next puyos and no markers). It also assumes zero hidden rows and turns off labeling, however any parameters available to set in \cmd{puyoboard} are also available in \cmd{puyogrid}.\par
+The user is encouraged to construct their own derived macros in similar fashion for their intended purpose.
+
+\begin{puyolisting}
+	% source code \puyogrid definition from puyotikz.sty
+	\newcommand{\puyogrid}[2][]{
+		\setkeys{puyoboard}{nhidrows=0, showlabels=False}
+		\begin{puyotikz}[\puyosmallscale]
+			\puyoboard[#1]{#2}{}
+		\end{puyotikz}
+	}
+
+	% example usage (see image below)
+	\puyogrid[nrows=4, ncols=10]
+		{rrr/yyyr/gggy/bbbg/pppb/rrrp/yyyr/gggy/bbbg/pppb}
+\end{puyolisting}
+
+\begin{center}
+	\puyogrid[nrows=4, ncols=10]{rrr/yyyr/gggy/bbbg/pppb/rrrp/yyyr/gggy/bbbg/pppb}
+\end{center}
+
+\section{Limitations}
+
+\subsection{TikZ}
+The graphics provided in this package are created using \tikzpgf. Having many graphics compiled in a single document will result in a long compilation time.\par
+It is recommended in this case to generate images in separately compiled standalone documents and include them in the main document via \cmd{includegraphics}. \pythontex is not compatible with \cmd{tikzexternalize}.
+
+\subsection{PythonTeX}
+The \pythontex documentation gives a warning which bears repeating: compiling a document that uses \pythontex involves executing Python code on your computer therefore you should only compile documents from sources you trust.
+
+\end{document}


Property changes on: trunk/Master/texmf-dist/doc/latex/puyotikz/puyotikz.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/puyotikz/puyotikz.py
===================================================================
--- trunk/Master/texmf-dist/tex/latex/puyotikz/puyotikz.py	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/puyotikz/puyotikz.py	2020-12-25 22:03:53 UTC (rev 57225)
@@ -0,0 +1,294 @@
+# PuyoTikZ package for LaTeX.
+# Created by amosborne (GitHub) / terramyst (Twitter).
+# MIT License
+
+import numpy as np
+import itertools
+import string
+import re
+
+
+# Wraps a function which returns a string. Prints the result with a ";".
+def print_tikz(func):
+    def wrapper(*args, **kwargs):
+        print(func(*args, **kwargs) + ";")
+
+    return wrapper
+
+
+PUYO_RADIUS, PUYO_JOIN = 0.45, 0.25
+COLORS = {
+    "r": "red",
+    "y": "yellow",
+    "g": "green",
+    "b": "blue",
+    "p": "purple",
+    "n": "gray",
+}
+for key, value in COLORS.items():
+    COLORS[key] = value + "puyo"
+
+
+def puyoboard(cols, rows, hrows, boardpuyos, nextpuyos, label):
+    if not cols > 0:
+        raise UserWarning("{0} columns must be atleast 1.".format(cols))
+    if not rows > 0:
+        raise UserWarning("{0} rows must be atleast 1.".format(rows))
+    if hrows < 0:
+        raise UserWarning("{0} hidden rows must be atleast 0.".format(hrows))
+
+    draw_board(cols, rows, hrows, boardpuyos)
+    draw_nextpuyos(cols, rows, nextpuyos)
+    if label:
+        draw_labels(cols, rows, hrows, nextpuyos)
+
+
+def puyomarker(config):
+    pattern = "^([a-z]+)(\d+)([rygbpn])([A-Z])$"
+
+    @print_tikz
+    def singlemark(subconfig):
+        match = re.search(pattern, subconfig)
+        if match is None:
+            raise UserWarning("Bad puyo marker format string.")
+        else:
+            colid, rowid, puyo, lid = match.groups()
+
+        rowidx = int(rowid) - 1
+        colidx = next(
+            idx for idx, x in enumerate(excel_cols(upper=False)) if x == colid
+        )
+        pos = colidx + 0.5, rowidx + 0.5
+
+        tikz = "\\draw[{0},thick]".format("dark" + COLORS[puyo])
+        tikz += " ({0},{1}) circle ({2});".format(*pos, PUYO_RADIUS)
+        tikz += " \\node[anchor=center, font=\sffamily]"
+        tikz += " at ({0},{1}) {{\\small {2}}}".format(*pos, lid)
+        return tikz
+
+    subconfigs = config.split("/")
+    if subconfigs == [""]:
+        return
+    else:
+        for subconfig in subconfigs:
+            singlemark(subconfig)
+
+
+def draw_board(cols, rows, hrows, boardpuyos):
+    # draw the board grid
+    draw_grid(params=["gray", "ultra thin"], size=(cols, rows))
+    draw_grid(
+        params=["gray", "ultra thin", "line cap=round"],
+        origin=(0, rows),
+        size=(cols, hrows),
+    )
+    draw_grid(
+        params=["black", "line cap=round"], stepsize=(cols, rows), size=(cols, rows)
+    )
+
+    # draw the puyos on the board
+    draw_puyos(puyos=boardpuyos.split("/"), size=(cols, rows), nhidden=hrows)
+
+
+def draw_nextpuyos(cols, rows, nextpuyos):
+    nextpuyos = nextpuyos.split("/")
+    if nextpuyos == [""]:
+        return
+    for idx, puyos in enumerate(nextpuyos):
+        if not len(puyos) == 2:
+            raise UserWarning("Next puyos must be of length 2.")
+        draw_puyos(
+            puyos=[puyos], origin=(cols + 0.75, rows - 1.5 - 3 * idx), size=(1, 2)
+        )
+
+
+def draw_labels(cols, rows, hrows, nextpuyos):
+    @print_tikz
+    def draw_label(pos, text, size="\\normalsize", style="\\rmfamily"):
+        return "\\node[anchor=mid, font={4}] at ({0},{1}) {{{3} {2}}}".format(
+            *pos, text, size, style
+        )
+
+    for idx in range(0, rows + hrows):
+        draw_label((-0.5, 0.5 + idx), idx + 1)
+
+    for idx, label in zip(range(0, cols), excel_cols(upper=False)):
+        draw_label((0.5 + idx, -0.5), label)
+
+    nextpuyoscount = len(nextpuyos.split("/"))
+    if nextpuyos.split("/") == [""]:
+        return
+    for idx, label in zip(range(0, nextpuyoscount), excel_cols(upper=True)):
+        draw_label((cols + 0.75, rows - 1.5 - 3 * idx), label, "\\small", "\\sffamily")
+
+
+ at print_tikz
+def draw_grid(params=[], origin=(0, 0), stepsize=(1, 1), size=(6, 12)):
+    extent = tuple([x + y for x, y in zip(origin, size)])
+    tikz = "\\draw"
+    tikz += "[" + ",".join(params) + "]"
+    tikz += " ({0},{1})".format(*origin)
+    tikz += " grid [xstep={0},ystep={1}]".format(*stepsize)
+    tikz += " ({0},{1})".format(*extent)
+    return tikz
+
+
+def draw_puyos(puyos=[], origin=(0, 0), size=(6, 12), nhidden=0):
+    # construct a 2D matrix of strings (representing puyos)
+    board = np.full((size[0], size[1] + nhidden), "")
+    for ridx, col in enumerate(puyos):
+        for cidx, puyo in enumerate(list(col)):
+            if puyo not in COLORS.keys():
+                raise UserWarning(
+                    "{0} is not a valid puyo identifier (rygbpn).".format(puyo)
+                )
+            try:
+                board[ridx, cidx] = puyo
+            except IndexError:
+                raise UserWarning("Puyo layout string has too many rows or columns.")
+
+    # helper function for converting true position
+    def true_pos(pos):
+        return tuple([x + y + 0.5 for x, y in zip(pos, origin)])
+
+    # draw all the puyo circles
+    for pos, puyo in np.ndenumerate(board):
+        if puyo:
+            draw_puyo(true_pos(pos), puyo)
+
+    # connect to adjacent puyos (except nuisance and hidden row)
+    for pos, puyo in np.ndenumerate(board):
+        for direc in {(1, 0), (-1, 0), (0, 1), (0, -1)}:
+            if not 0 <= pos[0] + direc[0] < board.shape[0]:
+                continue
+            elif not 0 <= pos[1] + direc[1] < board.shape[1] - nhidden:
+                continue
+            elif not 0 <= pos[1] < board.shape[1] - nhidden:
+                continue
+
+            other = board[pos[0] + direc[0], pos[1] + direc[1]]
+            if puyo and other == puyo and puyo != "n":
+                connect_puyo(true_pos(pos), direc, puyo)
+
+    # draw all the puyo faces
+    for pos, puyo in np.ndenumerate(board):
+        if puyo:
+            draw_face(true_pos(pos), puyo)
+
+    # outline the puyos with a darker color
+    for pos, puyo in np.ndenumerate(board):
+        for direc in {(1, 0), (-1, 0), (0, 1), (0, -1)}:
+            if not 0 <= pos[0] + direc[0] < board.shape[0]:
+                if puyo:
+                    outline_puyo(true_pos(pos), direc, puyo, join=False)
+                continue
+            elif not 0 <= pos[1] + direc[1] < board.shape[1] - nhidden:
+                if puyo:
+                    outline_puyo(true_pos(pos), direc, puyo, join=False)
+                continue
+            elif not 0 <= pos[1] < board.shape[1] - nhidden:
+                if puyo:
+                    outline_puyo(true_pos(pos), direc, puyo, join=False)
+                continue
+
+            other = board[pos[0] + direc[0], pos[1] + direc[1]]
+            if puyo and other == puyo and puyo != "n":
+                outline_puyo(true_pos(pos), direc, puyo, join=True)
+            elif puyo:
+                outline_puyo(true_pos(pos), direc, puyo, join=False)
+
+
+ at print_tikz
+def draw_face(pos=(0, 0), puyo="r"):
+    def tikz_shift(shift=(0, 0)):
+        total_shift = pos[0] + shift[0], pos[1] + shift[1]
+        return "[xshift={0}cm,yshift={1}cm]".format(*total_shift)
+
+    tikz = "\\draw[white,semithick]"
+    if puyo == "p":
+        tikz += " ({0}150:{1}) -- ({0}-30:{1});".format(tikz_shift(), PUYO_RADIUS)
+    elif puyo == "r":
+        tikz += " ({0}150:{1}) -- ({0}0,0) -- ({0}30:{1});".format(
+            tikz_shift(), PUYO_RADIUS
+        )
+    elif puyo == "g":
+        tikz += " ({0}-90:{1}) arc (-90:0:{1})".format(
+            tikz_shift((-PUYO_RADIUS, PUYO_RADIUS)), PUYO_RADIUS
+        )
+        tikz += " ({0}-90:{1}) arc (-90:-180:{1});".format(
+            tikz_shift((PUYO_RADIUS, PUYO_RADIUS)), PUYO_RADIUS
+        )
+    elif puyo == "b":
+        tikz += " ({0}180:{1}) -- ({0}90:{2}) -- ({0}0:{1});".format(
+            tikz_shift(), PUYO_RADIUS, PUYO_RADIUS * np.sin(np.deg2rad(30))
+        )
+    elif puyo == "y":
+        tikz += " ({0}150:{1}) -- ({0}30:{1});".format(tikz_shift(), PUYO_RADIUS)
+    elif puyo == "n":
+        tikz += " ({0}210:{1}) -- ({0}-30:{1});".format(tikz_shift(), PUYO_RADIUS)
+    else:
+        tikz = ""
+
+    return tikz
+
+
+ at print_tikz
+def draw_puyo(pos=(0, 0), puyo="r"):
+    tikz = "\\draw[{0},fill={0}]".format(COLORS[puyo])
+    tikz += " ({0},{1}) circle ({2})".format(*pos, PUYO_RADIUS)
+    return tikz
+
+
+ at print_tikz
+def connect_puyo(pos=(0, 0), direc=(1, 0), puyo="r"):
+    phi, join1, join2 = connect_puyo_params(pos, direc)
+    tikz = "\\draw[{0},fill={0}]".format(COLORS[puyo])
+    tikz += " ([xshift={0}cm,yshift={1}cm]".format(*pos)
+    tikz += "{0}:{2}) arc ({0}:{1}:{2})".format(phi - 45, phi + 45, PUYO_RADIUS)
+    tikz += " to[out={0},in={1}] ({2},{3})".format(phi - 45, phi - 180, *join1)
+    tikz += " -- ({0},{1})".format(*join2)
+    tikz += " to[out={0},in={1}] cycle".format(phi - 180, phi + 45)
+    return tikz
+
+
+ at print_tikz
+def outline_puyo(pos=(0, 0), direc=(1, 0), puyo="r", join=False):
+    phi, join1, join2 = connect_puyo_params(pos, direc)
+    tikz = "\\draw[{0}]".format("dark" + COLORS[puyo])
+
+    if join:
+        tikz += " ([xshift={0}cm,yshift={1}cm]".format(*pos)
+        tikz += "{0}:{1})".format(phi + 45, PUYO_RADIUS)
+        tikz += " to[out={0},in={1}] ({2},{3})".format(phi - 45, phi - 180, *join1)
+        tikz += " ({0},{1})".format(*join2)
+        tikz += " to[out={0},in={1}]".format(phi - 180, phi + 45)
+        tikz += " ([xshift={0}cm,yshift={1}cm]".format(*pos)
+        tikz += "{0}:{1})".format(phi - 45, PUYO_RADIUS)
+    else:
+        tikz += " ([xshift={0}cm,yshift={1}cm]".format(*pos)
+        tikz += "{0}:{2}) arc ({0}:{1}:{2})".format(phi - 45, phi + 45, PUYO_RADIUS)
+
+    return tikz
+
+
+def connect_puyo_params(pos, direc):
+    """Determine the path angle and midpoint locations."""
+    phi = np.rad2deg(np.arctan2(direc[1], direc[0])) % 360
+    x, y1, y2 = 0.5, PUYO_JOIN, -PUYO_JOIN
+
+    c, s = np.cos(np.deg2rad(phi)), np.sin(np.deg2rad(-phi))
+    j = np.matrix([[c, s], [-s, c]])
+
+    def rotate_point(y):
+        m = np.dot(j, [x, y])
+        return float(m.T[0]) + pos[0], float(m.T[1]) + pos[1]
+
+    return phi, rotate_point(y1), rotate_point(y2)
+
+
+def excel_cols(upper=True):
+    n = 1
+    letters = string.ascii_uppercase if upper else string.ascii_lowercase
+    while True:
+        yield from ("".join(group) for group in itertools.product(letters, repeat=n))
+        n += 1


Property changes on: trunk/Master/texmf-dist/tex/latex/puyotikz/puyotikz.py
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/puyotikz/puyotikz.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/puyotikz/puyotikz.sty	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/puyotikz/puyotikz.sty	2020-12-25 22:03:53 UTC (rev 57225)
@@ -0,0 +1,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 at key{puyoboard}{ncols}{\def\puyo at ncols{#1}}
+\define at key{puyoboard}{nrows}{\def\puyo at nrows{#1}}
+\define at key{puyoboard}{nhidrows}{\def\puyo at nhidrows{#1}}
+\define at key{puyoboard}{showlabels}{\def\puyo at showlabels{#1}}
+\setkeys{puyoboard}{ncols=6, nrows=12, nhidrows=1, showlabels=True}
+
+\setpythontexcontext{
+	ncols=\puyo at ncols,
+	nrows=\puyo at nrows,
+	nhidrows=\puyo at nhidrows,
+	showlabels=\puyo at 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


Property changes on: trunk/Master/texmf-dist/tex/latex/puyotikz/puyotikz.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/tlpkg/bin/tlpkg-ctan-check
===================================================================
--- trunk/Master/tlpkg/bin/tlpkg-ctan-check	2020-12-25 22:01:58 UTC (rev 57224)
+++ trunk/Master/tlpkg/bin/tlpkg-ctan-check	2020-12-25 22:03:53 UTC (rev 57225)
@@ -629,7 +629,7 @@
     pst2pdf pstool pstricks pstricks-add pstricks_calcnotes pstring
     ptex-base ptex-fontmaps ptex-fonts ptex-manual
     ptex2pdf ptext ptolemaicastronomy ptptex
-    punk punk-latex punknova purifyeps pwebmac pxbase
+    punk punk-latex punknova purifyeps puyotikz pwebmac pxbase
     pxchfon pxcjkcat pxfonts pxgreeks pxjahyper pxjodel
     pxpgfmark pxrubrica pxtatescale pxtxalfa pxufont
     pygmentex python pythonhighlight pythontex

Modified: trunk/Master/tlpkg/libexec/ctan2tds
===================================================================
--- trunk/Master/tlpkg/libexec/ctan2tds	2020-12-25 22:01:58 UTC (rev 57224)
+++ trunk/Master/tlpkg/libexec/ctan2tds	2020-12-25 22:03:53 UTC (rev 57225)
@@ -2115,6 +2115,7 @@
  'ptex-base',	'\.(ini|lib|src)$|(ascii-jplain|kinsoku|ptex).tex$',
  'ptex-manual', 'NULL', # keep ptex-manual.sty in doc
  'punk',        'NULL', # have separate punk-latex
+ 'puyotikz',	'\.py|' . $standardtex,
  'pwebmac',	'pwebmac.tex',
  'qobitree',    'qobitree.tex',
  'r_und_s',     '\.tex|\.sty',

Modified: trunk/Master/tlpkg/tlpsrc/collection-pictures.tlpsrc
===================================================================
--- trunk/Master/tlpkg/tlpsrc/collection-pictures.tlpsrc	2020-12-25 22:01:58 UTC (rev 57224)
+++ trunk/Master/tlpkg/tlpsrc/collection-pictures.tlpsrc	2020-12-25 22:03:53 UTC (rev 57225)
@@ -120,6 +120,7 @@
 depend prerex
 depend productbox
 depend ptolemaicastronomy
+depend puyotikz
 depend pxpgfmark
 depend qcircuit
 depend quantikz

Added: trunk/Master/tlpkg/tlpsrc/puyotikz.tlpsrc
===================================================================


More information about the tex-live-commits mailing list.