2009/11/12

PostScript 条件分岐

7.1-ConditionExecution-1.ps 

% ---variables---------------------------------------------
/LM 72 def
/RM 212 3 mul def
/ypos 720 def
/lineheight 40 def

% ---procedures--------------------------------------------

/newline{
    ypos lineheight sub
    /ypos exch def
    LM ypos moveto
} def

/prtstr{
    dup stringwidth pop
    currentpoint pop
    add RM
gt
    {newline} if
    show
} def

/choosefont{
    exch findfont exch scalefont setfont
} def

% ---main program------------------------------------------

/Times-Italic findfont 50 scalefont setfont

LM ypos moveto
(If ) prtstr
(you ) prtstr
(tell ) prtstr
(the ) prtstr
(truth, ) prtstr
(you ) prtstr
(don't ) prtstr
(have ) prtstr
(to ) prtstr
(remember ) prtstr
(anything. ) prtstr
(- Mark ) prtstr
(Twain ) prtstr

showpage

7.1-ConditionExecution-2.ps

% --- variables ----------------------------------------
/scalefactor 1 def
/counter 0 def

% --- procedures ---------------------------------------
/DecreaseScale {
    scalefactor .2 sub
    /scalefactor exch def
} def

/IncreaseConter {
    /counter counter 1 add def
} def

/trappath {
    0 0 moveto
    90 0 rlineto
    -20 45 rlineto
    -50 0 rlineto
    closepath
} def

/doATrap {
    gsave
    1 scalefactor scale
    trappath
    counter 2 mod
    0 eq {.5} {0} ifelse
    setgray fill
    grestore
} def

% --- programs -----------------------------------------
0 0 moveto
250 350 translate

10 {
    IncreaseConter
    doATrap
    DecreaseScale
    0 20 translate
} repeat

showpage

 

  • eq =
  • ne ≠
  • gt >
  • lt <
  • ge >=
  • le <=

 

PostScript(R) Language Tutorial and Cookbook (APL)

PostScript(R) Language Tutorial and Cookbook (APL)

posted with amazlet at 09.10.07

Adobe Systems Inc.
Addison-Wesley Professional
売り上げランキング: 235737

おすすめ度の平均: 5.0

5 まず最初に読むべき入門書
5 効率の良いPostScript書くなら…

Amazon.co.jp で詳細を見る

 

0 件のコメント:

コメントを投稿