Source PostScript (splitpath.pps)

Retour Texte non formaté
%% syntaxe : t path_object splitpath --> subpath1 subpath2 %% soit [array1' array2'] [array1" array2"] %% le chemin est defini a partir des tableaux array1 (parametre) et array2 %% (les points). dim array2 = 2 * dim array1, et array1 trie par ordre %% croissant. Attention, t est dans ]t0 ; tn[. depose sur la pile les %% 2 sous chemins. Le point de parametre t appartient a chacun des 2 %% sous chemins /splitpath { 10 dict begin cvx exec /table_xy exch def /table_t exch def /t exch def /n table_t length 1 sub def %% (interpolparamfunct) == %% (t) == t == %% (t0) == table_t 0 get == %% (tn) == table_t n get == %% t0 < t < tn /i 0 def /ti 0 def { /i i 1 add store /ti table_t i get store t ti le { %% ti-1 < t =< ti /xi table_xy 2 i mul get def /yi table_xy 2 i mul 1 add get def /xi-1 table_xy 2 i 1 sub mul get def /yi-1 table_xy 2 i 1 sub mul 1 add get def /ti-1 table_t i 1 sub get def xi xi-1 sub ti ti-1 sub div t ti-1 sub mul xi-1 add /x exch def yi yi-1 sub ti ti-1 sub div t ti-1 sub mul yi-1 add /y exch def %% (sortie) == %% (i) == i == %% (xi-1 -> ) == xi-1 == %% (xi -> ) == xi == %% (x -> ) == 1 index == %% (y -> ) == 0 index == exit } if } loop [ [table_t 0 i getinterval aload pop t] [table_xy 0 2 i mul getinterval aload pop x y] ] [ [t table_t i n 1 add i sub getinterval aload pop] [x y table_xy 2 i mul n 1 add i sub 2 mul getinterval aload pop] ] end } def