/xstquadrillage 1 def
/ystquadrillage 1 def
/quadrillagegray .4 def
/quadrillagewd .25 def
%% trace d'un trait horizontal
/shrule { %% syntaxe y shrule
newpath
dup %% y y
xmin exch %% y xmin y
smoveto %% y
xmax exch %% xmax y
slineto
stroke
} def
%% trace d'un trait vertical
/svrule { %% syntaxe x shrule
newpath
dup %% x x
ymin %% x x ymin
smoveto %% x
ymax %% x ymax
slineto
stroke
} def
/quadrillage {
gsave
quadrillagegray setgray
quadrillagewd setlinewidth
masque
newpath
ymin ystquadrillage div truncate ystquadrillage mul
ystquadrillage ymax {shrule} for
xmin xstquadrillage div truncate xstquadrillage mul
xstquadrillage xmax {svrule} for
stroke
grestore
} def
%% /quadrillage {
%% gsave
%% quadrillagegray setgray
%% masque
%% newpath
%% ymin floor ystquadrillage ymax {shrule} for
%% xmin floor xstquadrillage xmax {svrule} for
%% stroke
%% grestore
%% } def
%% syntaxe : xdiv ydiv doublequadrillage
/doublequadrillage {
5 dict begin
/ydiv exch def
/xdiv exch def
gsave
/xstquadrillage xstquadrillage xdiv div store
/ystquadrillage ystquadrillage ydiv div store
/quadrillagegray quadrillagegray 2 mul store
quadrillage
grestore
gsave
/xstquadrillage xstquadrillage xdiv mul store
/ystquadrillage ystquadrillage ydiv mul store
/quadrillagegray quadrillagegray 2 div store
currentlinewidth 2 mul setlinewidth
quadrillage
grestore
end
} def
%% les epaisseurs utilisees
/quadrillagewidth [.7 .4 .2] def
%% Attention : sans argument tableau, l'epaisseur de ligne utilisee
%% est l'epaisseur courante
%% syntaxe : [x y xs ys xss yss] {color} Quadrillage
%% ou bien
%% syntaxe : [x y xs ys] {color} Quadrillage
%% ou bien
%% syntaxe : x y {color} Quadrillage
%% ou {color} est toujours optionnel
/Quadrillage {
gsave
dup xcheck
{exec}
if
dup isarray
{
/tableau exch def
tableau length 5 ge
{ %% tableau de longueur 6
quadrillagewidth 2 get setlinewidth
tableau 2 getp qu@drillage
}
if
tableau length 3 ge
{ %% tableau de longueur 4 ou 6
quadrillagewidth 1 get setlinewidth
tableau 1 getp qu@drillage
}
if
%% toujours
quadrillagewidth 0 get setlinewidth
tableau 0 getp qu@drillage
}
{qu@drillage}
ifelse
grestore
} def
/Quadrillage+ {
gsave
dup xcheck
{exec}
if
dup isarray
{
/tableau exch def
tableau length 5 ge
{ %% tableau de longueur 6
quadrillagewidth 2 get setlinewidth
tableau 2 getp qu@drillage+
}
if
tableau length 3 ge
{ %% tableau de longueur 4 ou 6
quadrillagewidth 1 get setlinewidth
tableau 1 getp qu@drillage+
}
if
%% toujours
quadrillagewidth 0 get setlinewidth
tableau 0 getp qu@drillage+
}
{qu@drillage+}
ifelse
grestore
} def
%% syntaxe : xstep ystep qu@drillage
/qu@drillage {
2 dict begin
/ystep exch def
/xstep exch def
gsave
newpath
ymin ystep div truncate ystep mul
ystep ymax {shrule} for
xmin xstep div truncate xstep mul
xstep xmax {svrule} for
stroke
grestore
end
} def
%% syntaxe : xstep ystep qu@drillage
/qu@drillage+ {
2 dict begin
/ystep exch def
/xstep exch def
gsave
ymin ystep ymax {shrule} for
xmin xstep xmax {svrule} for
grestore
end
} def
|