new pictures

This commit is contained in:
Yann Esposito 2012-11-15 16:29:27 +01:00
parent 4ffe4b1adc
commit aee58233ad
5 changed files with 112 additions and 9 deletions

View file

@ -25,7 +25,14 @@ green :=(0.52156862745098 ,0.6 ,0.0);
%%%%%%%%%%%%%%%%%%%%
u:=.5cm; % unity
gu:=5u; % distance between states
nodesize := 1.2u; %size of a node
nodesize := u + .1cm; %size of a node
def resize(expr nu)=
u:=nu;
gu:=5u; % distance between states
nodesize := u; %size of a node
nodespace := u+.1cm; %size of a node
enddef;
% return the middle of a path
vardef midpoint(expr p)=
@ -91,7 +98,7 @@ vardef edgeFull(expr posA,posB,inan,outan) =
path sub;
path s;
s := posA {dir inan} .. {dir outan} posB ;
sub := shorten(s,nodesize);
sub := shorten(s,nodespace);
sub
enddef;
@ -138,16 +145,22 @@ enddef;
%% LOOPS %%
%% %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
vardef dist(expr a,b)=
numeric width,height,res;
width:=xpart b - xpart a;
height:=ypart b - ypart a;
res:=sqrt(width*width + height*height);
enddef;
% return a loop
vardef loopFull(expr a,b,an) =
pair ba,ea;
path circ,p,s;
p:=a{1,1}..b..{1,-1}cycle;
circ:= fullcircle scaled nodesize shifted a;
circ:= fullcircle scaled nodespace shifted a;
ba = circ intersectionpoint (subpath (0,1) of p);
ea = circ intersectionpoint (subpath (1,2) of p);
s:= ba{1,1}..b..{1,-1}ea;
s rotated an
s shifted -a rotated an shifted a
enddef;
vardef loopPoint(expr a,b) =
@ -195,21 +208,23 @@ enddef;
% draw some state with some label insize
def drawState(expr pos,l) =
% Draw the circle
draw fullcircle scaled u shifted pos;
draw fullcircle scaled nodesize shifted pos;
% Draw the label with the right size
picture lab,reslab;
numeric height,width;
numeric size;
lab=thelabel(TEX("$"&l&"$"),pos);
lab=thelabel(TEX("$"&l&"$"),origin);
height:=ypart (ulcorner lab - llcorner lab);
width :=xpart (urcorner lab - ulcorner lab);
size := sqrt(height*height + width*width);
if size>u:
reslab:=lab scaled (u/size);
if size>.9nodesize:
reslab:=lab scaled (.9nodesize/size) shifted pos;
else:
reslab:=lab;
reslab:=lab shifted pos;
fi
% help for debug to draw boundaries
% draw ulcorner reslab -- urcorner reslab -- lrcorner reslab -- llcorner reslab -- cycle;
draw reslab;
enddef;

View file

@ -0,0 +1,66 @@
pair int,bool,func,intlist,list;
resize(.8cm);
int=origin;
% drawoptions (withcolor baseOne withpen pencircle scaled 1.2);
intlist=int shifted (gu,0);
func=int shifted (0,-.6gu);
bool=func shifted (gu,0);
list=func shifted (2u,0);
drawState(int,"\mathtt{Int}");
drawState(bool,"\mathtt{Bool}");
drawState(func,"\mathtt{a\rightarrow b}");
drawState(intlist,"\mathtt{[Int]}");
drawState(list,"\mathtt{[a]}");
drawLoopPoint(int,int shifted (0,1.6u),"\mathtt{sqrt}");
drawEdge(int,int,"\mathtt{id}");
drawEdgeAngle(int,bool,"\mathtt{odd}",-30);
drawEdgeAngle(int,bool,"\mathtt{even}",30);
drawEdge(intlist,intlist,"\mathtt{tail}");
drawEdge(intlist,int,"\mathtt{head}");
pair decal;
pair fint,fbool,ffunc,fintlist,flist;
decal := (1.7gu,0);
fint=int shifted decal;
fintlist=intlist shifted decal;
ffunc= func shifted decal;
fbool= bool shifted decal;
flist= list shifted decal;
drawState(fint,"\mathtt{F\ Int}");
drawState(fbool,"\mathtt{F\ Bool}");
drawState(ffunc,"\mathtt{F\ a\rightarrow b}");
drawState(fintlist,"\mathtt{F\ [Int]}");
drawState(flist,"\mathtt{F\ [a]}");
drawLoopPoint(fint,fint shifted (0,1.6u),"\mathtt{sqrt}");
drawEdge(fint,fint,"\mathtt{id}");
drawEdgeAngle(fint,fbool,"\mathtt{odd}",-30);
drawEdgeAngle(fint,fbool,"\mathtt{even}",30);
drawEdge(fintlist,fintlist,"\mathtt{tail}");
drawEdge(intlist,int,"\mathtt{head}");
drawblock(fint,fbool,"\mathtt{F}");
pair ff;
ff = .5[fint,fintlist] shifted (0,u);
path b;
b := block(origin,origin);
draw b scaled .5 shifted ff;
label.top(btex $\mathtt{F\ F}$ etex, blockLabelPosition(b)) scaled .5 shifted ff;
draw b scaled .25 shifted ff;
label.top(btex $\mathtt{F\ F\ F}$ etex, blockLabelPosition(b)) scaled .25 shifted ff;
drawoptions(withcolor yellow withpen pencircle scaled 1 dashed evenly);
drawarrow edgeAngle(int,fint,45);
drawoptions(withcolor green withpen pencircle scaled 1 dashed evenly);
drawarrow edgeAngle(intlist,fintlist,-20);
drawoptions(withcolor blue withpen pencircle scaled 1 dashed evenly);
drawarrow edgeAngle(func,ffunc,-25);
drawoptions(withcolor red withpen pencircle scaled 1 dashed evenly);
drawarrow edgeAngle(list,flist,25);
drawoptions(withcolor orange withpen pencircle scaled 1 dashed evenly);
drawarrow edgeAngle(bool,fbool,-25);

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

22
categories/img/mp/hask.mp Normal file
View file

@ -0,0 +1,22 @@
pair int,bool,func,intlist,list;
resize(.8cm);
int=origin;
% drawoptions (withcolor baseOne withpen pencircle scaled 1.2);
intlist=int shifted (gu,0);
func=int shifted (0,-.6gu);
bool=func shifted (gu,0);
list=func shifted (2u,0);
drawState(int,"\mathtt{Int}");
drawState(bool,"\mathtt{Bool}");
drawState(func,"\mathtt{a\rightarrow b}");
drawState(intlist,"\mathtt{[Int]}");
drawState(list,"\mathtt{[a]}");
drawLoopPoint(int,int shifted (0,1.6u),"\mathtt{sqrt}");
drawEdge(int,int,"\mathtt{id}");
drawEdgeAngle(int,bool,"\mathtt{odd}",-30);
drawEdgeAngle(int,bool,"\mathtt{even}",30);
drawEdge(intlist,intlist,"\mathtt{tail}");
drawEdge(intlist,int,"\mathtt{head}");

BIN
categories/img/mp/hask.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB