#!/usr/bin/julia using ArgParse using LightGraphs; function parse_commandline() s = ArgParseSettings() @add_arg_table s begin "-p" help = "proba" arg_type = Float64 default = 0.5 "-r" help = "ratio (taille des cercles)" arg_type = Float64 default = 0.2 "-l" help = "taille de la légende" arg_type = Int default = 0 "-H" help = "taille horizontale de la grille" arg_type = Int default = 40 "-V" help = "taille verticale de la grille" arg_type = Int default = 30 "-d" help = "trace les arêtes duales" action = :store_true "-e" help = "ecart entre deux sites" arg_type = Int default = 20 "-f" help = "base fichier de sortie" default="essai-perco.eps" end return parse_args(s) end function trouve(nom, parsed_args) for pa in parsed_args if (pa[1]==nom) return pa[2] end end end parsed_args = parse_commandline() NH=trouve("H",parsed_args) NV=trouve("V",parsed_args) fichier=trouve("f",parsed_args) p=trouve("p",parsed_args) ecart=trouve("e",parsed_args) ratio=trouve("r",parsed_args) dual=trouve("d",parsed_args) l=trouve("l",parsed_args) rouge=" 1 0 0 setrgbcolor " noir="0 0 0 setrgbcolor " blanc="1 1 1 setrgbcolor " dur=" [] 0 setdash " pointille=" [3 3] 0 setdash " f = open(fichier,"w") print(f,"%!PS-Adobe-3.0 EPSF %%BoundingBox: 0 0 ",(NH+1)*ecart," ",(NV+1)*ecart+2*l,"\n") g = SimpleGraph(NH*NV) rh=rand(NH,NV) rv=rand(NH,NV) # graphe: création des horizontales for i=1:NH-1 for j=1:NV point=NH*(j-1)+i if (rh[i,j]1) global nd+=1 end for point=liste i=((point-1)% NH)+1 j=div((point-1),NH)+1 c[i,j]=nc end end maxcolor=min(nd,20) couleur=rand(3,max(maxcolor,11)) couleur[:,1]=[0;1;1] # bleu clair couleur[:,2]=[0;0;1] # bleu foncé couleur[:,3]=[1;1;0] # jaune couleur[:,4]=[1;0;0.5] # rouge magenta couleur[:,5]=[0;1;0] # vert couleur[:,6]=[1;0;0] # rouge couleur[:,7]=[0;0;0] # noir couleur[:,8]=[0.9;0.98;0.8] # lavande couleur[:,9]=[0.7; 0.3; 0.0] # marron couleur[:,10]=[1.0; 0.7; 0.0] # orange couleur[:,11]=[0.7; 0.3; 1.0] # violet # graphe: dessin des horizontales for i=1:NH-1 for j=1:NV point=NH*(j-1)+i if (rh[i,j]maxcolor) print(f,noir, "newpath ",i*ecart," ",j*ecart," ",ecart*ratio," 0 360 arc closepath stroke\n") else rouge=couleur[1,cl] vert=couleur[2,cl] bleu=couleur[3,cl] lac=string(rouge," ",vert," ",bleu," setrgbcolor ") print(f,noir, "newpath ",i*ecart," ",j*ecart," ",ecart*ratio," 0 360 arc closepath gsave ",lac,"fill grestore stroke\n") end end end if (l>0) print(f,"/Times-Roman findfont\n",l," scalefont setfont newpath ",NH*ecart/2," ",NV*ecart+l, " moveto (p=",p,") show") end close(f)