summaryrefslogtreecommitdiff
path: root/info/pstricks_calcnotes/Convert_PstricksCode_To_Pdf/convert.tex
blob: a71fc05eac66b350c934327c92d1e14926f1c0a0 (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
161
162
163
164
165
166
167
168
169
170
171
172
\documentclass[11pt,a4paper,oneside]{article}
\usepackage{pdftricks}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcount\Fa\newcount\Fct\newcount\tempA
\def\Factor{\ifnum\Fa=1\relax\else\advance\Fa by -1\multiply\Fct by \Fa\Factor\fi}
\def\FACTORIAL#1{\Fa=#1 \ifnum\Fa=0 \Fct=1\relax\else\Fct=\Fa \Factor\fi\global\tempA=\Fct}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcount\BINOM
\newcount\temp
\newcount\tmp
\def\BINOMIAL#1#2{%
\temp=#1\advance\temp by -#2
\FACTORIAL{#1}
\tmp=\tempA
\FACTORIAL{\temp}
\temp=\tempA
\divide\tmp by \temp
\FACTORIAL{#2}
\temp=\tempA
\divide\tmp by \temp\global\BINOM=\tmp}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\xch{\catcode`\p=12 \catcode`\t=12}\def\ych{\catcode`\p=11 \catcode`\t=11}
\xch \def\dec#1pt{#1}\ych \def\decimal#1{\expandafter\dec \the#1}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newdimen\Xa\newdimen\Yb\newcount\kc
\newdimen\BSTemp
\def\xmult#1{\ifnum\kc<#1\advance\kc by 1\Yb=\decimal\Xa\Yb\xmult{#1}\else\relax\fi}
\def\BERNSTEIN#1#2#3{\Xa=#3pt\kc=0\Yb=1pt\xmult{#1}\kc=0\Xa=-\Xa\advance\Xa by 1pt\xmult{#2}
\BINOMIAL{5}{#1}\global\BSTemp=\BINOM\Yb}

\newdimen\Xrf
\newdimen\Yrf
\newdimen\XoneBST\newdimen\YoneBST
\newdimen\XtwoBST\newdimen\YtwoBST
\newdimen\XBST\newdimen\YBST
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\XoneBC#1{%
\BERNSTEIN{2}{3}{#1}
\Xrf=1.5pt
\XoneBST=\decimal\BSTemp\Xrf
\BERNSTEIN{3}{2}{#1}
\Xrf=3pt
\advance\XoneBST by \decimal\BSTemp\Xrf
\BERNSTEIN{4}{1}{#1}
\Xrf=5pt
\advance\XoneBST by \decimal\BSTemp\Xrf
\BERNSTEIN{5}{0}{#1}
\Xrf=5pt
\advance\XoneBST by \decimal\BSTemp\Xrf
\global\XBST=\XoneBST}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\XtwoBC#1{%
\BERNSTEIN{0}{5}{#1}
\Xrf=5pt
\XtwoBST=\decimal\BSTemp\Xrf
\BERNSTEIN{1}{4}{#1}
\Xrf=5pt
\advance\XtwoBST by \decimal\BSTemp\Xrf
\BERNSTEIN{2}{3}{#1}
\Xrf=3.5pt
\advance\XtwoBST by \decimal\BSTemp\Xrf
\BERNSTEIN{3}{2}{#1}
\Xrf=2pt
\advance\XtwoBST by \decimal\BSTemp\Xrf
\global\XBST=\XtwoBST}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\YoneBC#1#2#3{%
\BERNSTEIN{1}{4}{#1}
\Yrf=1.5pt
\YoneBST=\decimal\BSTemp\Yrf
\BERNSTEIN{2}{3}{#1}
\Yrf=1pt
\Yrf=#2\Yrf
\advance\YoneBST by \decimal\BSTemp\Yrf
\BERNSTEIN{3}{2}{#1}
\Yrf=2pt
\Yrf=#3\Yrf
\advance\YoneBST by \decimal\BSTemp\Yrf
\BERNSTEIN{4}{1}{#1}
\Yrf=1.5pt
\advance\YoneBST by \decimal\BSTemp\Yrf
\global\YBST=\YoneBST}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\YtwoBC#1#2#3{%
\BERNSTEIN{1}{4}{#1}
\Yrf=-1.5pt
\YtwoBST=\decimal\BSTemp\Yrf
\BERNSTEIN{2}{3}{#1}
\Yrf=-1pt
\Yrf=#2\Yrf
\advance\YtwoBST by \decimal\BSTemp\Yrf
\BERNSTEIN{3}{2}{#1}
\Yrf=-2pt
\Yrf=#3\Yrf
\advance\YtwoBST by \decimal\BSTemp\Yrf
\BERNSTEIN{4}{1}{#1}
\Yrf=-1.5pt
\advance\YtwoBST by \decimal\BSTemp\Yrf
\global\YBST=\YtwoBST}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\XoneFive{15*t^2*(1-t)^3+30*t^3*(1-t)^2+25*t^4*(1-t)+5*t^5}
\def\YoneFive#1#2{7.5*t*(1-t)^4+(#1)*10*t^2*(1-t)^3+(#2)*20*t^3*(1-t)^2+7.5*t^4*(1-t)}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\XtwoFive{5*(1-t)^5+25*t*(1-t)^4+35*t^2*(1-t)^3+20*t^3*(1-t)^2}
\def\YtwoFive#1#2{(-7.5)*t*(1-t)^4+(#1)*(-10)*t^2*(1-t)^3+(#2)*(-20)*t^3*(1-t)^2+(-7.5)*t^4*(1-t)}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\NetDrawOne#1#2#3{%
\newdimen\Xsize
\newdimen\Ysize
\newdimen\tempx
\newdimen\tempy
\Xsize=7pt \divide\Xsize by #1
\Ysize=6pt \divide\Ysize by #1
\parametricplot[algebraic,fillstyle=solid,fillcolor=yellow!85,plotpoints=200,linewidth=0.5pt]{0}{1}
{\XoneFive|\YoneFive{#2}{#3}}
\multido{\nz=0.00+0.005}{200}{\XoneBC{\nz}\YoneBC{\nz}{#2}{#3}
\multido{\nx=-1.00+\decimal\Xsize}{#1}
{\tempx=\nx pt\multido{\ny=-3.00+\decimal\Ysize}{#1}
{\tempy=\ny pt\ifdim\YBST<\tempy\relax\else\advance\tempy by \Ysize
 \ifdim\YBST>\tempy\relax\else
 \ifdim\XBST<\tempx\relax\else\advance\tempx by \Xsize
 \ifdim\XBST>\tempx\relax\else\pspolygon[fillstyle=solid,fillcolor=blue!70,linecolor=black,linewidth=0.2pt]
 (\nx,\ny)(\decimal\tempx,\ny)(\decimal\tempx,\decimal\tempy)(\nx,\decimal\tempy)(\nx,\ny)\fi\fi\fi\fi}
}}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\NetDrawTwo#1#2#3{%
\newdimen\Xsize
\newdimen\Ysize
\newdimen\tempx
\newdimen\tempy
\Xsize=7pt \divide\Xsize by #1
\Ysize=6pt \divide\Ysize by #1
\parametricplot[algebraic,fillstyle=solid,fillcolor=yellow!85,plotpoints=200,linewidth=0.5pt]{0}{1}
{\XtwoFive|\YtwoFive{#2}{#3}}
\multido{\nz=0.00+0.005}{200}{\XtwoBC{\nz}\YtwoBC{\nz}{#2}{#3}
\multido{\nx=-1.00+\decimal\Xsize}{#1}
{\tempx=\nx pt\multido{\ny=-3.00+\decimal\Ysize}{#1}
{\tempy=\ny pt\ifdim\YBST<\tempy\relax\else\advance\tempy by \Ysize
 \ifdim\YBST>\tempy\relax\else
 \ifdim\XBST<\tempx\relax\else\advance\tempx by \Xsize
 \ifdim\XBST>\tempx\relax\else\pspolygon[fillstyle=solid,fillcolor=blue!70,linecolor=black,linewidth=0.2pt]
 (\nx,\ny)(\decimal\tempx,\ny)(\decimal\tempx,\decimal\tempy)(\nx,\decimal\tempy)(\nx,\ny)\fi\fi\fi\fi}
}}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\title{Making files \texttt{.ps} from \texttt{PSTricks}}
\begin{document}
\maketitle
\begin{psinputs}
\usepackage{pstricks}
\usepackage[dvips]{geometry}
\usepackage{pst-plot,pst-coil,multido,pst-xkey,pst-node}
\usepackage{calculator}
\usepackage{calculus}
\usepackage{pst-func}
\usepackage{pstricks-add}
\end{psinputs}
\section{Here is the PSTricks code to be converted}
\begin{pdfpic}
\begin{pspicture}(-1,-3)(6,3) \psset{unit=24pt}
\NetDrawOne{54}{1.7}{0.2}
\NetDrawTwo{54}{0.1}{1.8}
\multido{\nx=-1.00+\decimal\Xsize}{55}
{\psline[linewidth=0.2pt](\nx,-3)(\nx,3)}
\multido{\ny=-3.00+\decimal\Ysize}{55}
{\psline[linewidth=0.2pt](-1,\ny)(6,\ny)}
\parametricplot[algebraic,plotpoints=200,linecolor=white,linewidth=0.5pt]{0}{1}{\XoneFive|\YoneFive{1.7}{0.2}}
\parametricplot[algebraic,plotpoints=200,linecolor=white,linewidth=0.5pt]{0}{1}{\XtwoFive|\YtwoFive{0.1}{1.8}}
\end{pspicture}
\end{pdfpic}
\end{document}