I further modified the text printing program so that it does a 3D
transform on all the points of the characters. You define a transform
using 4 points and while it all seems to work, actually weilding those
4 points to accomplish a visual effect somewhat eludes me still.
I was trying to do the "Star Wars crawl" perspective but I can't figure
it out.
%!
%
% From: Jonathan Monsarrat (
jgm@cs.brown.edu)
% Subject: PostScript -> ASCII *and* ASCII -> PostScript programs
% Newsgroups: comp.lang.postscript
% Date: 1992-10-01 04:45:38 PST
%
% "If anyone is interested, here is an interesting program written by
% Professor John Hughes here at Brown University that formats ASCII
% in PostScript without a machine generator of any kind."
%
%%%
%%% Plan:
%%% Start with an empty string.
%%% For each character in the input stream,
%%% check to see if it's a carriage return.
%%% if so, show the current string and reset it to empty
%%% if not, add it to the current string.
%
% 2020-05-15 Updated/reorganzied --luser droog
% Change to get paper size from currentpagedevice.
% Fix buffer overflow check.
% Factor main line code into functions.
% Encapsulate definitions in a dictionary.
% Format short functions tightly.
% 2020-05-15 Added 3D 4-point transform --luser droog
<<
/parameters { % user modifiable values
/buflength 500 def
/topmargin 1 inch def
/botmargin 1 inch def
/leftmargin 1 inch def
/Courier 9 selectfont
}
% 3D parameters
% -xs- -w-
% x+xs,y+h [1] x+w+xs,y+h+ys [3]
% / /
% h h
% / /
% x,y [0] x+w,y+ys [2]
% -w- |ys
/x 0 /xs .1 % llx x-skew
/y 0 /ys 0 % lly y-skew
/w 1 % urx=x+w
/h 1 % ury=y+h
/square {
x y
x xs + y h +
x w + y ys +
x w + xs + y h + ys +
}
/points {
% UL [1] UR [3]
%
% LL [0] LR [2]
%
%0 0 0 1 1 0 1 1 % identity
%-.001 0 -.001 1 1.0005 0 1.0005 1 % pull left edge
%0 0 1 0 0 1 1 1 % double mirror
0 -.001 0 1.0005 1 0 1 1 % pull top edge
}
/main {
initialize
%square 3D
points 3D
mainloop quit
}
/initialize {
parameters
/leading calcleading def
/pageheight currentpagedevice /PageSize get 1 get def
%/pageheight newpath clippath pathbbox 4 1 roll pop pop pop def
/linesperpage pageheight topmargin sub botmargin sub leading div cvi def
/linenumber 1 def % the line we're about to write on
/buf buflength string def
/empty buflength string def
/ptr 0 def
}
/mainloop {
{
currentfile read not {lastpage exit} if
dup 10 eq {pop showstring}{addtostring} ifelse
} loop
}
/newline {
linenumber linesperpage gt {/linenumber 1 def showpage} if
leftmargin pageheight topmargin sub linenumber leading mul sub moveto
/linenumber ++
}
/lastpage { linenumber 1 gt { buf show showpage } if }
/startstring { buf 0 empty putinterval /ptr 0 def }
/showstring { newline buf 0 ptr getinterval show startstring }
/addtostring { ptr buflength ge {pop}{ buf exch ptr exch put /ptr ++ } ifelse }
/calcleading {
gsave
matrix currentmatrix matrix invertmatrix concat % ( CTM = identmatrix )
currentfont % font
dup /FontMatrix get concat % font ( CTM = FontMatrix )
/FontBBox get aload pop % llx lly urx ury
dtransform 3 2 roll dtransform % urx' ury' llx' lly'
exch pop sub exch pop % ury-lly
grestore
}
/3D {
findmatrix /P exch def
/show {
{
currentpoint newpath moveto
false charpath flattenpath
{ moveto }{ pop pop }{}{} pathforall
gsave
xformpath
fill
grestore
} foreach
} def
}
/findmatrix { % algorithm by Tim Rentsch
{
y3 x3
y2 x2
y1 x1
y0 x0
} begin-args
/xm x0 x1 - x2 - x3 + def
/ym y0 y1 - y2 - y3 + def
/a'd y1 y3 - x2 x3 - * x3 x1 - y2 y3 - * + def
/b'd x1 x3 - y2 y3 - * y3 y1 - x2 x3 - * + def
/a' y1 y3 - xm * x3 x1 - ym * + a'd | def
/b' y2 y3 - xm * x3 x2 - ym * + b'd | def
/a x2 1 a' + * x0 - def
/b x1 1 b' + * x0 - def
/d y2 1 a' + * y0 - def
/e y1 1 b' + * y0 - def
/c x0 def
/f y0 def
[ [ a b c ] [ d e f ] [ a' b' 1 ] ]
end
}
/xformpath {
[
{ project2 /moveto cvx }
{ project2 /lineto cvx }
{ }
{ /closepath cvx } pathforall
] cvx newpath exec
}
/project2 { to-homog P matmul to-xy }
/to-homog { 1 3 array astore }
/to-xy { 0 get aload pop dup 3 1 roll div 3 1 roll div exch }
/matmul { STATICDICT begin
/B exch def
B 0 get type /arraytype ne { /B [B] def } if
/A exch def
A 0 get type /arraytype ne { /A [A] def } if
/Q B length def
/R B 0 get length def
/P A length def
Q A 0 get length ne {
/A A transpose def
/P A length def
Q A 0 get length ne {
A B end /matmul cvx /undefinedresult signalerror
} if
} if
[
0 1 P 1 sub { /p exch def % rows of A
[
0 1 R 1 sub { /r exch def % cols of B
0
0 1 Q 1 sub { /q exch def % terms of sum
A p get q get
B q get r get mul
add
} for
} for
]
} for
]
end } dup 0 10 dict put
/begin-args { dup length dict begin {exch def} forall }
/foreach {
0 1 3 index length 1 sub % str proc 0 1 lim
%{//arr exch 1 getinterval //proc exec}
[ 6 5 roll /exch cvx 1 /getinterval cvx % proc 0 1 lim [ arr exch 1 getinterval
9 8 roll /exec cvx ] cvx
for
}
/inch {72 mul}
/+ /add cvx /- /sub cvx /* /mul cvx /| /div cvx
/++ {dup load 1 add store}
begin main
Text immediately following will be printed on the output device.
Use explicit newlines to trigger carriage returns.
Text immediately following will be printed on the output device.
Use explicit newlines to trigger carriage returns.
Text immediately following will be printed on the output device.
Use explicit newlines to trigger carriage returns.
Text immediately following will be printed on the output device.
Use explicit newlines to trigger carriage returns.
Text immediately following will be printed on the output device.
Use explicit newlines to trigger carriage returns.
Text immediately following will be printed on the output device.
Use explicit newlines to trigger carriage returns.
Text immediately following will be printed on the output device.
Use explicit newlines to trigger carriage returns.
Text immediately following will be printed on the output device.
Use explicit newlines to trigger carriage returns.
Text immediately following will be printed on the output device.
Use explicit newlines to trigger carriage returns.
Text immediately following will be printed on the output device.
Use explicit newlines to trigger carriage returns.
Text immediately following will be printed on the output device.
Use explicit newlines to trigger carriage returns.
Text immediately following will be printed on the output device.
Use explicit newlines to trigger carriage returns.
Text immediately following will be printed on the output device.
Use explicit newlines to trigger carriage returns.
Text immediately following will be printed on the output device.
Use explicit newlines to trigger carriage returns.
Text immediately following will be printed on the output device.
Use explicit newlines to trigger carriage returns.
Text immediately following will be printed on the output device.
Use explicit newlines to trigger carriage returns.
Text immediately following will be printed on the output device.
Use explicit newlines to trigger carriage returns.
Text immediately following will be printed on the output device.
Use explicit newlines to trigger carriage returns.
Text immediately following will be printed on the output device.
Use explicit newlines to trigger carriage returns.
Text immediately following will be printed on the output device.
Use explicit newlines to trigger carriage returns.
Text immediately following will be printed on the output device.
Use explicit newlines to trigger carriage returns.
Text immediately following will be printed on the output device.
Use explicit newlines to trigger carriage returns.
Text immediately following will be printed on the output device.
Use explicit newlines to trigger carriage returns.
Text immediately following will be printed on the output device.
Use explicit newlines to trigger carriage returns.
Text immediately following will be printed on the output device.
Use explicit newlines to trigger carriage returns.
Text immediately following will be printed on the output device.
Use explicit newlines to trigger carriage returns.
Text immediately following will be printed on the output device.
Use explicit newlines to trigger carriage returns.
Text immediately following will be printed on the output device.
Use explicit newlines to trigger carriage returns.
Text immediately following will be printed on the output device.
Use explicit newlines to trigger carriage returns.
Text immediately following will be printed on the output device.
Use explicit newlines to trigger carriage returns.
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)