I thing that most elementary implementation of rotating can be found in OPmac macros. It is based on \pdfsetmatrix, \pdfsave, \pdfrestore from pdftex but other engines can define these commands very simply, see opmac-xetex.tex file, for example.
The main problem is, ta we have to use \pdfsetmatrix{cos\alpha sin\alpha -sin\alpha cos\alpha}, it means that we must to implement a simple calculation of cos, sin, which is not present in the classical TeX. The implementation in the following OPmac macros does an interpolation of value of these functions using table of the values.
\newdimen\tmpdim \newcount\tmpnum
\def\pdfscale#1#2{\pdfsetmatrix{#1 0 0 #2}}
\def\pdfrotate#1{\tmpdim=#1pt
\ifdim\tmpdim=0pt
\else \ifdim\tmpdim=90pt \pdfsetmatrix{0 1 -1 0}%
\else \edef\tmp{#1}\expandafter\pdfrotateA\tmp..\relax
\fi \fi
}
\def\pdfrotateA #1.#2.#3\relax{%
\def\tmp##1.##2\relax {##1}%
\tmpnum=\expandafter \tmp \the\tmpdim \relax % round
\ifdim\tmpdim>0pt \def\tmpa{}\else\def\tmpa{-}\fi % save -
\loop \ifnum\tmpnum<0 \advance\tmpnum by360 \repeat
\loop \ifnum\tmpnum>360 \advance\tmpnum by-360 \repeat
\loop \ifnum\tmpnum>90 \pdfrotate{90}\advance\tmpnum by-90 \repeat
\ifnum\tmpnum=90 \pdfrotate{90}\else
\ifnum\tmpnum>44 \pdfsetmatrix{.7071 .7071 -.7071 .7071}%
\advance\tmpnum by-45 \fi
\ifnum\tmpnum>22 \pdfsetmatrix{.9272 .3746 -.3746 .9272}%
\advance\tmpnum by-22 \fi
\ifnum\tmpnum>0
\pdfsetmatrix{\smallcos \smallsin -\smallsin \smallcos}%
\fi\fi
\if$#2$\else % fraction part
\tmpdim=.01745329pt % \pi/180
\tmpdim=.#2\tmpdim %
\edef\tmp{\expandafter\ignorept\the\tmpdim\space}%
\ifx\tmpa\empty \pdfsetmatrix{1 \tmp -\tmp 1}%
\else \pdfsetmatrix{1 -\tmp \tmp 1}%
\fi\fi
}
\def\smallcos{.\ifcase\tmpnum \or9998\or9994\or9986\or9976\or9962\or9945\or
9925\or9903\or9877\or9848\or9816\or9781\or9744\or9703\or9659\or9613\or
9563\or9511\or9455\or9397\or9336\or9272\fi\space}
\def\smallsin{.\ifcase\tmpnum 0\or0175\or0359\or0523\or0698\or0872\or1045\or
1219\or1391\or1564\or1736\or1908\or2079\or2250\or2419\or2588\or2756\or
2924\or309\or3256\or342\or3584\or3746\fi\space}
Test: \pdfsave\pdfrotate{35}\rlap{don't use La\TeX}\pdfrestore
\bye
If you find something more straightforward, please, show it.
pdfsetmatrix(see pdftex.def) and with dvips postscript instructions like\special{ps: gsave currentpoint currentpoint translate \Grot@angle\GPT@space neg rotate neg exch neg exch translate}(see dvips.def). And naturally you need various commands to calculate the angle etc (see e.g graphics.sty). It is easier to reuse existing code. – Ulrike Fischer Nov 16 '22 at 22:32\specialfor each driver (dvips, dvipdfmx, dvisvg, ...) or back end primitive for pdftex or luatex – David Carlisle Nov 16 '22 at 23:19