summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/m-pstricks.mkii
blob: bdcf13b24d6f15c9f724b6bc33bd7cc90d3fbacb (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
%D \module
%D   [       file=m-pstricks,
%D        version=1997.01.15,
%D          title=\CONTEXT\ Extra Modules,
%D       subtitle=\PSTRICKS\ Connections,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

% pstricks is not supported in context mkii (it's no problem doing that
% but as we also need to support latex it would become quite messy so for
% context we use metapost and for latex pstricks)

%M \usemodule[pstric]

\letvalue{@unused}\plussixteen
\letvalue{alloc@}\gobblefivearguments

\chardef\oldbarcode\the\catcode`\|  \catcode`\|=12

\def\loadpstrickscolors#1%
  {\pushmacro\dodefinecolor
   \pushmacro\dodefinepalet
   \pushmacro\dodefinecolorgroup
   \def\dodefinecolor[##1][##2]%
     {\doifassignmentelse{##2}
        {\getparameters[pstricks][r=0,g=0,b=0,##2]%
         \expanded{\newrgbcolor{##1}{{\pstricksr} {\pstricksg} {\pstricksb}}}}%
        {}}%
   \def\dodefinepalet     [##1][##2]{}%
   \def\dodefinecolorgroup[##1][##2][##3]{}%
   \writestatus{pstricks}{loading colors from #1}%
   \input #1 \relax
   \popmacro\dodefinecolorgroup
   \popmacro\dodefinepalet
   \popmacro\dodefinecolor}

\doifelse{\jobsuffix}{dvi}
  {\input multido  \relax
   \input pstricks \relax
   \input pst-plot \relax
   \loadpstrickscolors{colo-rgb}}
  {\writestatus{pstricks}{using indirect method; enable write18}}

\catcode`\|=\oldbarcode

\def\loadpstricksmodule[#1]%
  {\chardef\oldbarcode\the\catcode`\|
   \catcode`\|=12
   \readfile{#1}{}{}%
   \catcode`\|=\oldbarcode}

%D The next piece of code is for John Culleton who suggested to
%D handle \PSTRICKS\ in a similar fashion as \METAPOST, i.e.\
%D using a child process. For the moment there is no support
%D for passing environments, so these should be called
%D explicitly inside this environment.

\unprotect

%D \startPSTRICKS[offset=2pt] ... \stopPSTRICKS
%D
%D works in both dvi and pdf mode
%D
%D % \usemodule[pstric]
%D
%D \startPSTRICKS
%D   \pspicture(0,0)(10,10)
%D     \dorecurse{10}{\psline(0,0)(\recurselevel,10)}
%D     \dorecurse{10}{\psline(0,0)(10,\recurselevel)}
%D   \endpspicture
%D \stopPSTRICKS

\def\startPSTRICKS
  {\dosingleempty\dostartPSTRICKS}

% \ifx\startTEXapplication\undefined
%
% \long\def\dostartPSTRICKS[#1]#2\stopPSTRICKS
%   {\doifelse{\jobsuffix}{dvi}
%      {#2}
%      {\bgroup
%       \setbuffer[pstricks]%
%         \usemodule[pstric]%
%         \setbox\scratchbox\hbox{#2}%
%         % There is probably a nicer way to handle this
%         \immediate\openout\scratchwrite=\bufferprefix dim.tmp
%         \immediate\write\scratchwrite{\dimen0=\the\ht\scratchbox}%
%         \immediate\write\scratchwrite{\dimen2=\the\wd\scratchbox}%
%         \immediate\closeout\scratchwrite
%         % Quick and dirty
%         \startTEXpage[#1]\box\scratchbox\stopTEXpage
%       \endbuffer
%       % Here we go!
%       %\immediate\write18{texexec \bufferprefix pstricks.tmp --once --batch}%
%       %\immediate\write18{dvips -G0 -Ppdf \bufferprefix pstricks -o}%
%       %\immediate\write18{ps2pdf  \bufferprefix pstricks.ps \bufferprefix pstricks.pdf}%
%       \executesystemcommand{texexec \bufferprefix pstricks.tmp --once --batch}%
%       \executesystemcommand{dvips -G0 -Ppdf \bufferprefix pstricks -o}%
%       \executesystemcommand{texmfstart pstopdf \bufferprefix pstricks.ps \bufferprefix pstricks.pdf}%
%       % We pick up the dimensions from the scratch file.
%       \readlocfile{\bufferprefix pstricks-dim.tmp}{}{}%
%       % Since the graphic is put on a page (sigh) by dvips/gs
%       % we need to shift it around a bit.
%       \setbox\scratchbox\hbox
%         {\externalfigure[\bufferprefix pstricks.pdf][\c!object=\v!no]}%
%       \setbox\scratchbox\hbox
%         {\lower\ht\scratchbox\hbox{\raise\dimen2\box\scratchbox}}%
%       \wd\scratchbox\dimen0
%       \ht\scratchbox\dimen2
%       \dp\scratchbox\zeropoint
%       \box\scratchbox
%       \egroup}}
%
% \fi

\long\def\dostartPSTRICKS[#1]#2\stopPSTRICKS
  {\doifelse{\jobsuffix}{dvi} % will some day move to app as switch
     {\hbox{#2}}
%      {\startTEXapplication[#1]{\usemodule[pstric]}#2\stopTEXapplication}}
     {\startTEXapplication[#1]{}#2\stopTEXapplication}}

\protect \endinput