Giter Site home page Giter Site logo

tikz-minesweeper's Introduction

Introduction of tikz-minesweeper

Draw a minesweeper board in LaTeX.

Installation

Compilation with VSCode

  • Clone this repository

  • Install VSCode and LaTeX Workshop extension (at least v8.29.0)

  • Compile tikz-minesweeper.dtx in VSCode with recipe Build dtx, and all the steps will be done in one click!

  • Move tikz-minesweeper.sty to TEXMF-LOCAL/tex/latex/tikz-minesweeper

  • Move tikz-minesweeper.pdf to TEXMF-LOCAL/doc/latex/tikz-minesweeper

  • Refresh local database with texhash or mktexlsr (with TeX Live)

Compilation with l3build

  • Clone this repository

  • Run the following commands:

    l3build install --full --texmfhome $TEXMF-LOCAL$
  • Refresh local database with texhash or mktexlsr (with TeX Live)

Using sty releases

  • See GitHub Releases page.

  • Download the latest sty file, and use it for your projects.

Using prebuilt artifacts

  • See GitHub Actions page

  • Click on the latest successful build and download the artifacts

  • Unzip the tds zip and move all things unzipped to TEXMF-LOCAL/

Usage

  • \cell{r}{c}{info}: draw info at (r, c), see here for detailed command discussions.

  • \row{r}{seq: info}: draw a row with a sequence of info according to \cell.

  • \border[[-]tlbr]{r}{c}: draw a border with edge options.

  • \board[[-]tlbrx]{r}{c}: draw a board with border.

  • \abscoord{pos_options}{r}{c}: get the absolute coordination of a cell.

  • \colorcell{color}{seq: coords}: fill an area with up to four colors.

Contribution

  • Issues and PRs are welcomed.

  • LaTeX3 is preferred.

  • VSCode is very recommended for developing.

Copyright and License

  • Copyright (C) 2021-2023 by Tian-Yi Pu, Fei-Yu Xiang and Yao-Yu Zhu

  • This file may be distributed and/or modified under the conditions of the LaTeX Project Public License, either version 1.3 of this license or (at your option) any later version.

  • The latest version of this license is at: http://www.latex-project.org/lppl.txt and version 1.3 or later is part of all distributions of LaTeX version 2005/12/01 or later.

tikz-minesweeper's People

Contributors

putianyi889 avatar t0nyx1ang avatar zhuyaoyu avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

tikz-minesweeper's Issues

Deprecation of \flag, \mine, \cellup, \celldown and \cellnum

As, these commands are rarely used in the documents, we plan to deprecate them in the next release (v0.2.4). To avoid side effects, please used the LaTeX3 version commands instead. These commands are defined as follows for further references:

