From 873660d1a83ece926fe7206288dda9c36b349c1b Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 12 Jan 2006 23:46:03 +0000 Subject: generic 1 git-svn-id: svn://tug.org/texlive/trunk@613 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/generic/tex-ps/cmyk-hax.tex | 673 ++++++++++++++++++++++ Master/texmf-dist/tex/generic/tex-ps/epsfx.tex | 412 +++++++++++++ Master/texmf-dist/tex/generic/tex-ps/poligraf.sty | 101 ++++ Master/texmf-dist/tex/generic/tex-ps/trans.tex | 653 +++++++++++++++++++++ 4 files changed, 1839 insertions(+) create mode 100644 Master/texmf-dist/tex/generic/tex-ps/cmyk-hax.tex create mode 100644 Master/texmf-dist/tex/generic/tex-ps/epsfx.tex create mode 100644 Master/texmf-dist/tex/generic/tex-ps/poligraf.sty create mode 100644 Master/texmf-dist/tex/generic/tex-ps/trans.tex (limited to 'Master/texmf-dist/tex/generic/tex-ps') diff --git a/Master/texmf-dist/tex/generic/tex-ps/cmyk-hax.tex b/Master/texmf-dist/tex/generic/tex-ps/cmyk-hax.tex new file mode 100644 index 00000000000..4d397c2f45f --- /dev/null +++ b/Master/texmf-dist/tex/generic/tex-ps/cmyk-hax.tex @@ -0,0 +1,673 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% CMYK-HAX.TEX: +% E This is a set of TeX macros supporting color separation and +% substitution using TeX/PostScript environment. Needs DVIPS and +% COLORDVI from standard DVIPS distribution. +% +% P Zestaw makr TeX-owo-PostScript-owych do tworzenia wyci/ag/ow barwnych +% i podmiany kolor/ow. Wsp/o/lpracuje ze sterownikiem DVIPS +% i zestawem makr COLORDVI (ze standardowej dystrybucji DVIPS-a); +% +% AUTHORS' COORDINATES: +% BOP s.c. +% ul. Piastowska 70, 80-363 Gda\'nsk, Poland +% tel./fax +48 58 553-46-59 +% email: bop@bop.com.pl +% +% VERSION 0.75, 15.06.2000 +% Public domain +% +% HISTORY: +% E version released during the GUST annual meeting Bacho\TeX'95. +% P wersja udost/epniona podczas Bacho\TeX'95. +% VERSION 0.51, 5 V 1995: +% E macro \CMYKinit added (it places necessary def's in a PS prolog). +% P dodane zosta/lo makro inicjalizacyjne `\CMYKinit', +% kt/ore umieszcza w prologu PS u/zywane definicje. +% VERSION 0.52, 27 VI 1995: +% E the `currentpoint' fault in case of empty current path; now `currentpoint' +% is called by the `stopped' command, which makes an error action +% availlable. +% P `currentpoint' generowa/l b/l/ad gdy bie/z/aca /scie/zki by/la pusta; +% obecnie `currentpoint' jest wykonywane przez `stopped', +% co daje mo/zliwo/s/c zareagowania na b/l/ad. +% VERSION 0.53, 23 VII 1996: +% E 1. the constant `epsilon=0.005' entered to do approximed +% color comparations. +% 2. \PSscreen became a \special. +% P 1. wprowadzono sta/l/a `epsilon=0.005', kt/ora jest dok/ladno/sci/a +% por/ownania kolor/ow. +% 2. \PSscreen by/l dot/ad makrem TeX-owym o tre/sci PS-owej +% sensowne jest, aby sta/l si/e \specialem +% VERSION 0.54, 8 XI 1996 r. +% E `show' redefinition allows the text outlining. +% P redefinicja `show' umo/zliwia ju/z dok/ladanie obw/odki do tekst/ow. +% VERSION 0.60, 11 IV 1997: +% E processing of CMYK bitmaps enabled +% P umo/zliwienie przetwarzania bitmap CMYK +% VERSION 0.61, 11.VIII.1997 +% E `adddownstroke' added (stroke under fill) +% P dodano `adddownstroke' (rysowan/a pod fillem) +% VERSION 0.62, 24.IX.1997 +% E `setscreen' gets all parameters +% P `setscreen' zyskuje wszystkie parametry podawane explicite +% nie korzysta si/e z warto/sci `currentscreen' +% VERSION 0.64, 9.VII.1999 +% E bitmap color separation added, delblack (also for imagemask), +% additional 5-th all-white bitmap separation (\BITinit and /to_sep_bitmap true def /hax_sep 4 def) +% additional 6-th all-black bitmap separation (\BITinit and /to_sep_bitmap true def /hax_sep 5 def) +% P do/l/aczono rozbarwianie bitmap, delblack (tak/ze dla imagemask), +% 5. bia/ly wyci/ag z bitmap (\BITinit oraz /to_sep_bitmap true def /hax_sep 4 def) +% 6. czarny wyci/ag z bitmap (\BITinit oraz /to_sep_bitmap true def /hax_sep 5 def) +% VERSION 0.65, 6.VIII.1999 +% E 5-th and 6-th bitmap separation were improved (`pop' added +% in the case of not-dictionary images) +% P poprawka w 5. i 6. wyci/agu bitmap (dodano `pop' w bitmapach +% nies/lownikowych) +% VERSION 0.66, 13.IX.1999 +% E indexed color bitmaps support (for `colormap') +% P obs/luga bitmap paletowych (do `colormap') +% VERSION 0.67, 21.01.2000 +% E support for multisource `colorimage' -- only CMYK separations +% P obs/luga wersji wielo/xr/od/lowej polecenia `colorimage' +% -- na razie tylko CMYK i tylko separacja +% VERSION 0.68, 16.03.2000 +% E \projectCMYK calls setcmykcolor explicite +% P \projectCMYK wywo/luje explicite setcmykcolor +% VERSION 0.70, 27.03.2000 +% E image, colorimage and imagemask operators are transferred to +% their dictionary form and we support them almost completly; +% limitations: we support only bitmaps with +% ImageType = 1, in one of Device Color Spaces, +% when BitsPerComponent = 1 (other values of BitsPerComponent +% we allow for imagemask, of corse, and for DeviceGray model -- +% without color substitution, unfortunately) +% P oparatory image, colorimage oraz imagemask przeniesione do wersji +% s/lownikowej i prawie kompletnie obs/lu/zone; +% ograniczenia: obs/lugujemy tylko bitmapy, dla kt/orych +% ImageType = 1, model barw nale/zy do klasy Device Color Spaces, +% BitsPerComponent = 8 (inne warto/sci BitsPerComponent dopuszczamy +% oczywi/scie dla imagemask oraz w przypadku modelu DeviceGray -- +% wtedy jednak nie potrafimy podmienia/c kolor/ow) +% VERSION 0.71, 10.04.2000 +% E 3 bugs fixed: +% 1) we already support MultipleDataSources in ImageDict +% 2) it was a superfluous pop in merge_multi3 +% 3) 1 level of redefinition setcmykcolor (hax_setcmykcolor) added +% P usuni/eto 3 pluskwy w obs/ludze image: +% 1) ju/z obs/luguje si/e MultipleDataSources w ImageDict +% 2) by/l zb/edny pop w merge_multi3 +% 3) dodano 1 poziom redefinicji setcmykcolor (hax_setcmykcolor) +% VERSION 0.73, 28.04.2000 +% E 1) \sepbitmapfalse turns bitmap separation off, +% \sepbitmaptrue turns bitmap separation on +% 2) missing ImageDict parameter added before ori_image +% P 1) \sepbitmapfalse wy/l/acza rozbarwianie bitmap, +% \sepbitmaptrue przywraca rozbarwianie bitmap +% 2) dodano brakuj/acy parametr ImageDict przed ori_image +% VERSION 0.74, 11.05.2000 +% E Bug in \delblacktrue handling has been fixed; +% the colors created from black with changecolor can be separated now. +% P Poprawiona pluskwa w obs/ludze \delblacktrue; +% mo/zliwe staje si/e rozbarwianie kolor/ow powsta/lych z podmiany +% koloru czarnego. +% VERSION 0.75, 15.06.2000 +% E \convertbitmaptrue turns on conversion of RGB bitmaps to CMYK, +% to allow them to be separated +% \convertbitmapfalse truns conversion off, by default, RGB bitmaps +% are neither converted nor separated +% P \convertbitmaptrue w/l/acza konwersj/e bitmap RGB do modelu CMYK, +% co umo/zliwia ich rozbarwianie +% \convertbitmapfalse wy/l/acza konwersj/e bitmap RGB do modelu CMYK, +% co uniemo/zliwia ich rozbarwianie; domy/slnie bitmapy RGB nie s/a +% ani konwertowane, ani rozbarwiane +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +\edef\slashcatcode {\the\catcode`\/} +\catcode`\/12 +% +\def\CMYKinit {\special {! userdict begin +% +/ori_setcmykcolor where {pop} {/ori_setcmykcolor /setcmykcolor load def} ifelse +/ori_setrgbcolor where {pop} {/ori_setrgbcolor /setrgbcolor load def} ifelse +/ori_setgray where {pop} {/ori_setgray /setgray load def} ifelse +/ori_colorimage where {pop} {/ori_colorimage /colorimage load def} ifelse +/ori_image where {pop} {/ori_image /image load def} ifelse +/ori_imagemask where {pop} {/ori_imagemask /imagemask load def} ifelse +/ori_fill where {pop} {/ori_fill /fill load def} ifelse +/ori_eofill where {pop} {/ori_eofill /eofill load def} ifelse +/ori_stroke where {pop} {/ori_stroke /stroke load def} ifelse +/ori_show where {pop} {/ori_show /show load def} ifelse +/hax_setcmykcolor /ori_setcmykcolor load def +% +/maybe_black { + 4 copy + 1 sub abs epsilon le exch + 0 sub abs epsilon le and exch + 0 sub abs epsilon le and exch + 0 sub abs epsilon le and + /if_delblack exch def +} def +% +/my_fill {userdict begin if_delblack {newpath} {ori_fill} ifelse end} def +/my_eofill {userdict begin if_delblack {newpath} {ori_eofill} ifelse end} def +/my_stroke {userdict begin if_delblack {newpath} {ori_stroke} ifelse end} def +/my_show {userdict begin if_delblack {false charpath currentpoint newpath moveto} {ori_show} ifelse end} def +% +/eofill {userdict begin my_eofill end} def +/fill {userdict begin my_fill end} def +/stroke {userdict begin my_stroke end} def +/show {userdict begin my_show end} def +% +/setcmykcolor {userdict begin + /k_ exch def /y_ exch def /m_ exch def /c_ exch def + c_ m_ y_ k_ hax_setcmykcolor end} def +/setgray {ori_setgray currentcmykcolor setcmykcolor} def +/setrgbcolor {ori_setrgbcolor currentcmykcolor setcmykcolor} def +% +/hax_image { + dup type cvlit /dicttype eq { + /ImageDict exch def + currentcolorspace dup length 1 eq % only Device color spaces + ImageDict /ImageType get 1 eq and {% and ImageType 1 are supported + 0 get + dup /DeviceRGB eq {/ncomp 3 def} if + dup /DeviceGray eq {/ncomp 1 def} if + /DeviceCMYK eq {/ncomp 4 def} if + ImageDict /BitsPerComponent get 8 ne % only gray image separations + /ncomp 1 ne and {/ncomp 0 def} if % allowed if sample is not a byte + } {pop /ncomp 0 def} ifelse + } { + false 1 makeimagedict + } ifelse + ncomp 0 eq {ImageDict ori_image} {hax_image_} ifelse +} def +% +/hax_colorimage { + makeimagedict + hax_image_ +} def +% +/makeimagedict { + dup /ncomp exch def + dup 4 eq {/DeviceCMYK setcolorspace} if + dup 3 eq {/DeviceRGB setcolorspace} if + 1 eq {/DeviceGray setcolorspace} if + /ImageDict 7 dict def ImageDict begin + {/MultipleDataSources true def + ncomp array astore} if % store multi source in array + /DataSource exch def + /ImageMatrix exch def + /BitsPerComponent exch def + /Height exch def + /Width exch def + /Decode [ncomp {0 1} repeat] def + /ImageType 1 def + end +} def +% +/data_str 65532 string def % very long +/data_str_ 8192 string def +/merge_multi4 { + ImageDict /DataSource get aload pop + dup type cvlit /filetype eq { + /fdatsrck exch def + /fdatsrcy exch def + /fdatsrcm exch def + /fdatsrcc exch def + /datasrck {fdatsrck data_str_ readstring pop} def + /datasrcy {fdatsrcy data_str_ readstring pop} def + /datasrcm {fdatsrcm data_str_ readstring pop} def + /datasrcc {fdatsrcc data_str_ readstring pop} def + } { + /datasrck exch def + /datasrcy exch def + /datasrcm exch def + /datasrcc exch def + } ifelse + ImageDict /DataSource { + data_str + 0 datasrcc {3 copy put pop 4 add} forall pop + 1 datasrcm {3 copy put pop 4 add} forall pop + 2 datasrcy {3 copy put pop 4 add} forall pop + 3 datasrck {3 copy put pop 4 add} forall + 3 sub 0 exch getinterval + } put +} def +% +/merge_multi3 { + ImageDict /DataSource get aload pop + dup type cvlit /filetype eq { + /fdatsrcb exch def + /fdatsrcg exch def + /fdatsrcr exch def + /datasrcb {fdatsrcb data_str_ readstring pop} def + /datasrcg {fdatsrcg data_str_ readstring pop} def + /datasrcr {fdatsrcr data_str_ readstring pop} def + } { + /datasrcb exch def + /datasrcg exch def + /datasrcr exch def + } ifelse + ImageDict /DataSource { + data_str + 0 datasrcr {3 copy put pop 3 add} forall pop + 1 datasrcg {3 copy put pop 3 add} forall pop + 2 datasrcb {3 copy put pop 3 add} forall + 2 sub 0 exch getinterval + } put +} def +% +/i_Str 3 string def +/O_Str 4 string def +/UCR {0.5 mul} def +/BG {0.7 mul} def +/min {1 index 1 index le {pop} {exch pop} ifelse} def +/max {1 index 1 index ge {pop} {exch pop} ifelse} def +% +/RGBtoCMYK {% RGB pixel is on the stack + % RGB --> CMYK conversion (Red Book p. 306) + dup 0 get R_scale mul R_shift add /c_i exch def + dup 1 get G_scale mul G_shift add /m_i exch def + 2 get B_scale mul B_shift add /y_i exch def + /k_i c_i m_i y_i min min def + O_Str + dup 0 255 0 c_i k_i UCR sub cvi max min put + dup 1 255 0 m_i k_i UCR sub cvi max min put + dup 2 255 0 y_i k_i UCR sub cvi max min put + dup 3 255 0 k_i BG cvi max min put +} def +% +/RGBtoCMYKfilter { + ImageDict /Decode get aload pop % use Decode for RGB -> CMYK conversion + 2 copy sub /B_scale exch def pop 255 mul 255 exch sub /B_shift exch def + 2 copy sub /G_scale exch def pop 255 mul 255 exch sub /G_shift exch def + 2 copy sub /R_scale exch def pop 255 mul 255 exch sub /R_shift exch def + /rtc_file ImageDict /DataSource get def + ImageDict /DataSource {rtc_file i_Str readstring {RGBtoCMYK} if} + 0 () /SubFileDecode filter put + /DeviceCMYK setcolorspace /ncomp 4 def + ImageDict /Decode [0 1 0 1 0 1 0 1] put +} def +% +/sep_str 8192 string def +/SEP_CMYK { + 0 + hax_sep 4 3 index length 1 sub { + 2 index exch get + 3 copy put pop + 1 add + } for + dup 0 ne {0 exch getinterval}{pop pop ()} ifelse +} def +% +/SEPfilters { + ncomp 4 eq { + hax_sep 3 le { + /sepproc /SEP_CMYK load def + ImageDict begin /Decode [ + Decode hax_sep 2 mul 1 add get + Decode hax_sep 2 mul get + ] def end + } { + /sepproc {dup length 4 idiv 0 exch getinterval} def + } ifelse + /sep_file ImageDict /DataSource get def + ImageDict /DataSource {sep_file sep_str readstring pop sepproc} 0 () + /SubFileDecode filter put + /DeviceGray setcolorspace + } {% ncomp 1 eq + hax_sep 3 ne {ImageDict /Decode [ 1 1 ] put} if + } ifelse + hax_sep 4 eq {ImageDict /Decode [ 1 1 ] put} if + hax_sep 5 eq {ImageDict /Decode [ 0 0 ] put} if +} def +% +/change_str 12288 string def % must be a multiplicity of 3 and 4 +/CHANGEfilter { + /change_file ImageDict /DataSource get def + ImageDict /DataSource { + change_file change_str readstring pop + 0 ncomp 2 index length ncomp sub { + 1 index exch 2 copy ncomp + getinterval changebits putinterval + } for + } 0 () /SubFileDecode filter put +} def +% +/hax_image_ { + ImageDict /MultipleDataSources known { + ImageDict /MultipleDataSources get { + ImageDict /MultipleDataSources false put + ImageDict /DataSource get length + dup 4 eq {merge_multi4} if + dup 3 eq {merge_multi3} if + 1 eq {ImageDict begin /DataSource DataSource aload pop def end} if + } if + } if + ImageDict begin + /DataSource dup load Width BitsPerComponent mul 7 add 8 idiv + Height ncomp mul mul () /SubFileDecode filter def + end + to_change_bitmap {CHANGEfilter} if + ncomp 3 eq to_convert_bitmap and {RGBtoCMYKfilter} if + ncomp 3 ne to_sep_bitmap and {SEPfilters} if + ImageDict ori_image +} def +% +/zero_data_str 65532 string def % length of the data_str +/hax_imagemask { + if_delblack { + dup type cvlit /dicttype eq { + /ImageDict exch def + } { + /ImageDict 7 dict def ImageDict begin + /DataSource exch def + /ImageMatrix exch def + /Decode exch {[1 0]} {[0 1]} ifelse def + /Height exch def + /Width exch def + /BitsPerComponent 1 def + /ImageType 1 def + end + } ifelse + ImageDict begin + /DataSource load Width 7 add 8 idiv Height mul + () /SubFileDecode filter + end /mask_file exch def + ImageDict /DataSource { + zero_data_str 0 mask_file data_str readstring pop length getinterval + } 0 () /SubFileDecode filter put + ImageDict /Decode [1 0] put + ImageDict ori_imagemask + } {ori_imagemask} ifelse +} def +% +/truebp {0 matrix defaultmatrix matrix currentmatrix + matrix invertmatrix matrix concatmatrix dtransform + dup mul exch dup mul add sqrt} def +/truein {72 mul truebp} def +/truept {72.27 div truein} def +/truesp {65536 div truept} def +/truedd {1238 mul 1157 div truept} def +/truecc {12 mul truedd} def +/truemm {25.4 div truein} def +/truecm {10 mul truemm} def +% +/epsilon 0.005 def +/if_delblack false def +/to_change_bitmap false def +/to_convert_bitmap false def +/to_sep_bitmap false def +% +currentcmykcolor setcmykcolor +% +end % userdict +}}% \special \CMYKinit +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\def\PSbegingroup {\begingroup \special{ps: save }} +\def\PSendgroup {\special{ps: restore }\endgroup} +% +\def\forcolor #1{\def\thecolor{#1}} +\def\checkcolor {\thecolor\space count 4 lt {(Not CMYK ) print} if +% k_ eq exch y_ eq and exch m_ eq and exch c_ eq and +% comparison of colours with a predefined accurracy (epsilon): + k_ sub abs epsilon le exch + y_ sub abs epsilon le and exch + m_ sub abs epsilon le and exch + c_ sub abs epsilon le and } +% +\def\changefill #1{% + \edef\changefills{\changefills \checkcolor + {#1 hax_setcmykcolor} if }} +\def\changestroke #1{% + \edef\changestrokes{\changestrokes \checkcolor + {#1 hax_setcmykcolor} if }} +\def\changecolor #1{% + \edef\changecolors{\changecolors \checkcolor + {#1 hax_setcmykcolor} if }} +\def\addfill #1{% + \edef\addfills{\addfills \checkcolor {addfill} if }% + \edef\changefills{\changefills \checkcolor + {#1 hax_setcmykcolor} if }} +\def\adddownstroke #1{% + \edef\addstrokes{\addstrokes \checkcolor {adddownstroke} if }% + \edef\changestrokes{\changestrokes \checkcolor + {#1 hax_setcmykcolor} if }} +\def\addstroke #1{% + \edef\addstrokes{\addstrokes \checkcolor {addstroke} if }% + \edef\changestrokes{\changestrokes \checkcolor + {#1 hax_setcmykcolor} if }} +\def\addcolor #1{\addstroke{#1}\addfill{#1}} +\def\delfill {% + \edef\delfills{\delfills \checkcolor {delfill} if }} +\def\delstroke {% + \edef\delstrokes{\delstrokes \checkcolor {delstroke} if }} +\def\delcolor {% + \edef\delcolors{\delcolors \checkcolor {delfill delstroke} if }} +\def\strokehook #1{% + \edef\strokehooks{\strokehooks \checkcolor {#1} if }} +\def\fillhook #1{% + \edef\fillhooks{\fillhooks \checkcolor {#1} if }} +\def\strokeup {% + \edef\changestrokes{\changestrokes \checkcolor {upstroke} if }} +\def\fillup {% + \edef\changestrokes{\changestrokes \checkcolor {upfill} if }} +% +\def\forbitmap #1{\def\thebitcolor{<#1>}} +\def\checkbitcolor {dup \thebitcolor\space eq } +% +\def\changebitmap #1{% + \edef\changebits{\changebits \checkbitcolor {pop <#1>} if }} +% +\def\setCMYKchange{% + \edef\changestrokes{}% + \edef\changefills{}% + \edef\changecolors{}% + \edef\addstrokes{}% + \edef\addfills{}% + \edef\delstrokes{}% + \edef\delfills{}% + \edef\delcolors{}% + \edef\strokehooks{}% + \edef\fillhooks{}% + \edef\changebits{}% +} +% +\def\fillinitials{% + /to_fill true def + /to_stroke false def + /to_upstroke false def +} +\def\strokeinitials{% + /to_fill false def + /to_stroke true def + /to_upstroke true def +} +% +\def\useCMYKchange{% + \special{ps: + userdict begin + /addfill {/to_fill true def} def + /delfill {/to_fill false def} def + /upfill {/to_upstroke false def} def + /addstroke {/to_stroke true def upstroke} def + /adddownstroke {/to_stroke true def upfill} def + /delstroke {/to_stroke false def} def + /upstroke {/to_upstroke true def} def + /current_point {{currentpoint} stopped {0 0} if} def + % + /do_stroke { + to_stroke {gsave \changestrokes \strokehooks my_stroke grestore} if + } def + % + /eofill { + userdict begin + \fillinitials \delfills \delcolors \addstrokes + current_point + to_upstroke {} {do_stroke} ifelse + to_fill {gsave \changefills \fillhooks my_eofill grestore} if + to_upstroke {do_stroke} if + newpath moveto + end + } def + % + /fill { + userdict begin + \fillinitials \delfills \delcolors \addstrokes + current_point + to_upstroke {} {do_stroke} ifelse + to_fill {gsave \changefills \fillhooks my_fill grestore} if + to_upstroke {do_stroke} if + newpath moveto + end + } def + % + /stroke { + userdict begin + \strokeinitials \delstrokes \delcolors \addfills + current_point + to_upstroke {} {do_stroke} ifelse + to_fill {gsave \changefills \fillhooks my_eofill grestore} if + to_upstroke {do_stroke} if + newpath moveto + end + } def + % + /show { + userdict begin + \fillinitials \delfills \delcolors \addstrokes + to_upstroke {} {dup false gsave charpath do_stroke grestore} ifelse + to_fill {dup gsave my_show grestore} {} ifelse + to_upstroke {dup false gsave charpath do_stroke grestore} if + false charpath current_point newpath moveto + end + } def + % + /setcmykcolor { + userdict begin + /k_ exch def /y_ exch def /m_ exch def /c_ exch def + c_ m_ y_ k_ hax_setcmykcolor \changecolors + end + } def + % + currentcmykcolor setcmykcolor + end}% + \ifx\changebits\empty\else + \BITinit + \special{ps: + userdict begin + /to_change_bitmap true def + /changebits {\changebits} def + end}% + \fi +} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\def\cyan {1 0 0 0} +\def\magenta {0 1 0 0} +\def\yellow {0 0 1 0} +\def\black {0 0 0 1} +\def\white {0 0 0 0} +% +\def\ScreenFrequency {150} +\def\Cangle {15} +\def\Mangle {75} +\def\Yangle {0} +\def\Kangle {45} +% +\def\PSscreen #1{\ifx\ScreenFrequency\empty + \special{ps: currentscreen exch pop #1 exch setscreen}% + \else + \special{ps: + /dot_spot {dup mul exch dup mul add 1 exch sub 2 div} def + \ScreenFrequency\space #1 {dot_spot} setscreen + }\fi} +% +\newif\ifdelblack \delblackfalse +\newif\ifbitmapsep \bitmapseptrue +% +\def\sepbitmaptrue{% + \bitmapseptrue + \BITinit + \special{ps: + userdict begin + /to_sep_bitmap true def + end}} +% +\def\sepbitmapfalse{% + \bitmapsepfalse + \special{ps: + userdict begin + /to_sep_bitmap false def + end}} +% +\def\convertbitmaptrue{% + \BITinit + \special{ps: + userdict begin + /to_convert_bitmap true def + end}} +% +\def\convertbitmapfalse{% + \special{ps: + userdict begin + /to_convert_bitmap false def + end}} +% +\def\BITinit{\special{ps: + userdict begin + /image /hax_image load def + /colorimage /hax_colorimage load def + /imagemask /hax_imagemask load def + end}} +% +\def\projectCMYK #1{% + \edef\projectcolor{#1}% + \ifx\projectcolor\cyan + \special{ps: + userdict begin + /hax_sep 0 def + /hax_setcmykcolor {\ifdelblack maybe_black \fi pop pop pop 1 exch sub ori_setgray} def + end + }% + \PSscreen\Cangle + \else \ifx\projectcolor\magenta + \special{ps: + userdict begin + /hax_sep 1 def + /hax_setcmykcolor {\ifdelblack maybe_black \fi pop pop exch pop 1 exch sub ori_setgray} def + end + }% + \PSscreen\Mangle + \else \ifx\projectcolor\yellow + \special{ps: + userdict begin + /hax_sep 2 def + /hax_setcmykcolor {\ifdelblack maybe_black \fi pop exch pop exch pop 1 exch sub ori_setgray} def + end + }% + \PSscreen\Yangle + \else \ifx\projectcolor\black + \special{ps: + userdict begin + /hax_sep 3 def + /hax_setcmykcolor {exch pop exch pop exch pop 1 exch sub ori_setgray} def + end + }% + \PSscreen\Kangle + \fi \fi \fi \fi + \ifbitmapsep\sepbitmaptrue\fi + \special{ps: currentcmykcolor setcmykcolor}% +} +% +\def\CMYKlabels #1{{#1% #1 is a font csname + \Cyan{CYAN} + \Magenta{MAGENTA} + \Yellow{YELLOW} + \Black{BLACK}}} +% +\ifx\notCMYKinit\undefined\CMYKinit\fi +% +\catcode`\/\slashcatcode +% +\endinput diff --git a/Master/texmf-dist/tex/generic/tex-ps/epsfx.tex b/Master/texmf-dist/tex/generic/tex-ps/epsfx.tex new file mode 100644 index 00000000000..88d8e4cd948 --- /dev/null +++ b/Master/texmf-dist/tex/generic/tex-ps/epsfx.tex @@ -0,0 +1,412 @@ +%-------------------------------------------------------------------------- +% This is small extension of T. Rokicki's EPSF.TEX (from DVIPS 5.58): +% -- allows safe including of EPS files generated by DVIPS +% -- can also display bounding boxes. +%-------------------------------------------------------------------------- +% AUTHORS: Bogus\l{}aw Jackowski and Piotr Pianowski +% BOP s.c. +% ul. Piastowska 70, 80-363 Gda\'nsk, Poland +% email: B.Jackowski@GUST.org.pl +% USAGE: +% \eps{file.eps} % instead of \epsffile{file.eps} +% The following settings of the parameter \tracingeps are recognized: +% \tracingeps=0 % default, no extra information displayed +% \tracingeps=1 % displays bounding boxes and file names +% \tracingeps>1 % displays graphics, bounding boxes and file names +% HISTORY: +% ver. 0.5 19 VIII 1994 +% ver. 0.51 25 VIII 1994 +% * \epsnamecolor added +% ver. 0.52 31 VIII 1994 +% * \eps renamed to \epsraw +% * \tps renamed to \eps +% ver. 0.53 9 I 1995 +% * `\isls false N' added to \eps +% * virtually active slash neutralized +% ver. 0.54 9 III 1995 +% * \eps clears bop-hook +% ver. 0.55 27 III 1995 +% * a patch neutralizing unnecessary rounding added +% ver. 0.56 3 X 1995 +% * \special commands surrounding EPS box are to be nested in the \vbox +% ver. 0.57 31 VIII 1996 +% * odd characters in names enabled +% ver. 0.58 21 III 1997 +% * setpageparams and setpage neutralized +% ver. 0.585 25 III 1997 +% * comments touched +% ver. 0.59 7 VI 1998 +% * EPSF.TEX included +% ver. 0.60 10 I 1999 +% * safe multiplication of eps dimensions by 10 (expected to be +% included in the newest version of Rokicki's package) +% ver. 0.61 29 III 2000 +% * \eps expands to \hbox +% ver. 0.62 13 (Friday) VII 2001 +% * setpagedevice neutralized (why only now?) along with a bundle of +% commands specifying paper size (a0, a1, ... , b0, b1, ... , etc.) +%-------------------------------------------------------------------------- +\edef\slashcatcode{\the\catcode`\/} +\catcode`\/12 +% +%%%%%%%%%%%%%%%%%%%%%%%%%%% \input epsf -- inserted below %%%%%%%%%%%%%%%%% +% EPSF.TEX macro file: +% Written by Tomas Rokicki of Radical Eye Software, 29 Mar 1989. +% Revised by Don Knuth, 3 Jan 1990. +% Revised by Tomas Rokicki to accept bounding boxes with no +% space after the colon, 18 Jul 1990. +% +% TeX macros to include an Encapsulated PostScript graphic. +% Works by finding the bounding box comment, +% calculating the correct scale values, and inserting a vbox +% of the appropriate size at the current position in the TeX document. +% +% To use with the center environment of LaTeX, preface the \epsffile +% call with a \leavevmode. (LaTeX should probably supply this itself +% for the center environment.) +% +% To use, simply say +% \input epsf % somewhere early on in your TeX file +% \epsfbox{filename.ps} % where you want to insert a vbox for a figure +% +% Alternatively, you can type +% +% \epsfbox[0 0 30 50]{filename.ps} % to supply your own BB +% +% which will not read in the file, and will instead use the bounding +% box you specify. +% +% The effect will be to typeset the figure as a TeX box, at the +% point of your \epsfbox command. By default, the graphic will have its +% `natural' width (namely the width of its bounding box, as described +% in filename.ps). The TeX box will have depth zero. +% +% You can enlarge or reduce the figure by saying +% \epsfxsize= \epsfbox{filename.ps} +% (or +% \epsfysize= \epsfbox{filename.ps}) +% instead. Then the width of the TeX box will be \epsfxsize and its +% height will be scaled proportionately (or the height will be +% \epsfysize and its width will be scaled proportiontally). The +% width (and height) is restored to zero after each use. +% +% A more general facility for sizing is available by defining the +% \epsfsize macro. Normally you can redefine this macro +% to do almost anything. The first parameter is the natural x size of +% the PostScript graphic, the second parameter is the natural y size +% of the PostScript graphic. It must return the xsize to use, or 0 if +% natural scaling is to be used. Common uses include: +% +% \epsfxsize % just leave the old value alone +% 0pt % use the natural sizes +% #1 % use the natural sizes +% \hsize % scale to full width +% 0.5#1 % scale to 50% of natural size +% \ifnum#1>\hsize\hsize\else#1\fi % smaller of natural, hsize +% +% If you want TeX to report the size of the figure (as a message +% on your terminal when it processes each figure), say `\epsfverbosetrue'. +% +\newread\epsffilein % file to \read +\newif\ifepsffileok % continue looking for the bounding box? +\newif\ifepsfbbfound % success? +\newif\ifepsfverbose % report what you're making? +\newif\ifepsfdraft % use draft mode? +\newdimen\epsfxsize % horizontal size after scaling +\newdimen\epsfysize % vertical size after scaling +\newdimen\epsftsize % horizontal size before scaling +\newdimen\epsfrsize % vertical size before scaling +\newdimen\epsftmp % register for arithmetic manipulation +\newdimen\pspoints % conversion factor +% +\pspoints=1bp % Adobe points are `big' +\epsfxsize=0pt % Default value, means `use natural size' +\epsfysize=0pt % ditto +% +\def\epsfbox#1{\global\def\epsfllx{72}\global\def\epsflly{72}% + \global\def\epsfurx{540}\global\def\epsfury{720}% + \def\lbracket{[}\def\testit{#1}\ifx\testit\lbracket + \let\next=\epsfgetlitbb\else\let\next=\epsfnormal\fi\next{#1}}% +% +\def\epsfgetlitbb#1#2 #3 #4 #5]#6{\epsfgrab #2 #3 #4 #5 .\\% + \epsfsetgraph{#6}}% +% +\def\epsfnormal#1{\epsfgetbb{#1}\epsfsetgraph{#1}}% +% +\def\epsfgetbb#1{% +% +% The first thing we need to do is to open the +% PostScript file, if possible. +% +\openin\epsffilein=#1 +\ifeof\epsffilein\errmessage{I couldn't open #1, will ignore it}\else +% +% Okay, we got it. Now we'll scan lines until we find one that doesn't +% start with %. We're looking for the bounding box comment. +% + {\epsffileoktrue \chardef\other=12 + \def\do##1{\catcode`##1=\other}\dospecials \catcode`\ =10 + \loop + \read\epsffilein to \epsffileline + \ifeof\epsffilein\epsffileokfalse\else +% +% We check to see if the first character is a % sign; +% if not, we stop reading (unless the line was entirely blank); +% if so, we look further and stop only if the line begins with +% `%%BoundingBox:'. +% + \expandafter\epsfaux\epsffileline:. \\% + \fi + \ifepsffileok\repeat + \ifepsfbbfound\else + \ifepsfverbose\message{No bounding box comment in #1; using defaults}\fi\fi + }\closein\epsffilein\fi}% +% +% Now we have to calculate the scale and offset values to use. +% First we compute the natural sizes. +% +\def\epsfclipon{\def\epsfclipstring{ clip}}% +\def\epsfclipoff{\def\epsfclipstring{\ifepsfdraft\space clip\fi}}% +\epsfclipoff +% +\def\epsfsetgraph#1{% + \epsfrsize=\epsfury\pspoints + \advance\epsfrsize by-\epsflly\pspoints + \epsftsize=\epsfurx\pspoints + \advance\epsftsize by-\epsfllx\pspoints +% +% If `epsfxsize' is 0, we default to the natural size of the picture. +% Otherwise we scale the graph to be \epsfxsize wide. +% + \epsfxsize\epsfsize\epsftsize\epsfrsize + \ifnum\epsfxsize=0 \ifnum\epsfysize=0 + \epsfxsize=\epsftsize \epsfysize=\epsfrsize + \epsfrsize=0pt +% +% We have a sticky problem here: TeX doesn't do floating point arithmetic! +% Our goal is to compute y = rx/t. The following loop does this reasonably +% fast, with an error of at most about 16 sp (about 1/4000 pt). +% + \else\epsftmp=\epsftsize \divide\epsftmp\epsfrsize + \epsfxsize=\epsfysize \multiply\epsfxsize\epsftmp + \multiply\epsftmp\epsfrsize \advance\epsftsize-\epsftmp + \epsftmp=\epsfysize + \loop \advance\epsftsize\epsftsize \divide\epsftmp 2 + \ifnum\epsftmp>0 + \ifnum\epsftsize<\epsfrsize\else + \advance\epsftsize-\epsfrsize \advance\epsfxsize\epsftmp \fi + \repeat + \epsfrsize=0pt + \fi + \else \ifnum\epsfysize=0 + \epsftmp=\epsfrsize \divide\epsftmp\epsftsize + \epsfysize=\epsfxsize \multiply\epsfysize\epsftmp + \multiply\epsftmp\epsftsize \advance\epsfrsize-\epsftmp + \epsftmp=\epsfxsize + \loop \advance\epsfrsize\epsfrsize \divide\epsftmp 2 + \ifnum\epsftmp>0 + \ifnum\epsfrsize<\epsftsize\else + \advance\epsfrsize-\epsftsize \advance\epsfysize\epsftmp \fi + \repeat + \epsfrsize=0pt + \else + \epsfrsize=\epsfysize + \fi + \fi +% +% Finally, we make the vbox and stick in a \special that dvips can parse. +% + \ifepsfverbose\message{#1: width=\the\epsfxsize, height=\the\epsfysize}\fi + \epsftmp=10\epsfxsize \divide\epsftmp\pspoints + \vbox to\epsfysize{\vfil\hbox to\epsfxsize{% + \ifnum\epsfrsize=0\relax + \special{PSfile=\ifepsfdraft psdraft.ps\else#1\fi\space + llx=\epsfllx\space lly=\epsflly\space + urx=\epsfurx\space ury=\epsfury\space rwi=\number\epsftmp + \epsfclipstring}% + \else + \epsfrsize=10\epsfysize \divide\epsfrsize\pspoints + \special{PSfile=\ifepsfdraft psdraft.ps\else#1\fi\space + llx=\epsfllx\space lly=\epsflly\space + urx=\epsfurx\space ury=\epsfury\space rwi=\number\epsftmp\space + rhi=\number\epsfrsize \epsfclipstring}% + \fi + \hfil}}% +\global\epsfxsize=0pt\global\epsfysize=0pt}% +% +% We still need to define the tricky \epsfaux macro. This requires +% a couple of magic constants for comparison purposes. +% +{\catcode`\%=12 \global\let\epsfpercent=%\global\def\epsfbblit{%BoundingBox}}% +% +% So we're ready to check for `%BoundingBox:' and to grab the +% values if they are found. +% +\long\def\epsfaux#1#2:#3\\{\ifx#1\epsfpercent + \def\testit{#2}\ifx\testit\epsfbblit + \epsfgrab #3 . . . \\% + \epsffileokfalse + \global\epsfbbfoundtrue + \fi\else\ifx#1\par\else\epsffileokfalse\fi\fi}% +% +% Here we grab the values and stuff them in the appropriate definitions. +% +\def\epsfempty{}% +\def\epsfgrab #1 #2 #3 #4 #5\\{% +\global\def\epsfllx{#1}\ifx\epsfllx\epsfempty + \epsfgrab #2 #3 #4 #5 .\\\else + \global\def\epsflly{#2}% + \global\def\epsfurx{#3}\global\def\epsfury{#4}\fi}% +% +% We default the epsfsize macro. +% +\def\epsfsize#1#2{\epsfxsize} +% +% Finally, another definition for compatibility with older macros. +% +\let\epsffile=\epsfbox +%%%%%%%%%%%%%%%%%%%%%%%%%%%%% End of EPSF %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% --- +\newcount\tracingeps \tracingeps0 +% --- +\newbox\tmpepsbox +% --- +\ifx\epsdirundefined\epsdir\def\epsdir{}\fi +\def\epsnamecolor{1 0 0} +% --- +% BOTH \eps and \epsraw ``normalize'' the eps name, as one may wish +% to use \epsraw separately +% --- +\def\epsraw{\begingroup\escapechar-1\catcode`\%12\def~{\string~}\epsrawcont} +\def\epsrawcont#1{% + \xdef\theepsname{\expandafter\string\csname#1\endcsname}\endgroup + \ifnum\tracingeps=0 \hbox{\epsffile{\epsdir\theepsname}}\fi + \ifnum\tracingeps>0 + \hbox{\setbox\tmpepsbox\hbox{\epsffile{\epsdir\theepsname}}% + \ifnum\tracingeps>1 \rlap{\copy\tmpepsbox}\fi + \vbox{\offinterlineskip + \hrule\vskip-.4pt + \hbox to\wd\tmpepsbox{\vrule\hss\vbox to\ht\tmpepsbox{ + \vss\hbox{\tt \special{ps:gsave \epsnamecolor\space setrgbcolor}% + \theepsname\special{ps:grestore}}\vss}\hss\vrule} + \vskip-.4pt\hrule + }}\fi} +% --- +\def\eps{\hbox\bgroup + \begingroup \escapechar-1 \catcode`\%12 \def~{\string~}\epscont} +\def\epscont#1{% + \xdef\theepsname{\expandafter\string\csname#1\endcsname}\endgroup + \vbox{\special{ps: /SItps save N /isls false N + statusdict begin + /setpageparams {pop pop pop pop} def /setpage {pop pop pop} def + end + userdict begin + /bop-hook {} def /setpagedevice {pop} def + /a0 {} def /a1 {} def /a2 {} def /a3 {} def /a4 {} def /a5 {} def + /a6 {} def /a7 {} def /a8 {} def /a9 {} def /a10 {} def + /b0 {} def /b1 {} def /b2 {} def /b3 {} def /b4 {} def /b5 {} def + /letter {} def /note {} def /legal {} def + /halfletter {} def /11x17 {} def /ledger {} def + /flsa {} def /flse {} def + end }% + \epsraw\theepsname\special{ps: SItps restore }}\egroup} +% --- +% Redefinition of epsf macros: +% +% The values of `rwi' and `rhi' parameters are to be given in tenths +% of big point; the older version of the epsf package used to multiply +% a dimen register by 10, which put severe limitations on the +% available EPS size. +% +% The macro `\decimalshift' multiplies a given value by 10 ``syntactically,'' +% i.e., accomplishes ``decimal shifting''; the following conditions +% are assumed to hold: +% * leading zeros are meaningless; +% * + is a proper form of a dimen value; +% * the command `\the' applied to a dimen register yields a canonical form: +% []+[+] +% where are `p' and `t' characters having category code 12. +% +\def\decimalshift#1{% #1 -- a dimen register + \expandafter\expandafter\expandafter + \decimalsplit\expandafter\gobblePT\the#1.\relax +}% +\def\decimalsplit#1.#2\relax{% + \ifnum#1=0 \ifdim#11sp=-1sp -\fi \else #1\fi + \ifdim0#2sp=0sp 0\else \fractionshift#2\fi +}% +\def\fractionshift#1#2.{\ifnum0#2=0 #1\else #1.#2\fi}% +{\catcode`\p12 \catcode`\t12 \gdef\gobblePT#1pt{#1}}% +\def\pttobp{0.99626401}% = 72/72.27 +% --- +\def\epsfsetgraph#1{% + \epsfrsize=\epsfury\pspoints + \advance\epsfrsize by-\epsflly\pspoints + \epsftsize=\epsfurx\pspoints + \advance\epsftsize by-\epsfllx\pspoints +% +% If `epsfxsize' is 0, we default to the natural size of the picture. +% Otherwise we scale the graph to be \epsfxsize wide. +% + \epsfxsize\epsfsize\epsftsize\epsfrsize + \ifnum\epsfxsize=0 \ifnum\epsfysize=0 + \epsfxsize=\epsftsize \epsfysize=\epsfrsize + \epsfrsize=0pt +% +% We have a sticky problem here: TeX doesn't do floating point arithmetic! +% Our goal is to compute y = rx/t. The following loop does this reasonably +% fast, with an error of at most about 16 sp (about 1/4000 pt). +% + \else\epsftmp=\epsftsize \divide\epsftmp\epsfrsize + \epsfxsize=\epsfysize \multiply\epsfxsize\epsftmp + \multiply\epsftmp\epsfrsize \advance\epsftsize-\epsftmp + \epsftmp=\epsfysize + \loop \advance\epsftsize\epsftsize \divide\epsftmp 2 + \ifnum\epsftmp>0 + \ifnum\epsftsize<\epsfrsize\else + \advance\epsftsize-\epsfrsize \advance\epsfxsize\epsftmp \fi + \repeat + \epsfrsize=0pt + \fi + \else \ifnum\epsfysize=0 + \epsftmp=\epsfrsize \divide\epsftmp\epsftsize + \epsfysize=\epsfxsize \multiply\epsfysize\epsftmp + \multiply\epsftmp\epsftsize \advance\epsfrsize-\epsftmp + \epsftmp=\epsfxsize + \loop \advance\epsfrsize\epsfrsize \divide\epsftmp 2 + \ifnum\epsftmp>0 + \ifnum\epsfrsize<\epsftsize\else + \advance\epsfrsize-\epsftsize \advance\epsfysize\epsftmp \fi + \repeat + \epsfrsize=0pt + \else + \epsfrsize=\epsfysize + \fi + \fi +% +% Finally, we make the vbox and stick in a \special that dvips can parse. +% + \ifepsfverbose\message{#1: width=\the\epsfxsize, height=\the\epsfysize}\fi + \epsftmp=\pttobp\epsfxsize + \vbox to\epsfysize{\vfil\hbox to\epsfxsize{% + \ifnum\epsfrsize=0\relax + \special{PSfile=\ifepsfdraft psdraft.ps\else#1\fi\space + llx=\epsfllx\space lly=\epsflly\space + urx=\epsfurx\space ury=\epsfury\space + rwi=\decimalshift\epsftmp + \epsfclipstring}% + \else + \epsfrsize=\pttobp\epsfysize + \special{PSfile=\ifepsfdraft psdraft.ps\else#1\fi\space + llx=\epsfllx\space lly=\epsflly\space + urx=\epsfurx\space ury=\epsfury\space + rwi=\decimalshift\epsftmp\space + rhi=\decimalshift\epsfrsize + \epsfclipstring}% + \fi + \hfil}}% +\global\epsfxsize=0pt\global\epsfysize=0pt}% +% --- +\catcode`\/\slashcatcode +% --- +\endinput diff --git a/Master/texmf-dist/tex/generic/tex-ps/poligraf.sty b/Master/texmf-dist/tex/generic/tex-ps/poligraf.sty new file mode 100644 index 00000000000..6b5b93df385 --- /dev/null +++ b/Master/texmf-dist/tex/generic/tex-ps/poligraf.sty @@ -0,0 +1,101 @@ +%% poligraf.sty generic macros +%% Copyright (C) 1996, 2001 Janusz Marian Nowacki. Public domain. +%% [Polish:] | [English:] +% ,,Mi/edzy \TeX-em a drukarni/a'' | ``Between \TeX{} and the printing house'' +% wersja 2.0, kwiecie/n 2001 r. | version 2.0, April 2001 +%--- +% Cel: obs/luga strony dokumentu | Purpose: preparation of pages for +% dla cel/ow drukarskich, separacje | prepress, color separation, cropmarks, +% barwne, pasery, ,,lustro''. | color and gray scale bars, mirror print. +%--- +% Author: Janusz Marian Nowacki +% 86-300 Grudzi/adz +% ul. /Sniadeckich 82/46 +% tel. +48 +56 46-218-37 +% Poland +% e-mail: j.nowacki@gust.org.pl +%% Wsp/o/lpraca i komentarze: | Cooperation and comments: +%% BOP s.c. & Staszek Wawrykiewicz +% +%------------------------------------------------------------------ +\catcode`\@=11 +% +\newdimen\bigpoint \bigpoint 1pt +\newdimen\Voffsetdim \Voffsetdim\voffset \advance\Voffsetdim by 1in +\newcount\Voffset \Voffset\Voffsetdim \divide\Voffset by \bigpoint +\newdimen\Hoffsetdim \Hoffsetdim\hoffset \advance\Hoffsetdim by 1in +\newcount\Hoffset \Hoffset\Hoffsetdim \divide\Hoffset by \bigpoint +\newcount\overprintblack \overprintblack=1 +% +\def\cropmarkdistance #1{% + \special{!userdict begin /cropmarkdistance #1 def end}} +\def\cropmarksize #1{% + \special{!userdict begin /cropmarksize #1 def end}} +\def\barsize #1{% + \special{!userdict begin /barsize #1 def end}} +\def\nocolorbars{% + \special{!userdict begin /colorbars 0 def end}} +\def\onlycolorbars{% + \special{!userdict begin /colorbars 3 def end}} +\def\onlycolorsteps{% + \special{!userdict begin /colorbars 2 def end}} +\def\mirror{% + \special{!userdict begin /mirror 1 def end}} +\def\xoffset #1{% + \special{!userdict begin /xoffset #1 def end}} +\def\yoffset #1{% + \special{!userdict begin /yoffset #1 def end}} +\def\labeloff{% + \special{!userdict begin /marglabel 0 def end}} +% +\def\CYAN {1 0 0 0} +\def\MAGENTA{0 1 0 0} +\def\YELLOW {0 0 1 0} +\def\BLACK {0 0 0 1} +\def\sepcolor{} +\def\NoOverPrintBlack{\overprintblack=0} +% +\def\Separate #1{% + \input cmyk-hax + \edef\projectcolor{#1}% + \ifx\projectcolor\CYAN + \def\sepcolor{\projectCMYK\cyan} + \special{!userdict begin /color_sep 0 def /setsep 1 def end} + \ifnum\overprintblack>0 \delblacktrue \fi + \else \ifx\projectcolor\MAGENTA + \def\sepcolor{\projectCMYK\magenta} + \special{!userdict begin /color_sep 1 def /setsep 2 def end} + \ifnum\overprintblack>0 \delblacktrue \fi + \else \ifx\projectcolor\YELLOW + \def\sepcolor{\projectCMYK\yellow} + \special{!userdict begin /color_sep 2 def /setsep 3 def end} + \ifnum\overprintblack>0 \delblacktrue \fi + \else \ifx\projectcolor\BLACK + \def\sepcolor{\projectCMYK\black} + \special{!userdict begin /color_sep 3 def /setsep 4 def end} + \fi \fi \fi \fi +} +% +\def\add@makeheadline#1{% + \let\oriheadline\makeheadline% + \def\makeheadline{#1\oriheadline}% + } +\def\add@begindvi#1{% + \def\PoligrafHook{#1}% + \def\@begindvi{% + \PoligrafHook% + \unvbox \@begindvibox% + \gdef\@begindvi{\PoligrafHook}% + }} +% +\ifx\documentclass\@undefined + \add@makeheadline{\sepcolor} % for Plain +\else + \add@begindvi{\sepcolor} % for LaTeX +\fi +% +\catcode`\@=12 +% +\special{header=crops.pro} +% +\endinput diff --git a/Master/texmf-dist/tex/generic/tex-ps/trans.tex b/Master/texmf-dist/tex/generic/tex-ps/trans.tex new file mode 100644 index 00000000000..a3869832f6c --- /dev/null +++ b/Master/texmf-dist/tex/generic/tex-ps/trans.tex @@ -0,0 +1,653 @@ +% --------------------------------------------------------------------------- +% TeX macros implementing a standard set of PostScript transformations +% made in BOP (1993--2001), Gda\'nsk, Poland -- public domain software +% authors: Bogus\l{}aw Jackowski, Piotr Pianowski, Piotr Strzelczyk +% e-mail contact: bop@bop.com.pl +% --------------------------------------------------------------------------- +% S Y N O P S I S +% +% In the sequel, `box' means \hbox, \vbox, \box, or \copy, `dimen' means +% a sequence of dimens to be summed up; all macros mentioned below expand +% to \hbox{...}, they can therefore be used wherever \hbox can be. +% +% 1) +% x_scale and y_scale are given in percents (>0) +% \zscale changes uniformly x_size and y_size (x_scale=y_scale=scale) +% \xscale changes only x_size (y_scale=100) +% \yscale changes only y_size (x_scale=100) +% +% \zscale{scale} followed by a box +% \xyscale{x_scale}{y_scale} followed by a box +% \yxscale{y_scale}{x_scale} followed by a box +% \xscale{x_scale} followed by a box +% \yscale{y_scale} followed by a box +% +% 2) +% \xyscaleto resizes a box uniformly such that the resulting wd=dimen +% \yxscaleto resizes a box uniformly such that the resulting ht=dimen +% \xscaleto resizes a box horizontally such that the resulting wd=dimen +% \yscaleto resizes a box verically such that the resulting ht=dimen +% +% \xyscaleto{dimen} followed by a box +% \yxscaleto{dimen} followed by a box +% \xscaleto{dimen} followed by a box +% \yscaleto{dimen} followed by a box +% +% 3) +% \revolve rotates anticlockwise the box (either \hbox or \vbox +% following the command) by 90 degree; for the resulting box +% width=height+depth of the original box, height=width +% of the original box, and the reference point is the left top corner +% of the original box; this means that revolving a box four times +% yields the original box if and only if its depth is zero; +% \revolvedir- is equivalent to \revolve, \revolvedir+ rotates +% the box clockwise +% +% \revolve followed by a box +% \revolvedir+ followed by a box +% \revolvedir- followed by a box +% \revolveleft followed by a box (equivalent to \revolvedir-) +% \revolveright followed by a box (equivalent to \revolvedir+) +% \revolvepi followed by a box (equivalent to \xflip\yflip +% but not to \revolve\revolve) +% \rotatepi followed by a box (equivalent to \revolvepi; +% cf. also plain METAFONT rotatedaround and rotatedabout macros) +% 4) +% \rotate rotates a box by an arbitrary angle, clockwise for angle>0, +% width=height=depth=0pt for the resulting box +% +% \rotate{angle} followed by a box +% +% \rotatebb rotates a box by an arbitrary angle, clockwise for angle>0; +% the result is placed in a box having the dimensions of the resulting +% bounding box, protrusion to the left is compensated by appropriate +% shifting (see the macro \put_into_bb) +% +% \rotatebb{angle} followed by a box +% +% 5) +% \xflip and \yflip flip the box horizontally and vertically, +% respectively, i.e., with respect to the vertical and horizontal +% axis of the box, without changing the dimensions of the \box +% +% \xflip followed by a box +% \yflip followed by a box +% +% 6) +% \slant slopes a box by an angle alpha such that tan(alpha)=slant, +% without changing dimensions of the \box; +% +% \slant{slant} followed a box +% +% (negative argument value means slanting to the left) +% +% \slantbb slopes a box by an angle alpha such that tan(alpha)=slant, +% the result is placed in a box having the dimensions of the resulting +% bounding box, protrusion to the left is compensated by appropriate +% shifting (see the macro \put_into_bb) +% +% \slantbb{slant} followed a box +% +% 7) +% \clipbox clips the contents of a box that follows the command; +% the macro expects three dimen parameters: the width, the height +% and the depth of the resulting box +% +% \clipbox{width}{height}{depth} followed a box +% +% Any parameter can be empty; in such a case, the respective dimension +% of the original box is used +% --------------------------------------------------------------------------- +% HISTORY: +% 18 VIII 1993 ver. 0.1 +% * first release +% 30--31 VIII 1993 ver. 0.2 +% * third parameter eliminated from \scale (via \afterassignment +% and \aftergroup hackery) +% * added \zscale, \xyscale, \yxscale, \xscale, and \yscale +% with scaling given in percents +% * added \scaleto, \xyscaleto, \yxscaleto, \xscaleto, and \yscaleto +% 3 IX 1993 ver. 0.21 +% * \the_scale renamed to \lastscale and made global, thus it became +% available to a user +% 8 IX 1993 ver. 0.22 +% * all transformations return \hbox, because of currentpoint +% positioning +% * the old version of \scale is become undefined +% * \slant and \rotate fit the new convention of parameter's +% hackery -- they are assumed to be followed by an \hbox +% or a \vbox +% 6 XII 1993 ver. 0.23 +% * \revolve added +% * \rotate with \vbox patched +% 10 II 1994 ver. 0.24 +% * \revolvedir+, \revolvedir-, \xflip, and \yflip added +% 20 III 2000 ver. 0.5 (pre-release) +% * total reconstruction: +% -- all macros expand to \hbox, so that it is possible to +% superpose them, e.g., \xscale{200}\yscale{50}\hbox{...}; +% one must remeber, however, that \rotate yields a box having +% null dimensions, so an attempt to scale the result +% to a given dimen will produce erroneous PostScript code +% -- the possibility of changing \ht and \dp of a \vbox abolished; +% such an operation yields hardly intuitive results; try, e.g.: +% \hrule width\hsize +% \hbox{\setbox0\hbox{\vrule height1cmwidth1cm}\ht0 0mm \box0} +% \kern20mm +% \hrule width\hsize +% \hbox{\setbox0\vbox{\hrule height1cmwidth1cm}\ht0 0mm \box0} +% -- the box expected by all macros can be a TeX box expression: +% \hbox, \vbox, \box, and \copy +% -- scaling height or width to a given dimension yields exact value +% of the height or width, respectively (or both); this change is +% backward incompatible (but reasonable, one should think) +% -- all transformations store information about the position of the +% lower left corner and the upper right corner of the resulting +% bounding box (with respect to the base point of the transformed +% box) in four globally defined macros: +% \transllx, \translly, \transurx, \transury +% (a piece of funny code for vector rotation was added) +% -- \rotatebb and \slantbb added +% 25 III 2000 ver. 0.51 +% * fraction multiplication improved (speedup in trigonometric +% calculations ca 30%) +% * trigonometry calculations are performed in a group (otherwise using +% them within another \loop ... \repeat would be inconvenient); +% the result is a pair of globally defined macros (instead of dimen +% registers); they expand to a series of digits (i.e., they contain +% a count representation of the resulting dimen) +% * \unhbox (introduced in order to reduce the level of box nesting) +% should be used only in \rotatebb +% * internal macro naming changed +% 27 III 2000 ver. 0.52 +% * a dimen parameter can be a sequence of dimens to be summed up +% * \clipbox added +% 7--10 X 2000 ver. 0.53 +% * a bug in \slant[bb] fixed: \ht and \dp were interchanged due to +% a fallacious interpretation of a slant sign (recall that in dvips +% PostScript, unlike in METAFONT, `-' denotes slanting to the right, +% `+' -- to the left, because the y-axis is directed downwards); +% actually, the problem is much more complex: relying (unconsciously) +% on dvips coordinates means, in this case, that for non-square pixels +% both rotate and slant will not work -- need to be fixed! +% 13 XI 2000 ver. 0.54 +% * @ is a letter during reading trans macros (AMSTeX uses active @) +% * local macro \undtranscode renamed to \transundcode +% 9 VI 2001 ver 0.55 +% * ``mnemonic'' macros added: \revolveleft, \revolveright, \revolvepi +% and \rotatepi +% --------------------------------------------------------------------------- +\def\transspecial#1{\special{ps:#1}}% driver-oriented; default is dvips +% --- +\edef\transundcode{\the\catcode`\_}\catcode`\_11 +\edef\transatcode{\the\catcode`\@}\catcode`\@11 +% \z@ (0pt) and \p@ (1pt) are borrowed from plain +% --- +% a pretty general macro +\def\sumto#1{\def\sum_to_what{#1}\sum_to_what=\z@\relax \sumto_} +\def\sumto_{\futurelet\sum_tok\sumto__} +\def\sumto__{\ifx\sum_tok\relax\else\expandafter\sumto___\fi} +\def\sumto___{\afterassignment\sumto_\advance\sum_to_what} +% --- +\newbox\tmp_box % temporary box register +\newdimen\tmp_dim % temporary dimen registers +\newdimen\tmp_dim_a +\newdimen\tmp_dim_b +\newdimen\tmp_dim_c +\newdimen\tmp_dim_d +\newcount\tmp_count_a % temporary count registers +\newcount\tmp_count_b +\newcount\tmp_count_c +\newif\ifput_into_bb +% --- +\def\jump_setbox{\ifvoid\tmp_box % every box is initially void + \aftergroup\after_setbox \else \after_setbox \fi}% a general trick +% --- +\def\set_std_bb{% + \xdef\transllx{\the\z@}% + \xdef\translly{\ifdim\dp\tmp_box>\z@ -\fi\the\dp\tmp_box}% + \xdef\transurx{\the\wd\tmp_box}% + \xdef\transury{\the\ht\tmp_box}% +} +\def\put_into_bb#1{% #1 = operation: \unhbox for rotation, \box for slanting + \setbox\tmp_box\hbox{\kern-\transllx\rlap{#1\tmp_box}\kern\transurx}% + \ht\tmp_box\transury \dp\tmp_box-\translly \relax +} +% --- +\def\perc_scale#1#2{% #1 -- xscale, #2 -- yscale, in percents, + % to be followed by an \hbox or a \vbox + \def\after_setbox{% + \setbox\tmp_box\hbox{% + \transspecial{gsave + currentpoint #2 100 div div exch #1 100 div div exch + currentpoint neg #2 100 div mul exch neg #1 100 div mul exch + translate #1 100 div #2 100 div scale translate}% + \box\tmp_box \transspecial{grestore}}% + \ifdim#1\p@=100\p@ \else % special treatment of special case (100%) + \tmp_dim\wd\tmp_box + \advance\tmp_dim50sp \divide\tmp_dim100 % rounding rather than floor + \wd\tmp_box#1\tmp_dim + \fi + \ifdim#2\p@=100\p@ \else % ditto + \tmp_dim\ht\tmp_box + \advance\tmp_dim50sp \divide\tmp_dim100 % ditto + \ht\tmp_box#2\tmp_dim + \tmp_dim\dp\tmp_box + \advance\tmp_dim50sp \divide\tmp_dim100 % ditto + \dp\tmp_box#2\tmp_dim + \fi + \set_std_bb + \box\tmp_box\egroup}% + \afterassignment\jump_setbox\setbox\tmp_box = +}% +% --- +\def\xyscale#1#2{\hbox\bgroup\perc_scale{#1}{#2}} +\def\zscale#1{\xyscale{#1}{#1}} +\def\yxscale#1#2{\xyscale{#2}{#1}} +\def\xscale#1{\xyscale{#1}{100}} +\def\yscale#1{\xyscale{100}{#1}} +% --- +{\catcode`\p12 \catcode`\t12 \gdef\PT_{pt}} +\def\hull_num{\expandafter\hull_num_} +\expandafter\def\expandafter\hull_num_\expandafter#\expandafter1\PT_{#1} +% --- +\def\find_scale#1#2{% #1 -- size after rescaling, #2 -- \wd or \ht +% Finds a scale (\lastscale macro) such that the box following the macro +% call would have the respective dimen (i.e., #2) equal to #1 after rescaling +% NOTE: it is assumed that prior to calling \find_scale a macro +% \extra_complete is defined + \def\after_setbox{% + \resize\tmp_dim{100\p@}{#1}{#2\tmp_box}% + \xdef\lastscale{\hull_num\the\tmp_dim}\extra_complete}% + \afterassignment\jump_setbox\setbox\tmp_box = +} +% --- +\def\scaleto#1#2#3#4{% #1 -- size of dimen #2 (\wd or \ht) after scaling + % #3 -- actual x-size, #4 -- actual y-size + \hbox\bgroup % `initial' hbox + \sumto\tmp_dim#1\relax % freeze the argument; must not be empty + \setbox\tmp_box\hbox\bgroup % one more setbox in order to control + % the specified dimen + \def\extra_complete{% + \perc_scale{#3}{#4}\box\tmp_box % finish setbox above + #2\tmp_box=\tmp_dim % force the exactness of the specified dimension + \set_std_bb + \box\tmp_box + \egroup % close `initial' hbox + }% + \find_scale{\tmp_dim}#2} +% +\def\xyscaleto#1{\scaleto{#1}\wd\lastscale\lastscale} +\def\yxscaleto#1{\scaleto{#1}\ht\lastscale\lastscale} +\def\xscaleto#1{\scaleto{#1}\wd\lastscale{100}} +\def\yscaleto#1{\scaleto{#1}\ht{100}\lastscale} +% --- +\def\slant{\hbox\bgroup \put_into_bbfalse \slant_} +\def\slantbb{\hbox\bgroup \put_into_bbtrue \slant_} +\def\slant_#1{% #1 (slant) = tan(alpha), where alpha is the slant angle, + % to be followed by a box + \def\after_setbox{% + \transspecial{gsave 0 currentpoint neg exch pop 0 currentpoint exch pop + translate [1 0 #1 1 0 0] concat translate}% + % set bounding box + \dim_x\wd\tmp_box + \ifdim#1\p@>\z@ \dim_t-#1\ht\tmp_box \advance\dim_x#1\dp\tmp_box + \else \dim_t#1\dp\tmp_box \advance\dim_x-#1\ht\tmp_box + \fi + \xdef\transllx{\the\dim_t}% + \xdef\translly{\ifdim\dp\tmp_box>\z@ -\fi\the\dp\tmp_box}% + \xdef\transurx{\the\dim_x}% + \xdef\transury{\the\ht\tmp_box}% + \ifput_into_bb \put_into_bb\box \fi + \box\tmp_box \transspecial{grestore}\egroup}% + \afterassignment\jump_setbox\setbox\tmp_box = +}% +% --- +\def\update_bb#1#2#3{% used in \rotate + \trigcompute{-#1}{#2}{#3}% clockwise vs anti-clockwise + \ifdim\transllx>\trigxresult sp\xdef\transllx{\trigxresult sp}\fi + \ifdim\translly>\trigyresult sp\xdef\translly{\trigyresult sp}\fi + \ifdim\transurx<\trigxresult sp\xdef\transurx{\trigxresult sp}\fi + \ifdim\transury<\trigyresult sp\xdef\transury{\trigyresult sp}\fi +} +\def\rotate{\hbox\bgroup \put_into_bbfalse \rotate_} +\def\rotatebb{\hbox\bgroup \put_into_bbtrue \rotate_} +\def\rotate_#1{% #1 -- angle, + % to be followed by a box + \def\after_setbox{% + \setbox\tmp_box\hbox{% otherwise does not work with \vbox + \transspecial{gsave currentpoint currentpoint translate + #1 rotate neg exch neg exch translate}% + \box\tmp_box \transspecial{grestore}}% + % set bounding box + \xdef\transllx{\the\z@}\xdef\translly{\the\z@}% + \xdef\transurx{\the\z@}\xdef\transury{\the\z@}% + \update_bb{#1}{\z@}{\ht\tmp_box}% + \update_bb{#1}{\z@}{-\dp\tmp_box}% + \update_bb{#1}{\wd\tmp_box}{\ht\tmp_box}% + \update_bb{#1}{\wd\tmp_box}{-\dp\tmp_box}% + % + \wd\tmp_box\z@ \ht\tmp_box\z@ \dp\tmp_box\z@ + \ifput_into_bb \put_into_bb\unhbox \fi + \box\tmp_box\egroup}% + \afterassignment\jump_setbox\setbox\tmp_box = +}% +% --- +\def\plus_{+} +\def\minus_{-} +\def\revolvedir#1{% to be followed by a box + \hbox\bgroup +% check parameter: + \def\param_{#1}% + \ifx\param_\plus_ \else \ifx\param_\minus_ + \else + \errhelp{I would rather suggest to stop immediately.}% + \errmessage{Argument to \noexpand\revolvedir should be either + or -}% + \fi\fi + \def\after_setbox{% + \tmp_dim_a\wd\tmp_box +% prepare to revolving: + \setbox\tmp_box\hbox{% + \ifx\param_\plus_\kern-\tmp_dim_a\fi + \box\tmp_box + \ifx\param_\plus_\kern\tmp_dim_a\fi}% +% compute dimensions of the box to be revolved: + \tmp_dim_a\ht\tmp_box \advance\tmp_dim_a\dp\tmp_box + \tmp_dim_b\ht\tmp_box \tmp_dim_c\dp\tmp_box + \dp\tmp_box\z@ \ht\tmp_box\wd\tmp_box \wd\tmp_box\tmp_dim_a +% revolve: + \kern \ifx\param_\plus_ \tmp_dim_c \else \tmp_dim_b \fi + \transspecial{gsave currentpoint currentpoint translate + #190 rotate neg exch neg exch translate}% + \set_std_bb + \box\tmp_box + \transspecial{grestore}% + \kern -\ifx\param_\plus_ \tmp_dim_c \else \tmp_dim_b \fi + \egroup}% + \afterassignment\jump_setbox\setbox\tmp_box = +}% +\def\revolveleft{\revolvedir-} +\def\revolveright{\revolvedir+} +\def\revolvepi{\xflip\yflip} +\let\revolve\revolveleft +\let\rotatepi\revolvepi +% --- +\def\xflip{% to be followed by a box + \hbox\bgroup + \def\after_setbox{% + \tmp_dim_a.5\wd\tmp_box +% prepare to flipping: + \setbox\tmp_box + \hbox{\kern-\tmp_dim_a \box\tmp_box \kern\tmp_dim_a}% +% flip: + \kern\tmp_dim_a + \transspecial{gsave currentpoint currentpoint translate + [-1 0 0 1 0 0] concat neg exch neg exch translate}% + \set_std_bb + \box\tmp_box + \transspecial{grestore}% + \kern-\tmp_dim_a + \egroup}% + \afterassignment\jump_setbox\setbox\tmp_box = +}% +% --- +\def\yflip{% to be followed by a box + \hbox\bgroup + \def\after_setbox{% + \tmp_dim_a\ht\tmp_box \tmp_dim_b\dp\tmp_box + \tmp_dim_c\tmp_dim_a \advance\tmp_dim_c\tmp_dim_b + \tmp_dim_c.5\tmp_dim_c +% prepare to flipping: + \setbox\tmp_box\vbox{% + \kern\tmp_dim_c\box\tmp_box\kern-\tmp_dim_c}% +% flip: + \advance\tmp_dim_c-\tmp_dim_b + \setbox\tmp_box\hbox{% + \transspecial{gsave currentpoint currentpoint translate + [1 0 0 -1 0 0] concat neg exch neg exch translate}% + \lower\tmp_dim_c\box\tmp_box + \transspecial{grestore}}% +% restore dimensions of the flipped box: + \ht\tmp_box\tmp_dim_a \dp\tmp_box\tmp_dim_b + \set_std_bb + \box\tmp_box + \egroup}% + \afterassignment\jump_setbox\setbox\tmp_box = +}% +% --- +% save TeX registers: +\let\clip_wd\tmp_dim_a +\let\clip_ht\tmp_dim_b +\let\clip_dp\tmp_dim_c +% --- +\def\tracingclipcmyk{1 0 0 0} +\def\clip_fix_pos#1{\transspecial{% + currentpoint /clip_#1_y exch def /clip_#1_x exch def% +}} +\def\clip_use_pos#1{clip_#1_x clip_#1_y} +\def\clip_delta#1#2{#1 #2 3 -1 roll exch sub 3 1 roll sub exch} +% +\def\do_clip{\transspecial{% + newpath + \clip_use_pos{LL} moveto + \clip_delta{\clip_use_pos{UR}}{\clip_use_pos{UL}} rlineto + \clip_delta{\clip_use_pos{UR}}{\clip_use_pos{LR}} rlineto + \clip_delta{\clip_use_pos{LL}}{\clip_use_pos{LR}} rlineto + closepath + \ifx\tracingclip\unknown \else + gsave \tracingclipcmyk\space setcmykcolor fill grestore + \fi + clip newpath% +}} +% +\def\clip_use_dim#1{% #1 = wd, ht, or dp + \ifdim\csname clip_#1\endcsname=\maxdimen \csname#1\endcsname\tmp_box + \else \csname clip_#1\endcsname\fi +} +% +\def\clip_fix_dim#1#2{% + \edef\clip_use_dim_param{#2}% + \ifx\clip_use_dim_param\empty #1\maxdimen\else + \ifx\clip_use_dim_param\space #1\maxdimen\else \sumto#1#2\relax \fi\fi +} +% +\def\clipbox#1#2#3{% desired height, width and depth to be followed by a box + \hbox\bgroup + \clip_fix_dim\clip_wd{#1}% + \clip_fix_dim\clip_ht{#2}% + \clip_fix_dim\clip_dp{#3}% + \clipbox_ +} +\def\clipbox_{% + \def\after_setbox{% + \setbox\tmp_box\hbox{\box\tmp_box}% + \clip_wd\clip_use_dim{wd}% freeze dimen + \clip_ht\clip_use_dim{ht}% ditto + \clip_dp\clip_use_dim{dp}% ditto + \transspecial{gsave}% + \rlap{% + \lower \clip_dp \vbox{% + \hbox to\clip_wd{\clip_fix_pos{UL}\hss\clip_fix_pos{UR}} + \kern\clip_ht \kern\clip_dp \nointerlineskip + \hbox to\clip_wd{\clip_fix_pos{LL}\hss\clip_fix_pos{LR}} + \do_clip + }% + }% + \wd\tmp_box=\clip_wd \ht\tmp_box=\clip_ht \dp\tmp_box=\clip_dp + \set_std_bb \box\tmp_box \transspecial{grestore}\egroup}% + \afterassignment\jump_setbox\setbox\tmp_box = +} +% --------------------------------------------------------------------------- +% ``floating point arithmetic'' (excerpted from T. Rokicki): +% r y +% +% ^ +% | +% | +% | +% | +% | +% 0--------------> t x +% +% save TeX registers: +\let\dim_x\tmp_dim_a % horizontal size after scaling +\let\dim_y\tmp_dim_b % vertical size after scaling +\let\dim_t\tmp_dim_c % horizontal size before scaling +\let\dim_r\tmp_dim_d % vertical size before scaling +%\tmp_dim % register for arithmetic manipulation (already declared) +% --- +\def\resize + % dimen registers: + #1% y make y such that y/r=x/t + #2% r + #3% x + #4% t +% We have a sticky problem here: TeX doesn't do floating point arithmetic! +% Our goal is to compute y = rx/t. The following loop does this reasonably +% fast, with an error of at most about 16 sp (about 1/4000 pt). + {% + % save parameters to the internal variables: + \dim_r#2\relax \dim_x#3\relax \dim_t#4\relax + \tmp_dim=\dim_r \divide\tmp_dim\dim_t + \dim_y=\dim_x \multiply\dim_y\tmp_dim + \multiply\tmp_dim\dim_t \advance\dim_r-\tmp_dim + \tmp_dim=\dim_x + \loop \advance\dim_r\dim_r \divide\tmp_dim 2 + \ifnum\tmp_dim>0 + \ifnum\dim_r<\dim_t\else + \advance\dim_r-\dim_t \advance\dim_y\tmp_dim \fi + \repeat + % assign result: + #1\dim_y\relax +} +% --------------------------------------------------------------------------- +% ``fixed point arithmetic'' -- fractions and trigometry, inspired by mf.web: +% +% save TeX registers: +\let\fracint\tmp_dim +\let\fracfrac\tmp_count_a +\let\fracprod\tmp_count_b +\def\fracpowlimit{30}% +\def\fracone{1073741824}% = 2^\fracpowlimit +% --- +\def\fracproduct#1#2{% #1 = fraction * 2^\fracpowlimit, #2 = integer +% result: macro \fracresult = floor(#1 * #2 / 2^\fracpowlimit + 1/2) +% expanding to the count equivalent of the respective dimen +\begingroup + \fracfrac#1\relax % \fracfrac <= 2^30 + \fracint#2\relax % \fracint <= \maxdimen + \ifdim\fracint<0pt \fracint-\fracint\def\fracsign{-}\else\def\fracsign{}\fi + \ifnum\fracone=\fracfrac \fracprod\fracint \else + \advance\fracfrac\fracone % \fracfrac < 2^31 + \fracprod\fracone % if \fracprod were dimen, this would yield error + \divide\fracprod2 % \fracprod = 2^29 (representation of 1/2) + \loop + \ifodd\fracfrac \advance \fracprod\fracint \fi + \divide\fracprod2 \divide\fracfrac2 + \ifnum \fracfrac>1 \repeat + \fi + \xdef\fracresult{\fracsign\number\fracprod}% +\endgroup +} +% --- +\newdimen\onedegree +\onedegree16pt % this must be consistent with the table below +% save TeX registers: +\let\trigangle\tmp_dim_a +\let\trigxpart\tmp_dim_b +\let\trigypart\tmp_dim_c +\let\trigxtmp\tmp_dim +\let\trigiter\tmp_count_a +\def\triglimit{28}% +% --- +\def\trigvalarg#1{\csname argscaled:\number#1\endcsname} +\def\trigvalcos#1{\csname cosscaled:\number#1\endcsname} +\def\trigvalsin#1{\csname sinscaled:\number#1\endcsname} +\def\defspectrig#1#2#3#4{% +% #1 -- ordering number (index) +% #2 -- angle in degrees * \onedegree expressed in sp; alpha=#1*2^(-20) +% #3 -- floor(cosd(alpha)*2^30+1/2) (30=\fracpowlimit) +% #4 -- floor(sind(alpha)*2^30+1/2) + \expandafter\def\csname argscaled:#1\endcsname{#2}% + \expandafter\def\csname cosscaled:#1\endcsname{#3}% + \expandafter\def\csname sinscaled:#1\endcsname{#4}% +} +\defspectrig{1}{62914560}{536870912}{929887697} % alpha=60 +\defspectrig{2}{47185920}{759250125}{759250125} % 45 +\defspectrig{3}{31457280}{929887697}{536870912} % 30 +\defspectrig{4}{16777216}{1032146887}{295963357} % 2^4 +\defspectrig{5}{8388608}{1063292242}{149435979} % 2^3 +\defspectrig{6}{4194304}{1071126243}{74900443} % 2^2 +\defspectrig{7}{2097152}{1073087729}{37473049} % 2^1 +\defspectrig{8}{1048576}{1073578288}{18739379} % 2^0 +\defspectrig{9}{524288}{1073700939}{9370046} % 2^-1 +\defspectrig{10}{262144}{1073731603}{4685068} % 2^-2 +\defspectrig{11}{131072}{1073739269}{2342539} % 2^-3 +\defspectrig{12}{65536}{1073741185}{1171270} % 2^-4 +\defspectrig{13}{32768}{1073741664}{585635} % 2^-5 +\defspectrig{14}{16384}{1073741784}{292818} % 2^-6 +\defspectrig{15}{8192}{1073741814}{146409} % 2^-7 +\defspectrig{16}{4096}{1073741822}{73204} % 2^-8 +\defspectrig{17}{2048}{1073741823}{36602} % 2^-9 +\defspectrig{18}{1024}{1073741824}{18301} % 2^-10 +\defspectrig{19}{512}{1073741824}{9151} % 2^-11 +\defspectrig{20}{256}{1073741824}{4575} % 2^-12 +\defspectrig{21}{128}{1073741824}{2288} % 2^-13 +\defspectrig{22}{64}{1073741824}{1144} % 2^-14 +\defspectrig{23}{32}{1073741824}{572} % 2^-15 +\defspectrig{24}{16}{1073741824}{286} % 2^-16 +\defspectrig{25}{8}{1073741824}{143} % 2^-17 +\defspectrig{26}{4}{1073741824}{71} % 2^-18 +\defspectrig{27}{2}{1073741824}{36} % 2^-19 +\defspectrig{28}{1}{1073741824}{18} % 2^-20 +% --- +\def\trigcompute#1#2#3{% +% #1 angle in degrees (a) +% #2 initial xpart (x) +% #3 initial ypart (y) +% result: (x',y')=(x,y) rotated a; the pair of macros +% \trigxresult and \trigyresult contain x' and y', respectively; +% both expand to the count equivalent of the respective dimen +\begingroup + \trigangle#1\onedegree \trigxpart#2\relax \trigypart#3\relax + \loop \ifdim\trigangle<0sp \advance\trigangle360\onedegree \repeat + \loop \ifdim\trigangle>360\onedegree \advance\trigangle-360\onedegree \repeat + \ifdim\trigangle=360\onedegree \trigangle0sp \fi + \ifdim\trigangle<180\onedegree \else % >= + \trigxpart-\trigxpart \trigypart-\trigypart + \advance\trigangle-180\onedegree + \fi + \ifdim\trigangle<90\onedegree \else % >= + \trigxtmp\trigxpart \trigxpart-\trigypart \trigypart\trigxtmp + \advance\trigangle-90\onedegree + \fi + \trigiter1\relax + \loop + \ifnum\trigvalarg\trigiter>\trigangle \else % <= + \advance\trigangle-\trigvalarg\trigiter sp + \trigxtmp\trigxpart + % x=x*cos[i]-y*sin[i] : + \fracproduct{\trigvalcos\trigiter}\trigxpart + \trigxpart\fracresult sp + \fracproduct{\trigvalsin\trigiter}\trigypart + \advance\trigxpart-\fracresult sp + % y=y*cos[i]+x*sin[i] : + \fracproduct{\trigvalcos\trigiter}\trigypart + \trigypart\fracresult sp + \fracproduct{\trigvalsin\trigiter}\trigxtmp + \advance\trigypart\fracresult sp + \fi + \advance\trigiter1 + \ifnum\trigangle>0 \repeat +% result in dimen registers: \trigxpart and \trigypart + \xdef\trigxresult{\number\trigxpart}% + \xdef\trigyresult{\number\trigypart}% +\endgroup +} +% --------------------------------------------------------------------------- +% restore original catcodes: +\catcode`\@\transatcode +\catcode`\_\transundcode +% --------------------------------------------------------------------------- +\endinput + -- cgit v1.2.3