home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Computer Buyer 1996 April
/
BYER_0496.iso
/
buisapp
/
design
/
dwk3
/
libs
/
des_sty.pre
< prev
Wrap
Text File
|
1995-04-20
|
18KB
|
563 lines
%#BeginStyles: 30
%----------------------------------------------------------------------
% DES_STY.PRE v1.08
% This file contains some postscript procedures for use as fill styles
% or line styles. A PostScript programmer should be able to add new
% styles to this file and access them from within GST ArtWork.
%----------------------------------------------------------------------
% The first line in the file gives an approximate number for the total
% number of fill styles and line styles defined here.
% The value given there should be greater than or equal to the actual number
% of styles defined in the file. Excessive over-estimates waste memory.
%----------------------------------------------------------------------
% Each fill style is bracketed with %%BeginFill and %%EndFill
% lines: these must not have any leading spaces. The BeginFill keyword
% is followed by a colon, then a number of key=value pairs.
% Each keyword may be up to 20 characters, and the values must be integers.
% The first keyword is the procedure name, and the value is used by
% the program to refer to that procedure. The remaining keywords
% are descriptions of the parameters, along with their default values.
% An ampersand (&) character in the keyword name causes the following
% character to be underlined when displayed on the dialog box, and that
% character can then be used as a keyboard shortcut.
% A %%Comment line may optionally follow the %%BeginFill line; the text
% from the comment line will be displayed on the dialog box when that
% style is selected in the listbox.
% The actual postscript procedure name starts with a hash character (#)
% followed by the fill style name.
%----------------------------------------------------------------------
% example:
% %%BeginFill: WireMesh=106 &Width(pt)=28 &Height(pt)=28
% %%Comment: The background (between the wires) is transparent.
%
% The fill style 'WireMesh' has two parameters, width and height.
% On the dialog box, Alt-W selects the width, and Alt-H selects the height.
% it's name is shown in the listbox as WireMesh, and the comment
% about a transparent background appears on the form.
%
% The postscript procedure #WireMesh is called, with the width is pushed
% onto the stack, followed by the height. The procedure is expected to
% remove them from the stack itself.
%----------------------------------------------------------------------
% Line style procedures are bracketed with %%BeginLine and %%EndLine
% in a similar manner. The line thickness, colour, end and corner styles,
% and mitre limit from the main form are all initialised for postscript
% before the procedure is called.
% The postscript procedure name for a line style starts with an underline
% character, followed by the line style name.
%----------------------------------------------------------------------
% The procedures at the top, bracketed with %%BeginCommon and %%EndCommon
% are all sent to the printer if any of the line styles or fill styles
% are used.
%----------------------------------------------------------------------
% The section between %%BeginScreens and EndScreens defines the special
% postscript halftone screens, and is only transmitted to the printer if
% a fill styles uses one of the screens.
%----------------------------------------------------------------------
%----------------------------------------------------------------------
%%BeginCommon
%----- support routines for 'user defined' postscript styles -----%
%validate: range-check a value, leave on stack with name for 'def'
/validate { % value min max
2 copy 4 index % value min max min max value
lt % value min max min bool
exch 4 index % value min max bool min value
gt or % value min max bool
{
add 2 div % replace value with mid-range
exch pop
}{
pop pop % discard min & max
} ifelse
} bd
/mm { 39.37 mul } bd % convert mm to internal units
/pt { 1000 mul 72 div } bd % convert pt to internal units
%rand01: return a random number in range 0 to 1
/rand01 { rand bignum div dup truncate sub abs } bd
% random: min max : returns number in given range
/random { 1 index sub rand01 mul add } bd
% randpos: translate to random position
/randpos { Left Right random Bottom Top random translate } bd
%---- chain: for special line styles -----%
/chainmove {
dup /PosY ed dup /SegY ed /PathY ed
dup /PosX ed dup /SegX ed /PathX ed
/Part 0 def
} bd
/rect_to_polar { % dy dx -> rect_to_polar -> theta len
2 copy
0 ne exch 0 ne or {
2 copy atan 3 1 roll
dup mul exch dup mul add sqrt
}if
}bd
/chainline2 {
/EndY ed /EndX ed
EndY PosY sub EndX PosX sub
rect_to_polar
/Len ed /Theta ed
/Num Len BlockLen div def
/Whole Num round cvi def
Num 2.7 gt { % if a fair number, scale to fit
/BlockLen2 BlockLen Num mul Whole div def
/Part 0 def
}{
/BlockLen2 BlockLen def
/Part Num Whole sub def
} ifelse
Whole 1 ge {
matrix currentmatrix % save transformation matrix
PosX PosY translate
Theta rotate % transform to fit path
BlockLen2 BlockWid scale
.05 setlinewidth wif % set line width & winding fill
newpath % initialise path to empty
.5 1 Whole { % loop per block on path
/Pos ed
gs Pos 0 translate newpath DrawBlock gr
Pos .5 add 0 moveto % set current point at end of block
} for
setmatrix % restore transformation matrix
currentpoint % pick up end point of final block in current space
/PosY ed /PosX ed % and remember it
} if
/SegX EndX def
/SegY EndY def
} bd
/chainline {
2 copy /EndY ed /EndX ed
Part 0.5 gt { % if there's any gap at end of last segment
EndY SegY sub EndX SegX sub
rect_to_polar
/Len ed /Theta ed % get this segment length
Len BlockLen 2 mul gt % if this segment is a long one
{
PosX PosY % stack current end point
% transform an identity matrix to match tile's transformation
BlockLen BlockWid Theta SegX SegY
matrix translate rotate scale
itransform % calculate point's inverse transformation: x y
2 copy %for debugging: x y x y
% if ((abs(x) < abs(y)) or (x >= 0) treat as a sharp corner
exch dup % y x x
0 ge 3 1 roll % bool y x
abs exch abs % bool abs(x) abs(y)
lt or {
% debug code:
% PosX PosY SegX SegY Part break
% sharp corner: simply adjust start point
/PosX SegX def
/PosY SegY def
} if
pop pop % debugging, pop spare x & y
}if
}if
chainline2 % do rest of line up to original endpoint
} bd
/chain { % blocklength blockwidth proc
/DrawBlock ed
1 25 validate mm /BlockWid ed
1 25 validate mm /BlockLen ed
setcolour
Print? { % if printing this separation...
gs
flatp
{chainmove}
{chainline}
{error}
{PathX PathY chainline}
pathforall
gr
} if
} bd
%%EndCommon
%---------------------------------------------------------------------------
%%BeginScreens=Default,Dot,Ellipse,Line,Propeller,Square Dots,Square Grid,Triangle,Diamond,White dot
/Screens [
{} % to be replaced by default during setup
{ dup mul exch dup mul add 1 exch sub } bind % Dot: simple black dot
{ dup 5 mul 8 div mul exch dup mul exch add sqrt 1 exch sub } bind % Ellipse
{ exch pop abs 1 exch sub } bind % Line (horiz at 0 degrees)
{ 2 copy .001 add atan cvi 72 mod 72 sub abs 72 div 3 1 roll
dup mul exch dup mul add 1 exch sub add 2 div } bind % Propellor (5 blade)
{ abs exch abs 2 copy gt {exch} if pop 2 mul 1 sub } bind % Square Dots
{ abs exch abs 2 copy gt {exch} if pop 2 mul 1 exch sub } bind % Square Grid
{ 2 exch sub exch abs 2 mul sub 3 div } bind % Triangle
{ abs exch abs add 1 exch sub } bind % Diamond
{ dup mul exch dup mul add 1 sub } bind % White dot
] def
/setscr {
exch AngleFix add exch % adjust angle if landscape
Screens exch get % convert screen number to procedure
setscreen % and select the halftone screen
% use default transfer function for special effects
% as the normalise function only works for default screen setup
{?Negative DefTran}settransfer
} bd
%%EndScreens
%---------------------------------------------------------------------------
%%BeginFill: Grass=100 &Blades=100 S&mallest(mm)=5 &Largest(mm)=10
%%Comment: random blades of grass - colour1->background colour2->outline
/#Grass {
5 25 validate mm /MaxN ed
mm 2 mm MaxN 1 sub validate /MinN ed
1 250 validate /N ed
gs _fill gr % fill background
setcolour % set colour for foreground
0 setlinewidth
clipper
N {
gs
randpos
MinN MaxN random 10 div dup
rand01 .5 sub mul exch neg scale
np 0 0 m 0 4 1 9 4 10 c 2 7 2 4 2 0 c
gs cp 0 _fill gr ~stroke
gr
} repeat
gr
} bd
%%EndFill
%%BeginFill: Leaves=101 &Number=100 S&mallest(mm)=5 &Largest(mm)=20
%%Comment: random leaf shapes
/#Leaves {
5 25 validate mm /MaxN ed
mm 2 mm MaxN 1 sub validate /MinN ed
1 250 validate /N ed
GradFillDict begin
grad_common_init
/GradType 0 def
clipper % clip to path
N { % loop N times
gs
rand01 grad_common_middle % random colour within range
randpos % translate to random position
MinN MaxN random dup scale % set scale for leaf
0 360 random rotate % and rotation
np 0 0 m 0 .5 .5 1 1 1 c 1 .5 .5 0 0 0 c cp ~fill
gr
} repeat
gr
end
} bd
%%EndFill
%%BeginFill: Bricks=102 &Width(pt)=24 &Height(pt)=6 &Mortar(pt)=1
%%Comment: colour1->bricks, colour2->mortar
/#Bricks {
0 4 validate pt /Lw ed
3 36 validate pt /Bheight ed
6 72 validate pt /Bwidth ed
Lw setlinewidth
gs _fill gr % start by plain filling background with first colour
setcolour % now select second colour for detail
clipper
Left Top translate
% insert commands to fill area from (0,0) to (Width,Height)
/Flag? false def
0 Bheight Height abs {
pop
np 0 0 m Width 0 l ~stroke
Flag? { Bwidth 2 div }{ 0 }ifelse
Bwidth Width {
/X ed
np X 0 m X Bheight l ~stroke
} for
/Flag? Flag? not def
0 Bheight translate
} for
gr
} bd
%%EndFill
%%BeginFill: Hatching=103 &Angle=45 Mi&nDist(pt)=2 &MaxDist(pt)=6 &Linewidth(pt)=1
%%Comment: only uses colour1
/#Hatching {
1 6 validate pt /Lw ed
pt Lw 36 pt validate /MaxN ed
pt Lw MaxN validate /MinN ed
/Theta ed
Lw setlinewidth
setcolour
gs Theta rotate clipper
Left Top translate
% insert commands to fill area from (0,0) to (Width,Height)
/Y 0 def
{
np 0 Y m Width Y l ~stroke
/Y Y MinN MaxN random add def
Y Height abs ge { exit } if
} loop
gr gr
setcolour
} bd
%%EndFill
%%BeginFill: GraphMetric=104
%%Comment: cm and mm graph paper; only uses colour1
/#GraphMetric { % no parameters
setcolour
clipper
Left Top translate
2 setlinewidth
0 1 mm Width { /X ed np X 0 m X Height l ~stroke } for
0 1 mm Height { /Y ed np 0 Y m Width Y l ~stroke } for
7 setlinewidth
5 mm 10 mm Width { /X ed np X 0 m X Height l ~stroke } for
5 mm 10 mm Height { /Y ed np 0 Y m Width Y l ~stroke } for
14 setlinewidth
0 10 mm Width { /X ed np X 0 m X Height l ~stroke } for
0 10 mm Height { /Y ed np 0 Y m Width Y l ~stroke } for
gr
setcolour
} bd
%%EndFill
%%BeginFill: GraphPaper=105
%%Comment: inches graph paper; only uses colour1
/#GraphPaper { % no parameters
setcolour
clipper
Left Top translate
2 setlinewidth
0 100 Width { /X ed np X 0 m X Height l ~stroke } for
0 100 Height { /Y ed np 0 Y m Width Y l ~stroke } for
7 setlinewidth
500 1000 Width { /X ed np X 0 m X Height l ~stroke } for
500 1000 Height { /Y ed np 0 Y m Width Y l ~stroke } for
14 setlinewidth
0 1000 Width { /X ed np X 0 m X Height l ~stroke } for
0 1000 Height { /Y ed np 0 Y m Width Y l ~stroke } for
gr
setcolour
} bd
%%EndFill
%%BeginFill: Squares=106
%%Comment: quarter inch squares; only uses colour1
/#Squares { % no parameters
setcolour
clipper
Left Top translate
2 setlinewidth
0 250 Width { /X ed np X 0 m X Height l ~stroke } for
0 250 Height abs { /Y ed np 0 Y m Width Y l ~stroke } for
gr
setcolour
} bd
%%EndFill
%%BeginFill: Rough=107 lo=0 hi=255
%%Comment: rough pseudo-random texture
/#Rough {
/MaxN exch def /MinN exch def
setcolour
clipper
Left Top translate
Width Height scale
100 100 8 [ 100 0 0 -100 0 100 ]
{ 1 string dup 0 MinN MaxN random cvi put }
image
gr
setcolour
} bd
%%EndFill
%----------------------------------------------------------------------------
%%BeginLine: Neon=200 &Width(pt)=5
%%Comment: neon-light effect (doesn't work in colour)
/_Neon {
2 12 validate pt /Lw ed
setcolour % pick up (and ignore) line colour
gs Lw setlinewidth 50 _stroke gr
gs Lw 2 div setlinewidth 100 _stroke gr
gs 10 setlinewidth 0 _stroke gr
} bd
%%EndLine
%%BeginLine: Calligraphic=202 &Penfactor=5 &Angle=30
%%Comment: Maximum line width is defined on the main form.
/_Calligraphic {
/Theta ed
2 20 validate
/PenScale ed
setcolour
gs currentlinewidth Theta rotate 1 1 PenScale div scale setlinewidth ~stroke gr
} bd
%%EndLine
%%BeginLine: TripleLine=203
%%Comment: works best if line width >= 4pt
/_TripleLine {
setcolour
Print? { % if printing this separation...
gs stroke gr currentlinewidth dup
gs .75 mul setlinewidth 1 setgray stroke gr
gs .4 mul setlinewidth stroke gr
} if
} bd
%%EndLine
%%BeginLine: Dingbats=205 &Pointsize=14 &Dingbat=118
/_Dingbats {
dup 128 gt { 161 254 validate }{ 33 126 validate } ifelse /DingChar ed
5 72 validate pt
40 div dup % convert to MM for chain
tempstr 0 DingChar put
gs
/Dingfont /ZapfDingbats findfont def
{
Dingfont 1 scalefont setfont
-.5 -.5 moveto tempstr show
} chain
gr
} bd
%%EndLine
%%BeginLine: DoubleLine=206
%%Comment: This draws a thin white line down the middle
/_DoubleLine {
setcolour
Print? { % if printing this separation...
gs stroke gr
gs currentlinewidth 3 div setlinewidth
1 setgray stroke gr
} if
} bd
%%EndLine
%%BeginLine: Charcoal=207 &Lightest(%)=25 &Darkest(%)=75 &Width(pt)=7
%%Comment: Drawn in black
/randdot { pop pop rand01 .5 sub } bd
/_Charcoal { % light dark width
2 12 validate pt /Lw ed
10 100 validate /Dark ed
0 Dark 2 sub validate /Light ed
Dark Light sub log 3 mul /Delta ed
Light Delta Dark {
/N exch def
N 100 add 10 div N 5 add { randdot } setscreen
100 N sub 100 Light sub div Lw mul setlinewidth
gs N _stroke gr
} for
} bd
%%EndLine
%%BeginLine: Dots=208 &Length(mm)=4 &Width(mm)=4
/_Dots { { 0 0 .5 0 360 arc fill } chain } bd
%%EndLine
%%BeginLine: Triangles=209 &Length(mm)=4 &Width(mm)=4
/_Triangles { { -.5 .5 m .5 0 l -.5 -.5 l cp fill } chain } bd
%%EndLine
%%BeginLine: TrianglesReversed=210 &Length(mm)=4 &Width(mm)=4
/_TrianglesReversed { { .5 .5 m -.5 0 l .5 -.5 l cp fill } chain } bd
%%EndLine
%%BeginLine: StarsFilled=211 &Length(mm)=4 &Width(mm)=4
/_StarsFilled { { -.45 .15 m .45 .15 l -.35 -.45 l 0 .45 l .3 -.45 l cp fill } chain } bd
%%EndLine
%%BeginLine: Circles=212 &Length(mm)=4 &Width(mm)=4
/_Circles { { 0 0 .5 0 360 arc stroke } chain } bd
%%EndLine
%%BeginLine: StarsHollow=214 &Length(mm)=4 &Width(mm)=4
/_StarsHollow { { -.45 .15 m .45 .15 l -.35 -.45 l 0 .45 l .3 -.45 l cp stroke } chain } bd
%%EndLine
%%BeginLine: Zigzags=215 &Length(mm)=4 &Width(mm)=4
/_Zigzags { { -.5 0 m 0 .5 l 0 -.5 l .5 0 l stroke } chain } bd
%%EndLine
%%BeginLine: GreekKey=216 &Length(mm)=4 &Width(mm)=4
/_GreekKey { { -.5 0 m -.5 .4 l .3 .4 l .3 -.25 l -.1 -.25 l -.1 0 l
.1 0 l .1 .25 l -.3 .25 l -.3 -.4 l .5 -.4 l .5 0 l stroke } chain } bd
%%EndLine
%%BeginLine: Hearts=217 &Length(mm)=4 &Width(mm)=4
/_Hearts { { 0 -.5 m -.4 -.1 l -.5 0 -.5 .1 -.4 .3 c -.3 .4 -.1 .4 0 .2 c
.1 .4 .3 .4 .4 .3 c .5 .2 .5 0 .4 -.1 c cp fill } chain } bd
%%EndLine
%%BeginLine: Diamonds=218 &Length(mm)=4 &Width(mm)=4
/_Diamonds { { -.5 0 m 0 .5 l .5 0 l 0 -.5 l cp fill } chain } bd
%%EndLine
%%BeginLine: Rope=219 &Length(mm)=4 &Width(mm)=4
/_Rope { { -.8 .3 m -.6 .5 0 .5 .2 .3 c .8 -.3 l
.6 -.5 0 -.5 -.2 -.3 c cp gs 0 _fill gr stroke } chain } bd
%%EndLine
%%BeginLine: Waves=220 &Length(mm)=4 &Width(mm)=4 &Number=2
/_Waves {
1 5 validate /N ed
{ gs np 0 -.5 translate 1 1 N div scale
N{
-.5 .5 m -.35 1.15 -.15 1.15 0 .5 c
.15 -.15 .35 -.15 .5 .5 c
0 1 translate
}repeat
stroke gr
} chain
} bd
%%EndLine