\flag => \msweeper_flag:
\mine => \msweeper_mine:
\cellup => \msweeper_cellup:
\celldown => \msweeper_celldown:
\cellnum[1] => \msweeper_cellnum:n {#1}

Make sure to enable LaTeX3 environments before you use these commands.

[Bug] board/row/col 传入参数未进行验证

  • board/row/col 目前仅验证了传入参数(行、列)是否为整数的情况,如果使用负数传入参数,绘制图像会不正常,因此需要构造一个参数校验器出来

关于命令的讨论

字符 行为 是否按下 是否已实现 备注
0 数字0 1 ✔️
1 数字1 1 ✔️
2 数字2 1 ✔️
3 数字3 1 ✔️
4 数字4 1 ✔️
5 数字5 1 ✔️
6 数字6 1 ✔️
7 数字7 1 ✔️
8 数字8 1 ✔️
b blue 0 ✔️
c cyan 0 ✔️
e misflag 0 ✔️
f flag 0 ✔️
g green 0 ✔️
m mine 1 ✔️
n blastedmine 1 ✔️
o orange 0 ✔️
r red 0 ✔️
s shademine 0 ✔️
v violet 0 ✔️
y yellow 0 ✔️
- 0 ✔️
? mark 0 ✔️ 可自动实现

滤镜

从绘图角度考虑,每个格子绘制时需要考虑很多独立的条件。

  • 格子是按下还是弹起?按下则中心为(8.5,-8.5),弹起则中心为(8,-8)
  • 格子的内容是什么?
  • 格子是否要上色?

显然单字符命令无法处理这么多复杂的条件,所以必须通过滤镜解决。

  • 按下/弹起滤镜。因为覆盖关系,这个滤镜必须在填充内容之前添加。
  • 上色的滤镜。已经通过\colorcell解决了(0c6344d

Deprecation of \col command

As \col command is rarely used and can be equivalently replaced by \row command, this command will be deprecated in the next release (v0.2.4). Please get ready.

Nightmode 夜间模式

因为夜间模式有时需要文档整体配色配合,就不太方便整合进宏包。这里放一段实现夜间模式的代码,复制粘贴到preamble即可。

\def\theme{1} % 1: nightmode
\ifnum\theme=0
\else\ifnum\theme=1
\color{gray} % doc font color
\pagecolor{black} % doc background color
\hypersetup{linkcolor=teal} % link color
\definecolor{color0}{RGB}{16,16,16}
\definecolor{color1}{RGB}{64,64,255}
\definecolor{color2}{RGB}{64,160,64}
\definecolor{color3}{RGB}{192,0,0}
\definecolor{color4}{RGB}{96,96,192}
\definecolor{color5}{RGB}{192,96,96}
\definecolor{color6}{RGB}{64,160,160}
\definecolor{color7}{RGB}{128,128,128}
\definecolor{color8}{RGB}{48,48,48}
\definecolor{cshade}{RGB}{0,0,0}
\definecolor{cborder}{RGB}{16,16,16}
\definecolor{clight}{RGB}{48,48,48}
\tikzappendtofigurename{night} % appendix to tikzexternalize file names
\fi\fi

效果
image

自定义配色

主要是为了换主题(例如夜间模式)。用\setmscolor{object}{r}{g}{b},其中object就是文档中定义的颜色名称。

或者也可以一步到位直接做\setmstheme{theme},但是需要开发者考虑具体配色。

[Feature Request] 自动更新dtx的checksum

目前的更新代码是拿python写的,不太方便以recipe形式集成到vscode里面,每次还需要新开一个终端出来更新checksum。
如果能直接用内置的texlua就好了~

旗子外观优化

New flag style based on:

<?xml version="1.0" standalone="yes"?>
<svg width="160" height="160" xmlns="http://www.w3.org/2000/svg">
	<rect x="40" y="110" width="80" height="20" fill="#000000" /> <!-- lower base -->
	<rect x="60" y="100" width="40" height="10" fill="#000000" /> <!-- upper base -->
	<rect x="80" y="40" width="10" height="60" fill="#000000" /> <!-- pole -->
	<path d="M 90 30 L 35 57 L 90 84" fill="#ff0000" /> <!-- flag -->
</svg>

宏包目前待解决的问题

  • 为了画图方便,尽可能去除单位(缺省cm),改用scope环境缩放。
  • (接上一条)增加便于像素-格与内置单位转换的命令。
  • 1-8数字矢量化
  • #35
  • 增加半透明的雷(\mineup),爆炸的雷(\mineblast)。原来雷的命令改为\minedown
  • #36
  • 增加\showaxis显示行列标(往图上加注释定位会比较方便)
  • \row命令优化
  • #24

优化border命令

为了接口统一,想把\trborder等命令中的长度参数移除,全部在\board中通过scope移动。

考虑改成\border{xx}的形式也可以。

如果没意见可能最近会先更新这个。

[Enhancement] Rewrite the \colorcell function more clearly

The function of \colorcell is as follows:

\cs_set:Npn \msweeper_colorcell:nn #1#2 {
    \tl_set:Nn \l_tmpa_tl {#2}
    \seq_set_split:NnV \l_tmpa_seq {;} \l_tmpa_tl
    \seq_map_inline:Nn \l_tmpa_seq {
        \tl_set:Nx \l_tmpb_tl {##1}
        \seq_set_split:NnV \l_tmpb_seq {,} \l_tmpb_tl
        \tl_set:Nx \l__ms_width_tl {\seq_item:Nn \l_tmpb_seq {1}}
        \tl_set:Nx \l__ms_height_tl {\seq_item:Nn \l_tmpb_seq {-1}}
        \seq_set_split:NnV \l__ms_width_seq {-} \l__ms_width_tl
        \seq_set_split:NnV \l__ms_height_seq {-} \l__ms_height_tl
        \tl_set:Nx \l__ms_widthx_tl {\seq_item:Nn \l__ms_width_seq {1}}
        \tl_set:Nx \l__ms_widthy_tl {\seq_item:Nn \l__ms_width_seq {-1}}
        \tl_set:Nx \l__ms_heightx_tl {\seq_item:Nn \l__ms_height_seq {1}}
        \tl_set:Nx \l__ms_heighty_tl {\seq_item:Nn \l__ms_height_seq {-1}}
        \int_step_variable:nnNn {\l__ms_widthx_tl} {\l__ms_widthy_tl} \l_tmpc_tl {
            \int_step_variable:nnNn {\l__ms_heightx_tl} {\l__ms_heighty_tl} \l_tmpd_tl {
                \begin{scope}[xshift=\l_tmpd_tl*16,yshift=-\l_tmpc_tl*16]
                    \msweeper_cellcolored:n {#1}
                \end{scope}
            }
        }
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.