As Knuths TeX had no support for colors or pictures, we have to make our own macros for that. The following macros are perhaps a bit simple, but that also means being easy to adapt to different needs and situations.
Images can be placed with an \image{} macro. It can be preceeded with \imageheight or \imagewidth to set dimensions. If a dimension is set to 0pt, the natural size of the image is used. This is very similar to how it's done in Opmac/OpTeX.
\newdimen\imagewidth \imagewidth=0pt % 0pt gives natural size of image
\newdimen\imageheight \imageheight=0pt
\newtoks\imagedir \imagedir{} % Must end with /, e.g. mypics/
\def\image#1{%
\hbox{%
\saveimageresource
\ifdim\imagewidth=0pt \else width\imagewidth\fi
\ifdim\imageheight=0pt \else height\imageheight\fi
{\the\imagedir#1}%
\useimageresource\lastsavedimageresourceindex
}%
}
% Example: {\imageheight=4cm \image{mypicture.png}}
Colors can be set like this:
% Token for \aftergroup to reset color
\def\colorstackpop{\pdfextension colorstack 0 pop}
% Switch to CMYK color in current group. Expects four values between 0 and 1
\def\setcmykcolor#1{%
\pdfextension colorstack 0 push {#1 k #1 K}%
\aftergroup\colorstackpop
}
% Switch to RGB color in current group. Expects three values between 0 and 1
\def\setrgbcolor#1{%
\pdfextension colorstack 0 push {#1 rg #1 RG}%
\aftergroup\colorstackpop
}
% Color names
\def\black{\setcmykcolor{0 0 0 1}}
\def\blue{\setcmykcolor{1 1 0 0}}
\def\red{\setrgbcolor{0.8 0 0}}
% Example: {\blue This is blue text}