🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.postscript
3 messages
3 total messages Started by Jonathan Monsarrat Sat, 05 Sep 1992 06:41
Splash your graphics will metal-looking objects (example given)
#1868
Author: Jonathan Monsarrat
Date: Sat, 05 Sep 1992 06:41
134 lines
4849 bytes
Hi! This is Jonathan Monsarrat again from Brown University.

As you can see, I have a lot of free time on my hands! I love hacking
PostScript.

Here's an example of how you can get any arbitrary path to be filled
in such a manner that it looks like metal. This example happens to
be centered around printing words as metal. Hope you like it.

-Jon

P.S. another short PS hack
%! Obfuscated PostScript !% /exch{cvx}def /dup /def load def setfont 10 scale
/q{dup 0 1 getinterval cvn exch cvx def}def(dup)q(scale)q(moveto)q(translate)q
(closepath)q(exec)q(rotate)q{90 r{220 25 m 0 d 220 12 172 arc c}cvx d e -1 d s
e 270 0 m 0 d 270 360 0 arcn c gsave fill grestore 0 setgray stroke}cvx 45 r
462 36 t .5 d s d e 1 setgray 2 d s d e 80 0 t .08 d s e 8 d s -90 r -190 -30 m
/Helvetica-Bold findfont 90 scalefont setfont(NO     NO-NOs) show showpage

--------------------------------------------------------------

%!PS-Adobe1.0
%%Title: metal
%%Pages:1
%%BeginProcSet:TextProcs 1.0 0
% This file demonstrates drawing metallic-looking strings. It could be
% generalized to any path. You may not be able to use this routine with Adobe
% locked fonts. If you have problems use the GNU equivalent fonts.
% 
% The basic idea is that something will look metal if there are linear
% streaks across it common to any reflective surface.
%
% The following are the rules used to generate the metal letters.
% 1. The charpath is broken into 3 sections: outline, edge, and body.
% 2. Draw the outline first in black.
% 3. Define the body as exactly one delta "in" from every edge. Don't overlap
%    deltas for very small holes! Shade the body in horizontal stripes
%    from top to bottom according to the following relation.
% V = Current - Bottom / Top - Bottom 
% From V = 0 to 7/16 falls from .8 to 0 in a sine curve
% From V = 7/16 to 9/16 rises linearly from 0 to 1
% From V = 9/16 to 1 falls from 1 to .2 in a cosine curve
%
% NOTE: I didn't spend much time optomizing this. Volunteers?

%%%%%%%%%%   string height  TextMetalShow  -   %%%%%%%%%%%%%%
%%% Prints a metal-looking string at the current position just like "show"
%% It expects the string to be printed to be on the stack as well as
%% the height of the font currently being used. WARNING! In practice
%% the actual height of the letters is not the official size of the
%% font. For example, in my demo below I use 100pt type but have a height
%% of only 60pt.
/TextMetalShow
{
  4 dict begin  % If you don't know dictionaries, you should learn them.
    /height exch def
    dup length 1 sub 0 1 3 -1 roll
    {
      1 index exch 1 getinterval
      dup stringwidth pop /width exch def
      Pattern
      stringwidth pop 0 rmoveto
    } for
    pop
  end
} bind def

%%%%%%%%%%%%%%%%%%%%%  char Pattern - %%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Displays a single character as metal
%%% It's important to break the string up into individual letters because
%%% often when I do a "charpath" on a whole word, there isn't enough
%%% memory or something and the program dies. One letter at a time is safe.
/Pattern
{
  gsave
       currentpoint translate
       dup true charpath clip
  /delta 0.02 in def  % How fine should the grayscales be?
  /bot 0 def /top height 0.4375 mul def
  bot delta top
  {
    dup bot sub top bot sub div 55 mul 55 exch sub sin setgray
    newpath 0 exch moveto
    width 0 rlineto
    0 delta rlineto
    width neg 0 rlineto
    closepath fill
  } for

  /bot top def /top height 0.5625 mul def
  bot delta top
  {
    dup bot sub top bot sub div setgray
    0 exch moveto
    width 0 rlineto
    0 delta rlineto
    width neg 0 rlineto
    closepath fill
  } for
 
  /bot top def /top height def
  bot delta top
  {
    dup bot sub top bot sub div 78 mul cos setgray
    0 exch moveto
    width 0 rlineto
    0 delta rlineto
    width neg 0 rlineto
    closepath fill
  } for
    0 0 moveto
    dup
    true charpath
       gsave
            1 setgray
            5 setlinewidth
            stroke
       grestore
       stroke
  grestore
} bind def

%%EndProcSet
%%EndProlog
%%Page: one 1
/in {72 mul} def
/Times-Bold findfont 100 scalefont setfont
0.5 in 0.5 in moveto 7.5 in 0 rlineto 0 5 in rlineto -7.5 in 0 rlineto
  closepath 0.2 setgray fill

1.8 in 3.3 in moveto (METAL) 60 TextMetalShow
1 in 2 in moveto (HACKING) 60 TextMetalShow
showpage
%%Trailer
Re: Splash your graphics will metal-looking objects (example given)
#1876
Author: Vidiot
Date: Sun, 06 Sep 1992 05:19
15 lines
1284 bytes
In article <1992Sep5.064148.4276@cs.brown.edu> jgm@cs.brown.edu (Jonathan Monsarrat) writes:

<  4 dict begin  % If you don't know dictionaries, you should learn them.

Should have followed your on advice.  On a Apple LaserWriter IINT, the
dictionary is filled and an error occurs.  I changed the 4 to a 10 and
it printed.

I didn't go counting to see if the number could be smaller than 10, but
larger or = to 5.
-- 
      harvard\                          spool.cs.wisc.edu!astroatc!vidiot!brown
Vidiot  ucbvax!uwvax..........!astroatc!vidiot!brown
      rutgers/            INTERNET:vidiot!brown%astroatc.UUCP@spool.cs.wisc.edu
                                   brown@wi.extrel.com
Re: Splash your graphics will metal-looking objects (example given)
#1874
Author: Eric P. Scott
Date: Sun, 06 Sep 1992 10:34
9 lines
714 bytes
In article <1992Sep5.064148.4276@cs.brown.edu> jgm@cs.brown.edu
	(Jonathan Monsarrat) writes:
>/TextMetalShow
>{
>  4 dict begin  % If you don't know dictionaries, you should learn them.
   ^
I get a "dictfull" error unless I raise this to 5.

					-=EPS=-
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads