Further support on www.tinaja.com
Also see http://www.tinaja.com/info01.html
(The following is believed correct. Please report any errors or differing experiences.)
Somewhere in our 1800+ file backlog is a
detailed and formal "tuna can" transform that
lets you use PostScript to create intentionally distorted "tuna can"
like objects, where the
lettering clearly and cleanly wraps itself around a tilted cylinder. A
tuna can transform
differs from isometric in that the tilt axis is less and is forward only.
It is also nonlinear.
I needed a quick and dirty Tuna Can transform for figure 4 of Muse121,
aka
http://www.tinaja.com/glib/muse121.pdf
where a pair of rod magnets was shown, and
it was easier to throw together some new and crude code rather than finding
the original.
The utterly fascinating general theory of PostScript nonlinear transforms
appears in
http://www.tinaja.com/glib/nonlingr.pdf
The tuna can is a nonlinear transform done
by intercepting and remapping each incidence of every moveto and
lineto.
The detailed code example appears in http://www.tinaja.com/glib/muse121.psl.
Here
is a tutorial excerpt:
% A "TUNA CAN" tutorial demo
% run my Gonzo utilities
(C:\\windows\\desktop\\gonzo\\gonzo.ps) run
gonzo begin
ps.util.1 begin
printerror
nuisance begin
100 100 translate % position on page
0 0 10 setgrid %
work on a 10x grid
20 20 showgrid %
optionally show grid for layout
10 0 translate % center magnet on grid
/!DD 4 def %
magnet diameter
/!TA 20 def %
tilt angle in degrees
/!KK !TA sin !DD mul 2 div def %
a transform variable
/adj {3.1415 2 div mul} def %
use radius units not circum
/tunaxf { %
begin Tuna NLT def
/yy exch store
% save y position
/xx exch store
% save x position
xx !DD div 114.591
mul sin % do Tuna nonlinear transform
!DD mul 2 div yy xx !DD
div % see nonlingr.pdf for math
114.591 mul cos !KK mul
sub
}
def
/specialmag { %
start magnet routine
save %
save machine state
/snapmag exch store %
.. as save object
translate %
position on page
/magcyl { -2 adj 0 mt 12 pu %
start magnet cylinder
40{.1 adj pr}
repeat % fake shortcut prevention
12 pd %
12 units high
40 {.1 adj
pl } repeat % close bottom
closepath
} def
/magtop {-2 adj 12 mt %
magnet cylinder top
80{.1 adj pl}repeat}
def
/Helvetica-Bold findfont [4 0 0 3 0 0] makefont setfont % setfont
/north { mark -1.42 9.1 mt (N) true charpath ] } def %
path for N
/south { mark -1.32 0.75 mt (S) true charpath ] } def % path
for S
/nlt { mark %
begin actual NLT array
{tunaxf /moveto cvx} %
movetoproc
{tunaxf /lineto cvx} %
linetoproc
{shouldnthappen} %
curveto error proc
{/closepath cvx} %
closepathproc
pathforall %
grab path
] } def %
close array
line1 %
set modest linewidth
beige
% and colorize
% show the magnet top...
magtop flattenpath nlt cvx %
get rid of curvetos
newpath exec %
and old path; execute
gsave 0.5 setgray fill grestore % fill top
0.33 setgray stroke %
stroke top
% show the magnet front
magcyl flattenpath nlt cvx %
get rid of curvetos
newpath exec % and
old path; execute
gsave 0.9 setgray fill grestore % fill front
stroke 0.33 setgray stroke %
and stroke
aqua % change colorize tint
north flattenpath nlt cvx %
transform the "N"
newpath exec
0.4 setgray fill %
and paint
south flattenpath nlt cvx %
transform the "S"
newpath exec
0.4 setgray fill %
and paint
snapmag restore } def % restore machine state
10 0 specialmag %
put lower magnet on page
10 30 specialmag %
put upper magnet on page
showpage %
show the page
My Gonzo utilities are found at http://www.tinaja.com/psutils/gonzo20.ps
The "run" file must be customized for your folders. Be
sure to use double slashes in
your PostScript filename string!
The easiest way to use this code is to edit it with Wordpad or whatever,
save it as an
ASCII textfile, and send it to Acrobat Distiller. More details on using
Distiller as a
general purpose PostScript interperter are in http://www.tinaja.com/text/sixclick.html
The only non-trivial gonzo commands used are the showgrid used
for the background layout
grid and the colorizing commands such as beige. The rest are
obvious, with mt = moveto,
pu = path up, etc.
A "proper" tuna can transform would automatically eliminate
any "corner cutting" by
intercepting all long horizontal moveto and lineto commands,
and replacing them with
shorter curvetrace commands, which in turn are converted to short
segments by
flattenpath. In this case, the can magnet cutting is eliminated by using
lots of short
segments in the circumferental direction. The "N" is not quite
right, but is small enough
that you cannot tell. Purty nigh but not plumb.
The key point of this tutorial is how easy it is to intercept positions
and do nonlinear
transformations of just about any type.
More on this whenever.