Changeset 4419 for trunk/examples

Show
Ignore:
Timestamp:
08/10/08 08:53:07 (5 months ago)
Author:
pmoura
Message:

Updated the SWI-Prolog Sudoku constraint example with the help of Markus Triska.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/examples/constraints/swipl/sudoku.lgt

    r4418 r4419  
    7676    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 
    7777 
    78     postscript("systemdict /.setlanguagelevel known { 2 .setlanguagelevel} if \ 
    79      /Palatino-Bold findfont 5 scalefont setfont \ 
    80      320 9 div dup scale 0 setlinewidth -0.9 -0.9 translate \ 
    81      /num { gsave 10 exch sub translate 0.5 0.25 translate 0.16 dup scale \ 
    82          dup stringwidth pop -2 div 0 moveto show grestore } bind def \ 
    83      /clear { gsave 10 exch sub translate 1 setgray 0.1 dup 0.8 dup rectfill \ 
    84          grestore } bind def \ 
    85      1 1 10 { gsave dup 1 moveto 10 lineto stroke grestore } for \ 
    86      1 1 10 { gsave dup 1 exch moveto 10 exch lineto stroke grestore } for \ 
    87      1 3 9 { 1 3 9 { 1 index gsave translate 0.05 setlinewidth 
    88          0 0 3 3 rectstroke grestore } for pop } for\n"). 
     78    postscript --> 
     79        "systemdict /.setlanguagelevel known { 2 .setlanguagelevel} if \ 
     80        /Palatino-Bold findfont 5 scalefont setfont \ 
     81        320 9 div dup scale 0 setlinewidth -0.9 -0.9 translate \ 
     82        /num { gsave 10 exch sub translate 0.5 0.25 translate 0.16 dup scale \ 
     83            dup stringwidth pop -2 div 0 moveto show grestore } bind def \ 
     84        /clear { gsave 10 exch sub translate 1 setgray 0.1 dup 0.8 \ 
     85            dup rectfill grestore } bind def \ 
     86        1 1 10 { gsave dup 1 moveto 10 lineto stroke grestore } for \ 
     87        1 1 10 { gsave dup 1 exch moveto 10 exch lineto stroke grestore } for \ 
     88        1 3 9 { 1 3 9 { 1 index gsave translate 0.05 setlinewidth 
     89            0 0 3 3 rectstroke grestore } for pop } for\n". 
    8990 
    9091    /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
     
    9394 
    9495    show(Options, Rows) :- 
    95         open(pipe('gs -dNOPAUSE -g680x680 -r150 -q -'), write, Out, 
    96             [buffer(false),alias(gs)]), 
     96        open(pipe('gs -dNOPAUSE -g680x680 -dGraphicsAlphaBits=2 -r150 -q -'), write, Out, [buffer(false),alias(gs)]), 
    9797        tell(Out), 
    98         postscript(Ps), 
     98        phrase(postscript, Ps), 
    9999        format(Ps), 
    100100        sudoku(Rows), 
    101         animate(Rows), 
    102101        append(Rows, Vs), 
    103         labeling(Options, Vs), 
    104         finish. 
    105     show(_, _) :- finish, close(gs), fail. 
     102        call_cleanup((animate(Rows),labeling(Options, Vs),finish), close(gs)). 
    106103 
    107104    finish :- 
     
    109106        % fill the buffer to make 'gs' process all generated output 
    110107        ignore((between(1,500,_), 
    111             format("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n"), 
    112             fail)), 
     108                format("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n"), 
     109                fail)), 
    113110        flush_output. 
    114111