Despite the lack of response to my comments I'll post an answer here anyway, as I seem to have a working solution. I'm very tentative about this one, as the packages pstricks
and tikz
are so large that there may well be some other interactions I know nothing about. I have to say that if your objective is the simplicity of plain TeX then using both of these packages at the same time appears to be a recipe for a headache.
The error about the undefined colour macro occurs because tikz redefines the colour commands used by pstricks, so \\color@black
(note the extra \
) gets mapped to \xcolor@{}{}{rgb}{0,0,0}
and \\color@blue
to \xcolor@{}{}{rgb}{0,0,1}
etc.
But neither pstricks
nor tikz
defines an \xcolor@
command, so you get an error.
IMHO the best way to fix this would be not to use tikz here, but since you want to try using both, here is a "reverse-engineered" fix that works at least for this simple example, and might form the base for further development.
\input pstricks
\input tikz
{\catcode`\@=11
\gdef\dec@mma#1,#2,#3{#1 #2 #3}
\gdef\xcolor@#1#2#3#4{\dec@mma#4 set#3color}
}
Lorem
\psset{linecolor=blue}
\pspicture(0,0)(2,1)
\psline{->}(0,0)(2,1)
\endpspicture
Ipsum
\tikzpicture
\path[draw=red] (0,0) -- (1,1) -- (2,1) circle (10pt);
\endtikzpicture
Dolor
\psset{linecolor=black}
\pspicture(0,0)(2,1)
\psline{<-}(0,0)(2,1)
\endpspicture
Adipiscum.
\bye
Notes:
On line 3 above we open a group and set the catcode of "@" to be 11, which makes TeX treat it like an ordinary letter, so we can use it in a control sequence name. On line 4,
we define a "dec@mma" command that takes an argument "{a,b,c}" and produces "a b c". The name is meant to sound like "de-comma". On line 5 we define the missing "xcolor@" command. We define it to expect four arguments. We ignore arguments #1 and #2; we expect #3 to be a colour space name - well actually we expect it to be "rgb" to be honest; and we expect #4 to be three numbers separated by commas. We call "decomma" to get rid of the commas. One line 6 we close the group.
The commands use "gdef" rather than "def" so that they are visible outside the local group.
The only colour space name used by TikZ appears to be "rgb", so we could have written \gdef\xcolor@#1#2#3#4{\dec@mma#4 setrgbcolor}
without loss of function. The other possible colour space names include "gray" and "cmyk", but to support these properly we would need to cope with a variable number of arguments - gray needs just one number, cmyk needs four - which would make things more complicated.
tikz
will work.tikz
has a\RequirePackage{xcolor}
instruction, and includes commands defined inxcolor
, then it will be necessary to patchtikz
to get rid of them. trying to use plain tex instead isn't a solution; it will only make solving the problem more difficult.\\color@black
to\xcolor@...
but never actually defines an\xcolor@
macro for you. Adding something like this directly after\input tikz
appears to do the trick:{\catcode`\@=11 \gdef\d@comma#1,#2,#3{#1 #2 #3} \gdef\xcolor@#1#2#3#4{\d@comma#4 set#3color}}
. Apparently you need\xcolor@
to eat four parms and produce a valid PS color choosing command. But beware that I have no idea what side effects this might have.\\color@black
produces\xcolor@{}{}{rgb}{0,0,0}
and then with my definitions above this is expanded to0 0 0 setrgbcolor
for PostScript. Clearly it could be made much more general...