forked from stefanbeller/texbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
circlething.tex
135 lines (125 loc) · 3.91 KB
/
circlething.tex
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
%
% circlething.tex
% Copyright 2011, Stefan Beller <[email protected]>
%
% This file is part of texbox.
%
% This program is free software; you can redistribute it and/or modify it
% under the terms of the GNU General Public License as published by the Free
% Software Foundation; either version 2 of the License, or (at your option)
% any later version.
%
% This program is distributed in the hope that it will be useful, but WITHOUT
% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
% more details.
%
% You should have received a copy of the GNU General Public License along with
% this program. If not, see <http://www.gnu.org/licenses/>.
%
% Draws a small circle with configurable inputs and outputs from North, South,
% East and West. Additionally there can be text in the circle.
%
% arguments:
% #1 position as tuple x,y
% #2 name of object
% #3 input directions: N, S, W, E, if small letters add minus sign
% #4 output directions: N, S, W, E
% #5 text
\newcommand{\CIRCLETHING}[5]
{
\path (#1) coordinate (COORDINATE);
\draw (COORDINATE) circle (.1);
\path (COORDINATE) ++( 0, 0.3) coordinate (#2_INN);
\path (COORDINATE) ++( 0,-0.3) coordinate (#2_INS);
\path (COORDINATE) ++(-0.3, 0) coordinate (#2_INW);
\path (COORDINATE) ++( 0.3, 0) coordinate (#2_INE);
\path (#2_INN) coordinate (#2_OUTN);
\path (#2_INS) coordinate (#2_OUTS);
\path (#2_INW) coordinate (#2_OUTW);
\path (#2_INE) coordinate (#2_OUTE);
\path (COORDINATE) ++( 0, 0.1) coordinate (lineN);
\path (COORDINATE) ++( 0, -0.1) coordinate (lineS);
\path (COORDINATE) ++( -0.1, 0) coordinate (lineW);
\path (COORDINATE) ++( 0.1, 0) coordinate (lineE);
\path (COORDINATE) ++( -0.15, 0.2) coordinate (INNW);
\path (COORDINATE) ++( 0.2, 0.15) coordinate (INNE);
\path (COORDINATE) ++( -0.2,-0.15) coordinate (INSW);
\path (COORDINATE) ++( 0.15,-0.2) coordinate (INSE);
\draw (COORDINATE) node[draw=none,fill=none]{ #5 };
\findchars[q]{#3}{N};
\ifnum \theresult>0
\draw [->] (#2_INN) -- (lineN);
\fi
\findchars[q]{#3}{S};
\ifnum \theresult>0
\draw [->] (#2_INS) -- (lineS);
\fi
\findchars[q]{#3}{W};
\ifnum \theresult>0
\draw [->] (#2_INW) -- (lineW);
\fi
\findchars[q]{#3}{E};
\ifnum \theresult>0
\draw [->] (#2_INE) -- (lineE);
\fi
% subtraktion durch kleinbuchstaben
\findchars[q]{#3}{n};
\ifnum \theresult>0
\draw [->] (#2_INN) -- (lineN);
\draw (INNW) node[draw=none,fill=none]{ - };
\fi
\findchars[q]{#3}{s};
\ifnum \theresult>0
\draw [->] (#2_INS) -- (lineS);
\draw (INSE) node[draw=none,fill=none]{ - };
\fi
\findchars[q]{#3}{w};
\ifnum \theresult>0
\draw [->] (#2_INW) -- (lineW);
\draw (INSW) node[draw=none,fill=none]{ - };
\fi
\findchars[q]{#3}{e};
\ifnum \theresult>0
\draw [->] (#2_INE) -- (lineE);
\draw (INNE) node[draw=none,fill=none]{ - };
\fi
\findchars[q]{#4}{N};
\ifnum \theresult>0
\draw [-] (#2_INN) -- (lineN);
\fi
\findchars[q]{#4}{S};
\ifnum \theresult>0
\draw [-] (#2_INS) -- (lineS);
\fi
\findchars[q]{#4}{W};
\ifnum \theresult>0
\draw [-] (#2_INW) -- (lineW);
\fi
\findchars[q]{#4}{E};
\ifnum \theresult>0
\draw [-] (#2_INE) -- (lineE);
\fi
}
% a plus sign
%
% arguments:
% #1 position as tuple x,y
% #2 name of object
% #3 input directions: N, S, W, E, if small letters add minus sign
% #4 output directions: N, S, W, E
\newcommand{\ADD}[4]
{
\CIRCLETHING{#1}{#2}{#3}{#4}{+}
}
% a multiplication sign
%
% arguments:
% #1 position as tuple x,y
% #2 name of object
% #3 input directions: N, S, W, E, if small letters add minus sign
% #4 output directions: N, S, W, E
\newcommand{\MUL}[4]
{
\CIRCLETHING{#1}{#2}{#3}{#4}{$\cdot$}
}