home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Corel Draw 3
/
CorelDRAW-v3.0.iso
/
draw
/
prolog.ps
< prev
next >
Wrap
Text File
|
1992-10-25
|
57KB
|
2,003 lines
% -------------- POSTSCRIPT PROLOG FOR CORELDRAW 3.X ------
% Copyright 1992 Corel Corporation. All rights reserved.
/wCorelDict 300 dict def % define our own dictionary
wCorelDict begin % everything is defined in our own dictionary
% -- general definition operators
/bd {bind def} bind def
/ld {load def} bd
/xd {exch def} bd
/_ null def % null object
% ----- Global Color variables ---------
% Current object's Fill color
/$c 0 def % Cyan component
/$m 0 def % Magenta component
/$y 0 def % yellow component
/$k 0 def % Black component
/$t 1 def % color Tint
/$n _ def % Color name(non-null for special colors only)
/$o 0 def % fill overprint flag
/$fil 0 def % current fill type: 0: solid, 1:pattern, 2: fountain, 3:PS-fill
/$bkg false def
% Current object's outline color
/$C 0 def % Cyan component
/$M 0 def % Magenta component
/$Y 0 def % yellow component
/$K 0 def % Black component
/$T 1 def % color Tint
/$N _ def % Color name(non-null for special colors only)
/$O 0 def % stroke overprint flag
/$PF false def % pattern stroke flag(0 no pattern, 1 pattern)
%--current transfo matrices--
/$ctm matrix currentmatrix def % initial general transfo matrix
/$ptm matrix def % pen stroking matrix(defaults identity)
/$ttm matrix def % text transfo matrix(Corel extensions)
/$stm matrix def % "save" matrix in extended text(Corel extensions)
%--pattern parameters --
% fill pattern:
%/$pn () def % current fill pattern name
%/$pm matrix def % current pattern matrix
%/$px 0 def % pattern x pos
%/$py 0 def % pattern y pos
%/$pxf 0 def % pattern x offset
%/$pyf 0 def % pattern y offset
%/$psx 10 def % current X shift between rows or tiles
%/$psy 0 def % current Y shift between columns or tiles
%/$pd [] def % current pattern description array
%/$tx 0 def % current tile x pos
%/$ty 0 def % current tile y pos
%-- info about current path when painting the pattern
%/$llx 0 def % current path's bbox(used by patterns only)
%/$lly 0 def % also used for each fountain stripes
%/$urx 0 def
%/$ury 0 def
%/Bbllx 0 def % current object's bbox(in absolute space)
%/Bblly 0 def
%/Bburx 0 def
%/Bbury 0 def
%/$tllx 0 def % current OBJECT's bbox(in current Pattern space)
%/$tlly 0 def
%/$turx 0 def
%/$tury 0 def
%-- Postscript fill variables
%/$Psn null def % current PS-fill function name(literal)
%/$Prm null def % current PS-fill parms(array of n params)
%-- fountain fill variables
/$fst 128 def % default # of steps in a fountain fill(can be redefined later)
%/$fty 0 def % current fountain type:0 linear, 1 radial
%/$fan 0 def % current fountain angle(if linear)
/$pad 0 def % edge pad around fountain (between 0 & 1.0)
/$rox 0 def % radial center x offset relative to bbox width
/$roy 0 def % radial center y offset relative to bbox height
%/$toc 0 def % TO anf FROM color components
%/$tom 0 def
%/$toy 0 def
%/$tok 0 def
%/$ton _ def % TO color name
%/$tot 0 def % TO tint
%/$frc 0 def
%/$frm 0 def
%/$fry 0 def
%/$frk 0 def
%/$frn _ def % FROM color name
%/$frt 0 def % FROM tint
%/$dc 0 def % delta colors between fountain steps
%/$dm 0 def
%/$dy 0 def
%/$dk 0 def
% ---- Halftone screen support (black only)----------------------
% NOTE: Unless modified later in the setup(generated code)section, the
% default halftone screens for fill & outline will be the
% current device's setting.
currentscreen % establish document's default halftone screen
/@dsp xd % default spot func
/$dsp /@dsp def % default spot func name
/$dsa xd % default screen angle
/$dsf xd % default screen frequency function
%-- and other screen-related vars
/$sdf false def % FLAG: non-default halftone screen for fill when true
/$SDF false def % FLAG: non-defaul halftone screen for stroke when true
%/$scp /$dsp def % Current spot func for fill
%/$sca $dsa def % Current screen angle for fill
%/$scf $dsf def % Current screen frequency for fill
%/$SCP /$dsp def % Current spot func for stroke
%/$SCA $dsa def % Current screen angle for stroke
%/$SCF $dsf def % Current screen frequency for stroke
/$Scra 0.0 def % screen adjustment (-90 if printing landscape)
% ---- Internal operators ----------------------
/$sv 0 def % variable for save snapshots
/@cp /closepath ld
/@gs /gsave ld
/@gr /grestore ld
/@np /newpath ld
/@sv {/$sv save def}bd
/@rs {$sv restore}bd
/@ss
{
% Increment screen angle by $Scra which is 0 for portrait printing,
% -90 for landscape printing.
exch $Scra add exch load setscreen
} bd
%-- ERROR Handling : Autoflatness for paths too complex
% The next section is to avoid the limitcheck error of typesetters.
% The painting operators of PostScript are rewritten to increase
% flatness until either the object can be printed, or a flatness
% of 10 more than the initial flatness setting has been reached.
% In this case an error message is displayed and printing continues with
% the next object.
% The auto-flatness will be enabled only if the value of the "AutoFlatness"
% variable is true. The code to set this variable is output by WALDO.
AutoFlatness
{
% error message if path can really not be printed
/$cpx ([Error: PathTooComplex; OffendingCommand: AnyPaintingOperator]\n) def
%-- @cpx Path too complex error message function - @cpx -
%%%%%%%%%/@err1 {$cpx print flush stop}bd % displays message and stops program
/@err1 {$cpx print flush newpath} bd % displays message and stops program
%-- @ifl Increase flatness initial_flatness @ifl initial_flatness
/@ifl
{
dup currentflat exch sub 10 gt % Is current flatness increase > 10?
{
@err1 exit
}
{
currentflat 2 add setflat
} ifelse
} bd
% --- Then redefine fill, eofill, clip, eoclip, & stroke
/@fill /fill ld
/fill
{
currentflat
{
{@fill}
stopped
{
@ifl
}
{
exit
} ifelse
} bind loop
setflat
} bd
/@eofill /eofill ld
/eofill
{
currentflat
{
{@eofill}
stopped
{
@ifl
}
{
exit
} ifelse
} bind loop
setflat
} bd
/@clip /clip ld
/clip
{
currentflat
{
{@clip}
stopped
{
initclip @ifl
}
{
exit
} ifelse
} bind loop
setflat
} bd
/@eoclip /eoclip ld
/eoclip
{
currentflat
{
{@eoclip}
stopped
{
initclip @ifl
}
{
exit
} ifelse
} bind loop
setflat
} bd
/@stroke /stroke ld
/stroke
{
currentflat
{
{@stroke}
stopped
{
@ifl
}
{
exit
} ifelse
} bind loop
setflat
} bd
} if
/InRange
{ %def -- FORCE VALUE BETWEEN TWO LIMITS -- STACK: value minimum maximum
% if value not in range, modifies the value to be between min and max
3 -1 roll % get value on top
2 copy le {pop}{exch pop}ifelse % val = min(val,MAXVAL)
2 copy ge {pop}{exch pop}ifelse % val = max(val,MINVAL)
} bd % --- NEEDED by functions in USERPROC.TXT
/wDstChck
{ % RETURN THE MAXVALUE CHANGE OR UNCHANGE. MORE DOC. IN USERPROC.TXT FILE.
2 1 roll dup 3 -1 roll
eq { 1 add } if
} bd % --- NEEDED by functions in USERPROC.TXT
%-- @dot dot spot function x y @dot num
/@dot
{ % implementation of a dot spot function for halftoning(see setscreen)
dup mul exch dup mul add 1 exch sub 2 div
} bd
%-- @lin line spot function x y @lin num
/@lin
{ % implementation of a line spot function for halftoning(see setscreen)
exch pop abs 1 exch sub
} bd
%-- @MN Minimum val1 val2 @MN value
/@MN
{
2 copy le
{pop}
{exch pop} ifelse % get minimum of both values
} bd
% -- define the setcmykcolor operator if not already defined
/setcmykcolor where {pop}
{
/setcmykcolor % cyan magenta yellow black setcmykcolor -
{
4 1 roll % send black below cyan
3 {3 index add 1 @MN 1 exch sub 3 1 roll} repeat % convert to BLUE, GREEN and RED
setrgbcolor
pop % get rid of black
} bd
} ifelse
% -- define the setoverprint operator if not already defined
% NOTE: We do not want to redefine this operator if it is defined so that
% other apps (e.g. Ventura Separator) can separate our EPS files.
/setoverprint where {pop}
{
/setoverprint % boolean setoverprint
{
/$op xd
} bd
} ifelse
% -- define the currentoverprint operator if not already defined
% NOTE: We do not want to redefine this operator if it is defined so that
% other apps (e.g. Ventura Separator) can separate our EPS files.
/currentoverprint where {pop}
{
/currentoverprint % - currentoverprint boolean
{
$op
} bd
} ifelse
/setsepcolor % greyvalue setsepcolor -
{
1 exch sub setgray % convert to ps gray
} bd
/checksepcolor % overprint greyvalue setsepcolor boolean
{
1 exch sub dup setgray % convert to ps gray
% if white(1) and overprint(1), do not print at all (return false)
1 eq exch 1 eq and not
} bd
/setprocesscolor % cyan magenta yellow black setprocesscolor -
{
ColorSeparationMode 0 eq % Check if not performing color seps.
{
setcmykcolor
}
{
0 4 $ink sub index % Fetch the relevant layer
exch pop % or zero for $ink == 4.
% |- C M Y K greyvalue
5 1 roll 4 { pop } repeat % |- greyvalue
setsepcolor
} ifelse
} bd
% -- define the findcmykcustomcolor operator if not already defined
% NOTE: We do not want to redefine this operator if it is defined so that
% other apps (e.g. Ventura Separator) can separate our EPS files.
/findcmykcustomcolor where {pop}
{
/findcmykcustomcolor % cyan magenta yellow black name findcmykcustomcolor array
{
5 array astore
} bd
} ifelse
% -- define the setcustomcolor operator if not already defined
% NOTE: We do not want to redefine this operator if it is defined so that
% other apps (e.g. Ventura Separator) can separate our EPS files.
/setcustomcolor where {pop}
{
/setcustomcolor % array tint setcustomcolor -
{
ColorSeparationMode 0 eq % Check if not performing color seps.
{
exch % tint array
aload pop pop % |- tint cyan magenta yellow black
4
{
4 index mul 4 1 roll % Multiply colour by tint.
} repeat
5 -1 roll pop % |- cyan magenta yellow black
setcmykcolor
}
{
exch aload pop % |- tint cyan magenta yellow black name
CurrentInkName eq % Check if this is the ink currently being separated.
{
4 index % Fetch the tint.
}
{
0 % No match, use 0.
} ifelse % |- tint cyan magenta yellow black greyvalue
6 1 roll
5 { pop } repeat % |- greyvalue
setsepcolor
} ifelse
} bd
} ifelse
% -- define the colorimage operator if not already defined
% -- NOTE: We know we always call colorimage with ONE procedure
% -- It should call the "image" operator instead
% NOTE ####### Now , just skips the color info
/colorimage where {pop}
{
/colorimage % wid hei bits matrix proc bool ncolors colorimage -
{
pop % # of colors
pop % BOOL always assumed false
pop % data aquisition must be different
pop % matrix not needed
pop % # bits not needed
{currentfile $dat readhexstring pop pop} % read each row of data
repeat % until all rows are read
pop % clear the rest of the stack
} bd
}ifelse
%-- @tc tint color cyan mag yel blk tint @tc cyan1 mag1 yel1 blk1
/@tc % Tint current color (basically multiply 4 components with given tint)
{
dup 1 ge % see if tint >= 1
{pop} % if it is, pop it
{ % otherwise, multiply all 4 components
4
{
dup % duplicate the tint
6 -1 roll % get next component
mul % multiply with current tint
exch % tint back on top
} repeat
pop % no need for tint anymore
} ifelse
} bd
%-- @scc set current color tint C M Y K name overprint @scc boolean
/@scc % -- set current color --
{
1 eq setoverprint % Set overprint parameter.
dup _ eq % Check if process colour.
{
pop
setprocesscolor
pop
}
{ % Spot colour.
findcmykcustomcolor
exch
setcustomcolor
} ifelse
ColorSeparationMode 0 eq % If not doing color seps, ...
{
true
}
{
% if white(1) and overprint, do not print at all(return false)
currentgray 1 eq currentoverprint and not
} ifelse
} bd
% -------------------- pattern support -----------------------
%-- @sft set first tile position - @sft -
/@sft %set first tile position into $tx $ty (top left corners)
{
% /$tx $tllx $pxf add dup $tllx gt {$pwid $psx add sub}if def % first tile's x position(left)
% /$ty $tury $pyf sub dup $tury lt {$phei $psy add add}if def % first tile's y position(top)
% 3-Apr-91:KB:Adjusted position of starting tile to make PS Output match
% preview and non-PS printers
/$tx $tllx $pxf add dup $tllx gt {$pwid sub}if def % first tile's x position(left)
/$ty $tury $pyf sub dup $tury lt {$phei add}if def % first tile's y position(top)
} bd
%-- @stb set current bbox - @stb -
/@stb % stores the current path's bbox into globals $llx,$lly, $urx, $ury
{
pathbbox /$ury xd /$urx xd /$lly xd /$llx xd % path's bbox
} bd
%-- @ep Execute Pattern array @ep -
/@ep % gets a pattern description from the stack and executes it
{
{
cvx exec
} forall
} bd
%-- @tp Tile pattern xpos ypos @tp -
/@tp % creates a tile at specified position and plays the current
{ % pattern into that tile
% first, make sure the tile woul be in the clipping path
@sv % save current settings
/$in true def
2 copy
dup $lly le {/$in false def}if % below current path?
$phei sub $ury ge {/$in false def}if % above current path?
dup $urx ge {/$in false def}if % right current path?
$pwid add $llx le {/$in false def}if % left current path?
$in
{
@np
2 copy m
$pwid 0 rl % Create a rectangle clip box for the tile
0 $phei neg rl
$pwid neg 0 rl
0 $phei rl
clip @np
% translate pattern into new tile
$pn cvlit load aload pop % get the current pattern
% stack: xpos ypos pat_bbox (0 0 72 72) pat_description
7 -1 roll % get x tile position on top
5 index sub % tile llx - pattern xpos
7 -1 roll % get the y tile pos on top
3 index sub % tile ury - pattern ypos
translate
/$ctm matrix currentmatrix def % transfo matrix changed for that tile
@ep % execute the pattern description into that tile
pop pop pop pop
}
{pop pop}ifelse % current tile not visible through current clipping path
@rs % restore VM
} bd
%-- @th Tile pattern horizontally - @th -
/@th % perform tiling when inter-tile shift is only in the x direction
{
@sft %set first tile position into $tx $ty
0 1 $tly 1 sub % compute each tile position(in $xp, $yp)
{
dup $psx mul $tx add % X position of this row
{
dup $llx gt {$pwid sub}{exit}ifelse % make sure first x is at the left boundary
} loop
exch $phei mul $ty exch sub % first Y position in this row
% stack: first X and Y in row
0 1 $tlx 1 sub
{
$pwid mul
3 copy
3 -1 roll add exch % current tile position(x increased)
@tp % create a tile and play the pattern into that tile
pop
} for
pop pop % end of column 1
} for
} bd
%-- @tv Tile pattern vertically - @tv -
/@tv % perform tiling when inter-tile shift is only in the y direction
{
@sft %set first tile position into $tx $ty
0 1 $tlx 1 sub % compute each tile position(in $xp, $yp)
{
dup $pwid mul $tx add % X position of this column
exch $psy mul $ty exch sub % first Y position in this column
{
dup $ury lt {$phei add}{exit}ifelse % make sure first Y is at the top boundary
} loop
% stack: top X and Y in column
0 1 $tly 1 sub
{
$phei mul
3 copy sub % current tile position(y decreased)
@tp % create a tile and play the pattern into that tile
pop
} for
pop pop % end of column 1
} for
} bd
%-- @pf Pattern fill - @pf -
/@pf % fills the current path with the current fill pattern
{
@gs
$ctm setmatrix % reset normal ctm
$pm concat % concatenate current pattern matrix
@stb % current path bbox(not object bbox)
eoclip % current object shape is the clipping path
Bburx Bbury $pm itransform /$tury xd /$turx xd % get object's bbox in transformed space
Bbllx Bblly $pm itransform /$tlly xd /$tllx xd % get object's bbox in transformed space
/$wid $turx $tllx sub def % current path width
/$hei $tury $tlly sub def % current path height
@gs
% fill background with white ; watch for colorseps % overprinting
$vectpat
{
1 0 0 0 0 _ $o @scc % fill a white background
{
eofill
} if
}
{
% For bitmap fills, fill the background now and not for each tile to
% avoid seams. Use a bitmap to fill it since the clipping path is
% treated differently for bitmaps than it is for fills.
$t $c $m $y $k $n $o @scc
{
$tllx $tlly translate
$wid $hei scale
<00> 8 1 false [ 8 0 0 1 0 0 ] {} imagemask
/$bkg true def
} if
} ifelse
@gr
$wid 0 gt $hei 0 gt and % make sure current path bbox not NULL
{
$pn cvlit load aload pop % get pattern parms on stack
/$pd xd % $pd = Current pattern description
3 -1 roll sub /$phei xd % pattern width
exch sub /$pwid xd % pattern height
/$tlx $wid $pwid div ceiling 1 add def % # of tiles in the X direction
/$tly $hei $phei div ceiling 1 add def % # of tiles in the Y direction
$psx 0 eq % pattern x shift
{
@tv % then tile vertically
}
{
@th % otherwise tile horizontally
} ifelse
} if % if pattern size not null
@gr % restore initial graphic state
@np % clear the current path
/$bkg false def
} bd
% --- fountain fill support ------------------
%-- @dlt compute deltas - $dlt bprint -
/@dlt
{ % step 1 : get deltas between stripes into $dc $dm $dy $dk,
% # of steps in $fst
% also sets initial color values into $c $m $y $k
% returns bool: print or do not print
ColorSeparationMode 0 eq
{ % color separation is not active
/$dc $toc $tot mul $frc $frt mul dup /$c xd sub $fst 1 sub div def % compute deltas % original values
/$dm $tom $tot mul $frm $frt mul dup /$m xd sub $fst 1 sub div def
/$dy $toy $tot mul $fry $frt mul dup /$y xd sub $fst 1 sub div def
/$dk $tok $tot mul $frk $frt mul dup /$k xd sub $fst 1 sub div def
true
}
{ % color separation is active
$frt $frc $frm $fry $frk $frn $o @scc % set gray to current FROM color
dup
{ % store that gray value
/$frk 1 currentgray sub def
}
{
/$frk 0 def
} ifelse
$tot $toc $tom $toy $tok $ton $o @scc % set gray to current TO color
dup
{ % store that gray value
/$tok 1 currentgray sub def
}
{
/$tok 0 def
} ifelse
or % leaves boolean on stack: True if either from or to colors are to be
% printed
dup
{ % if it is to be printed, compute deltas (in black plane only)
/$c 0 def /$m 0 def /$y 0 def /$k $frk def
/$dc 0 def /$dm 0 def /$dy 0 def
/$dk $tok $frk sub $fst 1 sub div def % delta gray between steps
} if
}ifelse
} bd
%-- @ftl fountain fill linear llx lly urx ury @ftl -
/@ftl % generates linear fountain stripes to fill given bbox
{
1 index 4 index sub % Total width of bbox
dup $pad mul dup /$pdw xd % Store width of each pad in $pdw.
% stack: llx lly urx ury bbox-width $pdw
2 mul sub % width of gradation
$fst div /$wid xd % width of each stripe
2 index sub /$hei xd % compute height
pop % stack: llx, lly
translate
$c $m $y $k % starting color
4 copy % 4 colors on stack
ColorSeparationMode 0 ne % Doing color seps?
{ 1 exch sub setgray pop pop pop} % only use the gray component if so
{setcmykcolor}ifelse % otherwise, use them all
0 0 moveto 0 $hei lineto $pdw $hei lineto $pdw 0 lineto 0 0 lineto fill % draw starting pad
$pdw 0 translate % next band position
$fst % loop for each band
{
4 copy % 4 colors on stack
ColorSeparationMode 0 ne % Doing color seps?
{ 1 exch sub setgray pop pop pop} % only use the gray component if so
{setcmykcolor}ifelse % otherwise, use them all
0 0 moveto 0 $hei lineto $wid $hei lineto $wid 0 lineto 0 0 lineto fill % draw band
$wid 0 translate % next band position
$dk add 4 1 roll % set colors for next band
$dy add 4 1 roll
$dm add 4 1 roll
$dc add 4 1 roll
} repeat
$dk sub 4 1 roll % come back to last color for ending pad
$dy sub 4 1 roll
$dm sub 4 1 roll
$dc sub 4 1 roll
ColorSeparationMode 0 ne % Doing color seps?
{ 1 exch sub setgray pop pop pop} % only use the gray component if so
{setcmykcolor}ifelse % otherwise, use them all
0 0 moveto 0 $hei lineto $pdw $hei lineto $pdw 0 lineto 0 0 lineto fill % draw ending pad
} bd
%-- @ftr fountain fill radial llx lly urx ury @ftr -
/@ftr % generates radial fountain stripes to fill given bbox
{
% get radius
1 index 4 index sub % bbox width on stack
dup $rox mul /$row xd % Store width of center offset in $row
% stack: llx lly urx ury bbox-width
2 div % half bbox width
1 index 4 index sub % bbox height on stack
% stack: llx lly urx ury bbox-width/2 bbox-height
dup $roy mul /$roh xd % Store height of center offset in $roh
2 div % half bbox height
% stack: llx lly urx ury bbox-width/2 bbox-height/2
2 copy dup mul exch dup mul add sqrt % total radius on stack
$row dup mul $roh dup mul add sqrt add % add offset to radius
dup /$hei xd $fst div /$wid xd % width of each band(delta radius)in $wid
% original radius in $hei
% on stack: llx lly urx ury w/2 h/2
4 index add $roh add % y center with offset
exch
5 index add $row add % x center with offset
exch translate % origin in center of bbox
pop pop pop pop % don't need bbox anymore
currentflat dup 5 mul setflat % no need for extra precision on fountain circles
$c $m $y $k % starting color
% Draw the background pad
4 copy
ColorSeparationMode 0 ne % Doing color seps?
{ 1 exch sub setgray pop pop pop} % only use the gray component if so
{setcmykcolor}ifelse % otherwise, use them all
$wid 0 moveto 0 0 $hei 0 360 arc fill % draw circle at new center of bbox
% then scale according to the pad size
1.0 $pad 2 mul sub dup scale % scale around new center for pad
$fst % loop for each band
{
4 copy
ColorSeparationMode 0 ne % Doing color seps?
{ 1 exch sub setgray pop pop pop} % only use the gray component if so
{setcmykcolor}ifelse % otherwise, use them all
$wid 0 moveto 0 0 $hei 0 360 arc fill % draw circle at new center of bbox
/$hei $hei $wid sub def % next band radius in $hei
$dk add 4 1 roll % set colors for next band
$dy add 4 1 roll
$dm add 4 1 roll
$dc add 4 1 roll
} repeat
pop pop pop pop
setflat
} bd
%-- @ff fountain fill current path - @ff -
/@ff
{
@gs
@dlt % step 1 : get deltas between stripes into $dc $dm $dy $dk,
% # of steps in $fst
% also sets initial color values into $c $m $y $k
% puts a bool on the stack, same meaning as for @scc
{
$ctm setmatrix % reset normal ctm
eoclip % current path is clipping path
newpath
Bbllx Bblly moveto % compute size of box around current object
Bbllx Bbury lineto
Bburx Bbury lineto
Bburx Bblly lineto
$fan rotate
pathbbox
newpath
$fty 1 eq % fountain type ?
{@ftr} % radial fountain
{@ftl} ifelse % linear fountain
} if
@gr
@np
} bd
%--@Pf Postscript Fill - @Pf -
/@Pf
{ % Call user-defined Postscript fill with current parameters
@sv % don't take chances, save current state
% 20dec90:MB: Print PS fill only in composite
% or in black plane of color seps.
ColorSeparationMode 0 eq $ink 3 eq or
{ % PS fills can be printed
0 J 0 j [] 0 d % reset stroke attributes (all PS fills set line width)
$t $c $m $y $k $n $o @scc pop % set colour
$ctm setmatrix % reset matrix for PS-filling
% --- NOTE: All PS fills expect the current UNIT to be MIL (1/1000 inch)
% --- and Bburx, .. need to be specified in that unit as well.
72 1000 div dup matrix scale % scaling matrix
dup concat % change current ctm
dup Bburx exch Bbury exch itransform
ceiling cvi /Bbury xd
ceiling cvi /Bburx xd % change unit of BBox
Bbllx exch Bblly exch itransform
floor cvi /Bblly xd
floor cvi /Bbllx xd
$Prm aload pop % Bring the parameters on stack
$Psn load exec % execute the ps fill as desired
}
{ % Not proper color plane, fill in white instead.
1 setgray eofill
} ifelse
@rs % restore original state
@np % and clear the path
} bd
% -------------------------------------------------------------------
% -- painting attributes operators
%-- g Fill gray gray g -
/g
{
1 exch sub /$k xd % get black component
/$c 0 def /$m 0 def /$y 0 def /$t 1 def /$n _ def /$fil 0 def
} bd
%-- G Stroke gray gray G -
/G
{
1 exch sub /$K xd % get black component
/$C 0 def /$M 0 def /$Y 0 def /$T 1 def /$N _ def
} bd
%-- k Fill color cyan mag yel blk k -
/k
{
/$k xd /$y xd /$m xd /$c xd
/$t 1 def /$n _ def /$fil 0 def
} bd
%-- K Stroke color cyan mag yel blk K -
/K
{
/$K xd /$Y xd /$M xd /$C xd
/$T 1 def /$N _ def
} bd
%-- x Fill custom color cyan mag yel blk strname tint x -
/x
{
% Tint 0 is no ink; 1 is Full ink.
/$t xd /$n xd
/$k xd /$y xd /$m xd /$c xd /$fil 0 def
} bd
%-- X Stroke custom color cyan mag yel blk strname tint X -
/X
{
% Tint 0 is no ink; 1 is Full ink.
/$T xd /$N xd
/$K xd /$Y xd /$M xd /$C xd
} bd
%-- d setdash array offset d -
/d /setdash ld
%-- i set current flat flat i -
/i
{
dup 0 ne {setflat} {pop} ifelse
} bd
%-- j set line join join j -
/j /setlinejoin ld
%-- J set line cap cap J -
/J /setlinecap ld
%-- M set miter limit value M -
/M /setmiterlimit ld
%-- w set line width width w -
/w /setlinewidth ld
%-- O set overprint fill flag O -
/O
{
/$o xd
} bd
%-- R set overprint stroke flag R -
/R
{
/$O xd
} bd
%------------------------------------------------------------------------
%-- path construction operators
%-- c curveto smooth x1 y1 x2 y2 x3 y3 c -
/c /curveto ld
%-- C curveto corner x1 y1 x2 y2 x3 y3 C -
/C /c ld
%-- v curveto smooth x12 y12 x3 y3 v -
/v
{
4 -2 roll % get x12 y12 on top
2 copy % duplicate them
6 -2 roll curveto % move x3 y3 back to the end
} bd
%-- V curveto corner x12 y12 x3 y3 V -
/V /v ld
%-- y curveto smooth x1 y1 x23 y23 y -
/y
{
2 copy curveto % duplicate last point
} bd
%-- Y curveto corner x1 y1 x23 y23 Y -
/Y /y ld
%-- l lineto smooth x y l -
/l /lineto ld
%-- L lineto corner x y L -
/L /l ld
%-- rl rlineto x y rl -
/rl /rlineto ld
%-- m moveto x y m -
/m /moveto ld
%------------------------------------------------------------------------
% -- Painting operators
%-- n newpath - n -
/n /newpath ld
%-- N newpath - N -
/N /newpath ld
%-- F fill - F -
/F
{
matrix currentmatrix % save current transfo matrix on stack
$sdf {$scf $sca $scp @ss} if % alternate halftone screen?
$fil 1 eq
{@pf} % pattern fill
{ %
$fil 2 eq % fountain fill?
{@ff} % fountain fill path
{
$fil 3 eq % Postscript fill?
{@Pf} % PS fill
{
$t $c $m $y $k $n $o @scc % set FILL color, returns TRUE if we fill, FALSE if not
{eofill}
{@np} ifelse
} ifelse
} ifelse
} ifelse
$sdf {$dsf $dsa $dsp @ss} if % reset default halftone screen
setmatrix % reset original transfo matrix on stack
} bd
%-- f closepath fill - f -
/f
{
@cp F
} bd
%-- S stroke - s -
/S
{
matrix currentmatrix % save current transfo matrix on stack
$ctm setmatrix % reset normal ctm
$SDF {$SCF $SCA $SCP @ss}if % alternate halftone screen?
$T $C $M $Y $K $N $O @scc % set current stroke color, returns TRUE if we paint, FALSE if not
{
matrix currentmatrix
$ptm concat % set the pen matrix
stroke
setmatrix % reset the original matrix(from stack)
}
{@np}ifelse
$SDF {$dsf $dsa $dsp @ss}if % reset default halftone screen
setmatrix % reset original matrix set on stack
} bd
%-- s closepath stroke - s -
/s
{
@cp
S
} bd
%-- B fill, then stroke - B -
/B
{
@gs F @gr % fill
S % stroke
} bd
%-- b closepath, fill, stroke - b -
/b
{
@cp B
} bd
%-- W clip path - W -
/W
{
eoclip % clip to current path
} bd
%-- p pattern fill name xpos ypos xmag ymag angle reflect_flag
%-- reflect_angle skew_angle skew_imposed_angle
%-- matrix - p -
/p
{
/$pm xd % current pattern matrix
7 {pop} repeat % get rid of undesired parms(not implemented)
/$pyf xd /$pxf xd % remember X Y original offests
/$pn xd % remember pattern name
/$fil 1 def % set global for filling
} bd
%-- P pattern stroke (same as p)
/P
{ % NOT IMPLEMENTED
11 {pop} repeat % get rid of undesired parms(not implemented)
} bd
%-------------------------------------------------------------------------
% --- grouping information ---
%-- u begin group - u -
/u {} bd
%-- U end group - U -
/U {} bd
%-- A locked object flag A -
/A {pop} bd
%-- q gsave - g -
/q /@gs ld
%-- Q grestore - Q -
/Q /@gr ld
%--------------------------------------------------------------------
%--- pattern operators
%-- E define pattern name llx lly urx ury description E -
% a pattern will be defined as an array of 5 entries:
% (0)llx (1)lly (2)urx (3)ury (4)descrition
% the description is also an array of executable strings
/E
{
5 array astore % -- parms are in an array
exch cvlit exch def % -- defined with key equal to the name(string)
} bd
%-- ` place marker - ` -
/` {}bd
%-- ~ end place - ~ -
/~ {}bd
%-- @ pattern marker - @ -
/@ {}bd
%-- & pattern marker - & -
/& {}bd
% ------------------------------------------------------------------------
% -- CORELDRAW 3.X re-encoding vector for characters above 128
/CorelDrawReencodeVect [
16#0/grave 16#5/breve 16#6/dotaccent 16#8/ring 16#A/hungarumlaut 16#B/ogonek 16#C/caron 16#D/dotlessi
16#82/quotesinglbase/florin/quotedblbase/ellipsis/dagger/daggerdbl
16#88/circumflex/perthousand/Scaron/guilsinglleft/OE
16#91/quoteleft/quoteright/quotedblleft/quotedblright/bullet/endash/emdash
16#98/tilde/trademark/scaron/guilsinglright/oe
16#9F/Ydieresis
16#A1/exclamdown/cent/sterling/currency/yen/brokenbar/section
16#a8/dieresis/copyright/ordfeminine/guillemotleft/logicalnot/minus/registered/macron
16#b0/degree/plusminus/twosuperior/threesuperior/acute/mu/paragraph/periodcentered
16#b8/cedilla/onesuperior/ordmasculine/guillemotright/onequarter/onehalf/threequarters/questiondown
16#c0/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE/Ccedilla
16#c8/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex/Idieresis
16#d0/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis/multiply
16#d8/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn/germandbls
16#e0/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla
16#e8/egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis
16#f0/eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide
16#f8/oslash/ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis
] def
% -- @cc collect bitmap data - @cc string
% -- NOTE: Can be temporarily redefined by @N operator
/@cc
{ % collect bitmap information from current file (used by @C)
currentfile $dat readhexstring pop
} bd
% --------------------------- COREL EXTENSIONS ---------------------
% --Definitions of COREL extensions to the official AI language
% --All operators start with a @ followed by ONE letter.
%-- @sm save currentmatrix - @sm -
/@sm % save current transfo matrix into global $ctm
{
/$ctm $ctm currentmatrix def
} bd
%-- @E Define Object's bbox bbllx bblly bburx bbury matrix @E -
/@E
{ % must be called before painting if PATTERNS, PSFILLS, or FOUNTAINS are used
/Bbury xd /Bburx xd % upper right of OBJECT's bbox in absolute space
/Bblly xd /Bbllx xd % lower left of OBJECT's bbox in absolute space
} bd
%-- @c Close sub Path
/@c
{ % must be called during the path description
@cp
} bd
%-- @p COREL Tiled pattern fill name xoffset yoffset xshift yshift matrix pattern_type @p -
/@p
{
/$fil 1 def % set global for pattern filling
1 eq /$vectpat xd % pattern type: 0 - bitmap, 1 - vector
/$pm xd % current pattern matrix
/$psy xd % current Y shift before transformation(x & y exclusives)
/$psx xd % current X shift before transformation(x & y exclusives)
/$pyf xd /$pxf xd % remember X Y original offests (before transformation)
/$pn xd % remember pattern name
} bd
%-- @P COREL Postscript Fill parm1 .. parmn n fillname @P -
/@P
{ % COREL Postscript fill # of parms can vary
/$fil 3 def % set global for filling
/$Psn xd % PS-fill name
array astore % build array for PS-fill parms
/$Prm xd % parms in Prm
} bd
%-- @k Fountain fill CMYK-CMYK cy ma ye bl cy ma ye bl angle type pad xoff yoff @k -
/@k
{ % specifies that the next object will be filled with a fountain
% angle is in degrees , "type" is a flag (0 = linear, 1 radial)
% pad is the amount of padding to be set around edges( between 0 and 1.0 )
% xoff & yoff indicate the radial center offset (relative to bbox size (-1 to 1))
/$fil 2 def % set global for filling
/$roy xd /$rox xd /$pad xd
/$fty xd /$fan xd
$fty 1 eq {/$fan 0 def}if % if radial fill, force angle to 0
/$tok xd /$toy xd /$tom xd /$toc xd
/$frk xd /$fry xd /$frm xd /$frc xd
/$frn _ def /$frt 1 def /$ton _ def /$tot 1 def
} bd
%-- @x Fountain fill custom-custom cy ma ye bl name tint cy ma ye bl name tint angle type pad xoff yoff @x -
/@x
{ % specifies that the next object will be filled with a fountain
% angle is in degrees , "type" is a flag (0 = linear, 1 radial)
% pad is the amount of padding to be set around edges( between 0 and 1.0 )
% xoff & yoff indicate the radial center offset (relative to bbox size (-1 to 1))
% Tint 0 is no ink; 1 is Full ink.
/$fil 2 def % set global for filling
/$roy xd /$rox xd /$pad xd
/$fty xd /$fan xd
/$tot xd /$ton xd /$tok xd /$toy xd /$tom xd /$toc xd
/$frt xd /$frn xd /$frk xd /$fry xd /$frm xd /$frc xd
} bd
%-- @ii image preparation llx lly urx ury matrix @ii -
/@ii
{ % common bitmap code
concat % integrate transo right away
3 index 3 index m % set clipping path(cropping rect)
3 index 1 index l
2 copy l
1 index 3 index l
3 index 3 index l
clip % this is the clipping path
pop pop pop pop % pop cropping rect
} bd
% -- @i Gray/Mono bitmap pxlwid pxlhei bits llx lly urx ury
% background foreground
% cropllx croplly cropurx cropury
% matrix @i -
/@i % gray/mono bitmap image
% parms: pxlwid pxlhei : size of bitmap in pixels
% bits : # of bits per sample
% llx lly urx ury : total size of bitmap(before transfos)
% background: flag: 1: fill background with current fill attributes, 0: transparent background
% foreground: flag: 1: mask foreground with current stroke attributes, 0: transparent foreground
% cropllx croplly cropurx cropury: cropping rectangle(before transfos)
% matrix: additional transfo matrix for stretching/rotating, etc..
% NOTE: height can be negative if it comes from @N operator, in such a
% case, it must be printed upside down.
{
@sm @gs % save current ctm and graphics state
@ii % get common parameters
% stack: pxlwid pxlhei bits llx lly urx ury background_flag foreground_flag
6 index 1 ne % grayscale bitmap
{
/$frg true def
pop pop
}
{ % monochrome bitmap
% When doing colour seps of a monochrome bitmap, if the background is
% printed, then print the foreground also.
1 eq % Check if foreground flag is set.
{
$T $C $M $Y $K $N $O @scc % Set foreground color.
/$frg xd
}
{
/$frg false def
} ifelse
1 eq % Check if background flag is set.
{
@gs $ctm setmatrix
$t $c $m $y $k $n $o @scc % Check if background to be filled.
{
eofill % If bitmap to be painted, fill background.
} if
@gr
} if
} ifelse
% If the background of a bitmap fill was painted in "@pf", always paint
% the foreground.
/$frg $frg $bkg or def
@np % no path but clipping
% stack: pxlwid pxlhei bits llx lly urx ury
/$ury xd /$urx xd /$lly xd /$llx xd % bitmap rectangle
/$bts xd % # of bits per sample
/$hei xd /$wid xd % pixel size
/$dat $wid $bts mul 8 div ceiling cvi string def % string for data entry (each scan line)
$frg % foreground to be printed?
{
$SDF {$SCF $SCA $SCP @ss}if % alternate halftone screen? (determined by stroke attribs)
% set params for the imagemask/image operator
$llx $lly translate
$urx $llx sub $ury $lly sub scale
$wid $hei abs % if height is negative, print it upside down
$bts 1 eq {false}{$bts}ifelse % either false or #bits/sample
[ $wid 0 0
$hei neg 0
$hei 0 gt{$hei}{0}ifelse] % matrix(upside down if $hei is negative)
/@cc load % @cc can be redefined by @N
$bts 1 eq {imagemask}{image}ifelse
$SDF {$dsf $dsa $dsp @ss}if % reset default halftone screen
}
{
$hei abs {@cc pop} repeat % skip all lines
} ifelse % in color seps, the foreground might not be printed
@gr $ctm setmatrix % Restore graphics state & org matrix
} def % not bd because @cc can be redefined by @N
%-- @M Short Bitmap data starts - @M -
/@M
{ % called prior to defining a bitmap pattern/bitmap in vector pattern.
% Immediately following this call, there are a sequence of binary
% strings defining the bitmap data that will be put on the stack.
@sv % Save VM so that the space occupied by the string(s) is
% freed at the end of @N (which performs a restore).
% the @N operator must be called to free the stack from all those
% strings and to print the bitmap
% BITMAP DATA MUST FIT IN 64K
}bd
%-- @N Short bitmap pattern or bitmap in a vector pattern.
% string1 string2 ... stringn
%
% pxlwid pxlhei bits llx lly urx ury background foreground
% cropllx croplly cropurx cropury matrix 1 @N -
%
% or
%
% pxlwid pxlhei bits ncolors llx lly urx ury
% cropllx croplly cropurx cropury matrix 0 @N -
%
/@N % parms: pxlwid pxlhei : size of bitmap in pixels
% bits : # of bits per sample
% ncolors : number of colors (if color bitmap)
% llx lly urx ury : total size of bitmap(before transfos)
% background: flag: 1: fill background with current fill attributes, 0: transparent background
% (only for monochrome/grayscale bitmaps)
% foreground: flag: 1: mask background with current stroke attributes, 0: transparent background
% (only for monochrome/grayscale bitmaps)
% cropllx croplly cropurx cropury: cropping rectangle(before transfos)
% matrix: additional transfo matrix for stretching/rotating, etc..
% NOTE: height can be negative if it comes from @N operator, in such a
% case, it must be printed upside down.
{
/@cc {} def
% Make the bitmap pxl height negative, so that @i/@I knows that the data
% is upside down.
1 eq
{
12 -1 roll neg 12 1 roll % height negative
@I
}
{
13 -1 roll neg 13 1 roll % height negative
@i
} ifelse
@rs
} bd
% -- @I Color bitmap pxlwid pxlhei bits ncolors
% llx lly urx ury
% cropllx croplly cropurx cropury
% matrix @I -
/@I % Color bitmap image
% parms: pxlwid pxlhei : size of bitmap in pixels
% bits : # of bits per color component(24-bits color is 8 bits per component)
% ncolors: # of color components(RGB=3, CMYK=4)
% llx lly urx ury : total size of bitmap(before transfos)
% cropllx croplly cropurx cropury: cropping rectangle(before transfos)
% matrix: additional transfo matrix for stretching/rotating, etc..
{
@sm @gs % save current ctm and graphics state
@ii % get common parameters
@np % no path but clipping
% stack: pxlwid pxlhei bits ncolors llx lly urx ury
/$ury xd /$urx xd /$lly xd /$llx xd % bitmap rectangle
/$ncl xd % # of color components
/$bts xd % # of bits per color component
/$hei xd /$wid xd % pixel size
/$dat $wid $bts mul $ncl mul 8 div ceiling cvi string def % string for data entry (each scan line)
% set params for the colorimage operator
$llx $lly translate
$urx $llx sub $ury $lly sub scale % set current scale for bitmap size
$wid $hei abs % parms for colorimage
$bts
[ $wid 0 0
$hei neg 0
$hei 0 gt{$hei}{0}ifelse] % matrix(upside down if $hei is negative)
/@cc load
false $ncl
colorimage % colorimage redefined.
@gr $ctm setmatrix % restore graphics state & original matrix
} bd
% -------------------- text support ----------------------------
%--------------------------------------------------------------------
% -- text/font manipulation
%-- z findfont fontname size z -
/z
{ % sets current font, ptsize
exch findfont exch scalefont setfont % set the current font
} bd
%-- ZB define raster font
/ZB % fontname default_metrics_entry FontBBox FontMatrix ZB
{
9 dict
% stack: fontname default_metrics_entry FontBBox FontMatrix fontdict
dup begin
4 1 roll
% stack: fontname fontdict default_metrics_entry FontBBox FontMatrix
/FontType 3 def
/FontMatrix xd
/FontBBox xd
% stack: fontname fontdict default_metrics_entry
/Encoding 256 array def
0 1 255
{
Encoding exch /.notdef put
} for
/CharStrings 256 dict def
CharStrings /.notdef {} put
/Metrics 256 dict def
% stack: fontname fontdict default_metrics_entry
Metrics /.notdef 3 -1 roll put
% stack: fontname fontdict
/BuildChar
{
% stack: font char
exch
% stack: char font
dup /$char exch /Encoding get 3 index get def % Get character name.
% stack: char font
% Get origin of next char relative to current char and bounding box
% for current char and call setcachedevice.
dup /Metrics get $char get aload pop setcachedevice
begin
Encoding exch get CharStrings exch get
end
exec
} def
end
% stack: fontname fontdict
definefont pop
} bd
/ZBAddChar % metrics_entry char_proc char_code char_name fontname ZBAddChar
{
findfont begin
% stack: metrics_entry char_proc char_code char_name
dup 4 1 roll dup 6 1 roll
% stack: char_name metrics_entry char_name char_proc char_code char_name
Encoding 3 1 roll put
% stack: char_name metrics_entry char_name char_proc
CharStrings 3 1 roll put
% stack: char_name metrics_entry
Metrics 3 1 roll put
end
} bd
%-- Z re-encode font width-array encode-array newfontname fontname Z -
/Z
{
% get font dictionary on stack
findfont
dup maxlength 2 add dict exch % get its size & create new font dictionary
% on stack: width-array encode-array newfontname new-dict old-dict
% -- copy all entries from the old dict to the new dict
dup
{
1 index /FID ne % avoid copying the FID key
{
3 index % stack: ... newdict olddict key value newdict
3 1 roll put % store entry in dict
}
{
pop pop
} ifelse
} forall % for all entries in the old dict
% Now, get the new encoding array into the new dictionary
% stack: width-array encode-array newfontname new-dict old-dict
pop % don't need old dict anymore
dup dup /Encoding get
% stack: width-array encode-array newfontname newdict newdict Encoding
256 array copy % get a copy of original encoding array (to modify)
dup /$fe xd % prepare a pointer to the dest Encoding array
/Encoding exch put % store copy of original in encoding vect
% stack: width-array encode-array newfontname new-dict
dup /Fontname 3 index put % store it's own new name in that font
% stack: width-array encode-array newfontname new-dict
% store the new encoding array into the copy
3 -1 roll % |- width-array newname newdict encode-array
dup length 0 ne
{
0 exch
{ % the array has either numbers or names; initialize counter
dup type 0 type eq % check for numbers
{
exch pop % throw the old number away
}
{ % else, must be a char name
$fe exch 2 index exch put % put it into array
1 add % get ready for next
} ifelse
} forall
pop % remove counter
} if
% stack: width-array newname newfontdict
dup 256 dict
%stack: width-array newname newfontdict newfontdict metricsdict
dup /$met xd % prepare a pointer to the dest Metrics dict
/Metrics exch put
%stack: width-array newname newfontdict
% Character widths in width-array are for a 1000 unit character coordinate
% system. If this is not the coordinate system used for this font, the
% character widths have to be scaled appropriately. This scale factor
% is being calculated here.
dup /FontMatrix get
0 get
1000 mul
1 exch div
%stack: width-array newname newfontdict scale-factor
% Add character widths in width-array to the font if width-array contains
% 256 entries.
3 index length 256 eq
{
0 1 255
{
%stack: width-array newname newfontdict scale-factor index
dup $fe exch get
%stack: width-array newname newfontdict scale-factor index char
dup /.notdef eq
{
pop pop
}
{
%stack: width-array newname newfontdict scale-factor index char
5 index
3 -1 roll get
% stack: width-array newname newfontdict scale-factor char char-width
2 index mul
$met 3 1 roll put
} ifelse
} for
} if
pop
%stack: width-array newname newfontdict
definefont pop % then, record that new font in the font list
%stack: width-array
pop
} bd
%-- @ftx Text fill(special) string @ftx -
/@ftx % fill text with pattern or fountain
{
{ % loop for each character in the string
currentpoint 3 -1 roll
(0) dup 3 -1 roll 0 exch put % convert integer into a string
dup
@gs
true charpath % get character outline in path
$ctm setmatrix % set matrix for pattern filling
@@txt % pattern fill or fountain fill
@gr
@np
% set current point for next character
stringwidth pop 3 -1 roll add exch moveto
} forall
} bd
%--@ft fill text object string @ft -
/@ft % fill current text object
{
matrix currentmatrix exch % save current transfo matrix on stack
$sdf {$scf $sca $scp @ss} if % alternate halftone screen?
$fil 1 eq % pattern fill?
{/@@txt /@pf ld @ftx} % pattern fill on text
{
$fil 2 eq % fountain fill?
{/@@txt /@ff ld @ftx} % fountain fill on text
{
$fil 3 eq % Postscript fill?
{/@@txt /@Pf ld @ftx} % PS fill on text
{
$t $c $m $y $k $n $o @scc % set FILL color, returns TRUE if we fill, FALSE if not
{show} % show text
{pop} ifelse
} ifelse
} ifelse
} ifelse
$sdf {$dsf $dsa $dsp @ss} if % reset default halftone screen
setmatrix % reset original transfo matrix on stack
} bd
%--@st stroke text object string @st -
/@st % stroke current text object
{
matrix currentmatrix exch % save current transfo matrix on stack
$SDF {$SCF $SCA $SCP @ss} if % alternate halftone screen?
$T $C $M $Y $K $N $O @scc % set STROKE color, returns TRUE if we stroke, FALSE if not
{
{ % loop for each character in the string
currentpoint 3 -1 roll
(0) dup 3 -1 roll 0 exch put % convert integer into a string
dup
@gs
true charpath % get character outline in path
$ctm setmatrix $ptm concat % set matrix for stroking
stroke % stroke it
@gr
@np
% set current point for next character
stringwidth pop 3 -1 roll add exch moveto
} forall
}
{pop} ifelse % @scc
$SDF {$dsf $dsa $dsp @ss} if % reset default halftone screen
setmatrix % reset original transfo matrix on stack
} bd
%--@te print filled text string @te -
/@te % prints text as filled only
{
@ft % fill that text
} bd
%--@tr print stroked text string @tr -
/@tr % prints text as stroked only
{
@st % stroke that text
} bd
%--@ta fill & stroke text string @ta -
/@ta % prints text as filled & stroked
{
dup
@gs @ft @gr % fill the text
@st % then stroke text
} bd
%--@t@a stroke & fill text string @t@a -
/@t@a % prints text as stroked & filled
{
dup
@gs @st @gr % stroke the text
@ft % then fill text
} bd
%-- @tm set text matrix matrix @tm -
/@tm
{
% Create a VM snapshot to be restored when the text object processing
% is finished (See the T operator). This allows memory consumed for
% strings and matrices during processing of the text object to be freed.
/$textsave save def
@sm % save current matrix
concat
} bd
%-- e filled text - e -
/e
{
/t {@te} def % define operator t as @te
} bd
%-- r stroked text - r -
/r
{
/t {@tr} def % define operator t as @tr
} bd
%-- o invisible text - o -
/o
{
/t {pop} def % define operator t as nothing
} bd
%-- a fill&stroke text - a -
/a
{
/t {@ta} def % define operator t as @ta
} bd
%-- @a stroke&fill text - @a -
%--@a
/@a
{
/t {@t@a} def % define operator t as @t@a
} bd
%-- t text body string t -
/t {@te} def % default value: will be redefined by a,e,o,r, and I
%-- T end text (restore) - T -
/T
{
@np % Clear path.
$ctm setmatrix % Reset current matrix.
/$ttm matrix def % Reset extended text matrix.
% Restore VM snapshot.
$textsave restore
} bd
%-- @t 1-character text xpos ypos string @t -
/@t % -- paints a 1-character string at desired position
{
/$stm $stm currentmatrix def % save current matrix
3 1 roll % send string to bottom
moveto % move to character position
$ttm concat % add text matrix
t % draw the character (current t operator)
$stm setmatrix % restore saved matrix
} def % NO "bind def" because of t (can be modified)
%-- @n character angle angle @n -
/@n % set current caracter angle (held in matrix $ttm)
{
/$ttm exch matrix rotate def % modify current text matrix accordingly
} bd
% -- @s : Mark a space - @s -
/@s {} bd % does nothing but mark a space character in extended text
% -- @l : Mark an end of line - @l -
/@l {} bd % does nothing but mark an end of line in extended text
%-- @B stroke, then fill - @B -
/@B
{
@gs S @gr % stroke
F % fill
} bd
%-- @b closepath, stroke & fill path - @b -
/@b
{
@cp @B
} bd
%-- @w calligraphic pen matrix [matrix] bscale width height angle @w -
/@w
{ % set pen matrix "$ptm" to desired settings
% bscale is a flag: 1: "scale with object", 0 no scale
% matrix is passed only if bscale is 1 (object total matrix)
matrix rotate /$ptm xd % define $ptm to be rotation matrix
matrix scale % set pen shape
$ptm dup concatmatrix /$ptm xd
1 eq % if scale, concat object matrix
{
$ptm exch dup concatmatrix /$ptm xd
} if
1 w % basic thickness to be transformed by $ptm
} bd
%-- @g setscreen for fill freq ang spotproc 1 @g -
%or default screen for fill 0 @g -
/@g
{ % Set halftone screen for gray filling
% parm spotproc is a spot procedure name (ex: /@dot or /@lin)
1 eq dup /$sdf xd % set global flag
{ % next 3 parameters are set only if parm1 is 1
/$scp xd % Current spot func for fill
% 29-Jan-91:KB:Removed the negation of screen angle to make work like 1.21 did
/$sca xd % Current screen angle for fill
/$scf xd % Current screen frequency for fill
} if
} bd
%-- @G setscreen for stroke freq ang spotproc 1 @G -
%or default screen for stroke 0 @G -
/@G
{ % Set halftone screen for gray filling
% parm spotproc is a spot procedure name (ex: /@dot ot /@lin)
1 eq dup /$SDF xd % set global flag
{ % next 3 parameters are set only if parm1 is 1
/$SCP xd % Current spot func for stroke
% 29-Jan-91:KB:Removed the negation of screen angle to make work like 1.21 did
/$SCA xd % Current screen angle for stroke
/$SCF xd % Current screen frequency for stroke
} if
} bd
%-- @D setscreen for all document freq ang spotproc @D -
/@D
{ % Set halftone screen for all document
3 copy @ss % set that screen right now
/$dsp xd % default spot func name
/$dsa xd % default screen angle
/$dsf xd % default screen frequency function
} bd
%-- @j Begin Arrow head @j -
/@j
{ % -- DEF: BEGIN ARROW HEAD
% -- Stack: nothing
@sv % this is just a save followed by a new path
@np % Look at @J for the corresponding restore
} bind def
%-- @J End Arrow head @J -
/@J
{ % -- DEF: END ARROW HEAD
% -- Stack: nothing
@rs % this is just a grestore; Look at @j for the corresponding save
} bind def
% --- color separation support---
% --@sep Initialize color separation mode - @sep -
/@sep
{
% ColorSeparationMode defines the current mode for color separation
% Possible values are: 0-composite(no color seps)
% 1-CMYK Only (maximum four colors, custom colors converted)
% 2-CMYK+Customs (four colors + each of the customs)
/ColorSeparationMode where
{pop}
{
/ColorSeparationMode 0 def % if not defined previously: composite
/CurrentInkName (Composite) def % if not defined previously: composite
}ifelse
ColorSeparationMode 0 eq % if not defined previously: composite
{
/CurrentInkName (Composite) def
} if
% CurrentInkName is a string defining the current color plane being
% printed. The possible values are: (case sensitive, not to be translated)
% (Composite), (Cyan), (Magenta), (Yellow), (Black),
% or any of the custom colors defined in the document; e.g.: (Pantone 345)
% Custom color names are only valid when "ColorSeparationMode" is 2.
/CurrentInkName where
{pop}
{
/CurrentInkName (Composite) def % if not defined previously: composite
} ifelse
%-- Internally, a numeric variable ($ink) indicates the numeric value for the
% current ink, -1:composite, 0:cyan, 1:magenta, 2:yellow, 3:Black, 4: any custom
CurrentInkName (Composite) eq
{/$ink -1 def}
{
CurrentInkName (Cyan) eq
{/$ink 0 def}
{
CurrentInkName (Magenta) eq
{/$ink 1 def}
{
CurrentInkName (Yellow) eq
{/$ink 2 def}
{
CurrentInkName (Black) eq
{/$ink 3 def}
{
/$ink 4 def
} ifelse
} ifelse
} ifelse
} ifelse
} ifelse
} bd
@sep % -- And by default, call it (Can also be called in the setup section)
%-- @whi Fill Page white - @whi -
/@whi
{ %- Fill everything white
@gs
-72000 dup moveto
-72000 72000 lineto
72000 dup lineto
72000 -72000 lineto
closepath 1 setgray fill
@gr
} bd
%-- @neg Print negative - @neg -
/@neg
{ %def -- MAKE ALL COLORS NEGATIVE -- STACK: -
% Only set the GRAY scale transfer function since WALDO only
% Uses negative for color separations.
[{1 exch sub} /exec cvx currenttransfer /exec cvx] cvx settransfer
@whi % fill page in white (Will be turned into white)
} bd
%-- @reg Print registration mark x y @reg -
/@reg
{
% 25-Apr-91:KB:Reset line type to solid
[] 0 d
0 setgray .3 setlinewidth
2 copy 5.4 0 360 arc closepath
2 copy moveto 9 0 rlineto
2 copy moveto -9 0 rlineto
2 copy moveto 0 9 rlineto
moveto 0 -9 rlineto stroke
} bd
/leftbracket {(\050)} def
/rightbracket {(\051)} def