summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/rubik/rubikrotation.sty
blob: bbb8d0f1a433864b102399f2a2ed4f8ddae9066e (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
%%
%% This is file `rubikrotation.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% rubikrotation.dtx  (with options: `rubikrotation')
%% 
%% -----------------------------------------------------------------
%%   Authors: RWD Nickalls (dick@nickalls.org)
%%           and Apostolos Syropoulos (asyropoulos@yahoo.com)
%%   Copyright January 2014  RWD Nickalls and A Syropoulos
%% 
%% 
%%   This work may be distributed and/or modified under the
%%   conditions of the LaTeX Project Public License, either
%%   version 1.3c of this license or (at your option) any
%%   later version: <http://www.latex-project.org/lppl.txt>
%% 
%%   This work consists of the files listed in the README file.
%% -----------------------------------------------------------------
%% 
%%   This is a LaTeX/TikZ package for drawing Rubik cubes
%%   Please report errors or suggestions for improvement to
%% 
%%          RWD Nickalls  (dick@nickalls.org)
%%          Apostolos Syropoulos (asyropoulos@yahoo.com)
%% 
%%  This package requires the basic TikZ package to be loaded already
%% ------------------------------------------------------------------

%%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}


\def\RRfileversion{2.0}%
\def\RRfiledate{2014/01/20}%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{rubikrotation}[\RRfiledate\space (v\RRfileversion)]
\@ifpackageloaded{rubikcube}{}{%
   \typeout{---rubikrotation requires the rubikcube package.}%
   }%
\@ifpackageloaded{fancyvrb}{}{%
   \typeout{---rubikrotation requires the fancyvrb package%
       for VerbatimInput{} command.}%
   \RequirePackage{fancyvrb}}
\newcommand{\rubikrotation}{\textsf{rubikrotation}}
{\catcode`\%=12   \global\def\rubikpercentchar{%}}%
\newcommand{\@comment}{\rubikpercentchar\rubikpercentchar\space}%
\newcommand{\@commentone}{\rubikpercentchar}%
%% We need  a simple print command for writing comments to a file.
\newcommand{\@print}[1]{\immediate\write\outfile{#1}}
\newcommand{\rubikperlname}{rubikrotation.pl}
\newcommand{\rubikperlcmd}{perl \rubikperlname}
\typeout{---checking for config file (rubikrotation.cfg)...}
\IfFileExists{rubikrotation.cfg}{%
   \input{rubikrotation.cfg}%
   }{\typeout{---no config file available}%
}%
\typeout{---cleaning file rubikstateNEW.dat}%
\newwrite\outfile%
\immediate\openout\outfile=rubikstateNEW.dat%
\@print{\@comment rubikstateNEW.dat (by TeX)}%
\immediate\closeout\outfile%
\typeout{---creating file rubikstateERRORS.dat}%
\newwrite\outfile%
\immediate\openout\outfile=rubikstateERRORS.dat%
\@print{\@comment rubikstateERRORS.dat}%
\typeout{---checking for Perl script \rubikperlname...}
   \IfFileExists{\rubikperlname}{%
   \typeout{---\rubikperlname\space exists OK}%
   }{\typeout{** ERROR: cannot find Perl program \rubikperlname}%
    \@print{\@comment ** ERROR: cannot find Perl program \rubikperlname}}%
\immediate\closeout\outfile%
\typeout{---setting up newwrite for rubikrotation to use...}%
\newwrite\outfile%
\newcommand{\@openstatefile}{\immediate\openout\outfile=rubikstate.dat}
\newcommand{\@closestatefile}{\immediate\closeout\outfile}
\newcommand{\@printrubikstate}{%
   \@print{up,\Ult,\Umt,\Urt,\Ulm,\Umm,\Urm,\Ulb,\Umb,\Urb}%
   \@print{down,\Dlt,\Dmt,\Drt,\Dlm,\Dmm,\Drm,\Dlb,\Dmb,\Drb}%
   \@print{left,\Llt,\Lmt,\Lrt,\Llm,\Lmm,\Lrm,\Llb,\Lmb,\Lrb}%
   \@print{right,\Rlt,\Rmt,\Rrt,\Rlm,\Rmm,\Rrm,\Rlb,\Rmb,\Rrb}%
   \@print{front,\Flt,\Fmt,\Frt,\Flm,\Fmm,\Frm,\Flb,\Fmb,\Frb}%
   \@print{back,\Blt,\Bmt,\Brt,\Blm,\Bmm,\Brm,\Blb,\Bmb,\Brb}%
   \@print{checkstate}%
}
\newcommand{\RubikRotation}[1]{\IfFileExists{\rubikperlname}{%
   \typeout{---NEW rotation command------------------}%
   \typeout{---command = RubikRotation{#1}}%
   \typeout{---Perl script \rubikperlname\space exists OK}%
   \typeout{---writing current Rubik state to file rubikstate.dat}%
   \@openstatefile% open data file
   \@print{\@comment filename: rubikstate.dat}%
   \@printrubikstate%
   \@print{rotation,#1}%
   \@closestatefile% close data file
   \typeout{---running Perl script}%
   \immediate\write18{\rubikperlcmd}%
   \typeout{---inputting NEW datafile (from Perl)}%
   \input{rubikstateNEW.dat}%
   \typeout{-----------------------------------------}%
 }{\typeout{** ERROR: \rubikperlname\space does not exist}%
}}
\newcommand{\ShowRubikErrors}{%
   \typeout{---ShowRubikErrors: inputting file rubikstateERRORS.dat}%
   \VerbatimInput{rubikstateERRORS.dat}}
\newcommand{\CheckRubikState}{\IfFileExists{\rubikperlname}{%
   \typeout{---NEW check command------------------}%
   \typeout{---command = CheckRubikState}%
   \typeout{---Perl script \rubikperlname\space exists OK}%
   \typeout{---writing current Rubik state to file rubikstate.dat}%
   \@openstatefile% opens data file
   \@print{\@comment filename: rubikstate.dat}%
   \@printrubikstate%
   \@closestatefile% close data file
   \typeout{---running Perl script}%
   \immediate\write18{\rubikperlcmd}%
   \typeout{---inputting NEW datafile (from Perl)}%
   \input{rubikstateNEW.dat}%
   \typeout{-----------------------------------------}%
 }{\typeout{** ERROR: \rubikperlname\space does not exist}%
}}
\newcommand{\SaveRubikState}[1]{%
\typeout{---NEW save command------------------}%
\typeout{---command = SaveRubikState{#1}}%
\typeout{---saving Rubik state data to file #1}%
\immediate\openout\outfile=#1%
\@print{\@comment filename: #1\@commentone}%
\@print{\string\RubikFaceUp%
   {\Ult}{\Umt}{\Urt}{\Ulm}{\Umm}{\Urm}{\Ulb}{\Umb}{\Urb}\@commentone}%
\@print{\string\RubikFaceDown%
   {\Dlt}{\Dmt}{\Drt}{\Dlm}{\Dmm}{\Drm}{\Dlb}{\Dmb}{\Drb}\@commentone}%
\@print{\string\RubikFaceLeft%
   {\Llt}{\Lmt}{\Lrt}{\Llm}{\Lmm}{\Lrm}{\Llb}{\Lmb}{\Lrb}\@commentone}%
\@print{\string\RubikFaceRight%
   {\Rlt}{\Rmt}{\Rrt}{\Rlm}{\Rmm}{\Rrm}{\Rlb}{\Rmb}{\Rrb}\@commentone}%
\@print{\string\RubikFaceFront%
   {\Flt}{\Fmt}{\Frt}{\Flm}{\Fmm}{\Frm}{\Flb}{\Fmb}{\Frb}\@commentone}%
\@print{\string\RubikFaceBack%
   {\Blt}{\Bmt}{\Brt}{\Blm}{\Bmm}{\Brm}{\Blb}{\Bmb}{\Brb}\@commentone}%
\immediate\closeout\outfile%
\typeout{-----------------------------------------}%
}%
\endinput
%%
%% End of file `rubikrotation.sty'.