diff options
Diffstat (limited to 'test/examples')
| -rw-r--r-- | test/examples/ps/hilbert.lua | 42 | ||||
| -rw-r--r-- | test/examples/ps/ps.lua | 181 | ||||
| -rw-r--r-- | test/examples/www/README | 10 | ||||
| -rw-r--r-- | test/examples/www/db.lua | 46 | ||||
| -rw-r--r-- | test/examples/www/staff.lua | 33 | ||||
| -rw-r--r-- | test/examples/www/template.html | 29 |
6 files changed, 0 insertions, 341 deletions
diff --git a/test/examples/ps/hilbert.lua b/test/examples/ps/hilbert.lua deleted file mode 100644 index dbcec963..00000000 --- a/test/examples/ps/hilbert.lua +++ /dev/null @@ -1,42 +0,0 @@ --- hilbert.c --- Hilbert curve --- Luiz Henrique de Figueiredo (lhf@csg.uwaterloo.ca) --- 10 Nov 95 - -dofile("ps.lua") - -function p() - PS.lineto(x,y) -end - -function a(n) - if (n==0) then return else n=n-1 end - d(n); y=y+h; p(); a(n); x=x+h; p(); a(n); y=y-h; p(); b(n); -end - -function b(n) - if (n==0) then return else n=n-1 end - c(n); x=x-h; p(); b(n); y=y-h; p(); b(n); x=x+h; p(); a(n); -end - -function c(n) - if (n==0) then return else n=n-1 end - b(n); y=y-h; p(); c(n); x=x-h; p(); c(n); y=y+h; p(); d(n); -end - -function d(n) - if (n==0) then return else n=n-1 end - a(n); x=x+h; p(); d(n); y=y+h; p(); d(n); x=x-h; p(); c(n); -end - -function hilbert(n) - PS.open("hilbert curve") - h=2^(9-n) - x=0 - y=0 - PS.moveto(x,y) - a(n) - PS.close() -end - -hilbert(5) diff --git a/test/examples/ps/ps.lua b/test/examples/ps/ps.lua deleted file mode 100644 index 0d749194..00000000 --- a/test/examples/ps/ps.lua +++ /dev/null @@ -1,181 +0,0 @@ --- ps.lua --- lua interface to postscript --- Luiz Henrique de Figueiredo (lhf@csg.uwaterloo.ca) --- 14 May 96 - -PS={} - -function P(x) - write(x.."\n") -end - --------------------------------------------------------------------- control -- - -function PS.open(title) - if title==nil then title="(no title)" end - P("%!PS-Adobe-2.0 EPSF-1.2") - P("%%Title: "..title) - P("%%Creator: ps.lua from Lua 2.4") - P("%%CreationDate: "..date()) - P("%%Pages: (atend)") - P("%%BoundingBox: (atend)") - P("%%EndComments") - P("%%BeginProcSet: ps.lua") - P("/s { stroke } bind def") - P("/f { fill } bind def") - P("/m { moveto } bind def") - P("/l { lineto } bind def") - P("/L { moveto lineto stroke } bind def") - P("/t { show } bind def") - P("/o { 0 360 arc stroke } bind def") - P("/O { 0 360 arc fill } bind def") - P("/p { 3 0 360 arc fil } bind def") - P("/F { findfont exch scalefont setfont } bind def") - P("/LS { 0 setdash } bind def") - P("/LW { setlinewidth } bind def") - P("%%EndProcSet: ps.lua") - P("%%EndProlog") - P("%%BeginSetup") - P("0 setlinewidth") - P("1 setlinejoin") - P("1 setlinecap") - P("10 /Times-Roman F") - P("%%EndSetup\n") - P("%%Page: 1 1") --- cxmin=dv.xmin; cxmax=dv.xmax; cymin=dv.ymin; cymax=dv.ymax - xmin=1000; xmax=-1000; ymin=1000; ymax=-1000 - page=1 -end - -function PS.close() - P("stroke") - P("showpage") - P("%%Trailer") - P("%%Pages: "..page) - P("%%BoundingBox: "..xmin.." "..ymin.." "..xmax.." "..ymax) - P("%%EOF") -end - -function PS.clear() - if (empty) then return end - page=page+1 - P("showpage") - P("%%Page: "..page.." "..page) - empty=1 -end - -function PS.comment(s) - P("% "..s) -end - ---------------------------------------------------------------- direct color -- - -function PS.rgbcolor(r,g,b) - P(r.." "..g.." "..b.." setrgbcolor") -end - -function PS.gray(g) - P(g.." setgray") -end - ----------------------------------------------------------------- named color -- - -function PS.color(c) - P("C"..c) -end - -function PS.defrgbcolor(c,r,g,b) - P("/C"..c.." { "..r.." "..g.." "..b.." setrgbcolor } def") -end - -function PS.defgraycolor(c,g) - P("/C"..c.." { "..g.." setgray } def") -end - ------------------------------------------------------------------------ line -- - -function PS.line(x1,y1,x2,y2) - P(x2.." "..y2.." "..x1.." "..y1.." L") - PS.update(x1,y1) - PS.update(x2,y2) -end - -function PS.moveto(x,y) - P(x.." "..y.." m") - PS.update(x,y) -end - -function PS.lineto(x,y) - P(x.." "..y.." l") - PS.update(x,y) -end - -function PS.linewidth(w) - P(w.." LW") -end - -function PS.linestyle(s) - P("["..s.."] LS") -end - ------------------------------------------------------------------------ text -- - -function PS.font(name,size) - if (size==nil) then size=10 end - P(size.." /"..name.." F") -end - -function PS.text(x,y,s) - P(x.." "..y.."m ("..s..") t") - PS.update(x,y) -end - ---------------------------------------------------------------------- circle -- - -function PS.circle(x,y,r) - P(x.." "..y.." "..r.." o") - PS.update(x-r,y-r) - PS.update(x+r,y+r) -end - -function PS.disk(x,y,r) - P(x.." "..y.." "..r.." O") - PS.update(x-r,y-r) - PS.update(x+r,y+r) -end - -function PS.dot(x,y) - P(x.." "..y.." p") - PS.update(x-r,y-r) - PS.update(x+r,y+r) -end - ------------------------------------------------------------------------- box -- - -function PS.rectangle(xmin,xmax,ymin,ymax) - P(xmin.." "..ymin.." m ".. - xmax.." "..ymin.." l ".. - xmax.." "..ymax.." l ".. - xmin.." "..ymax.." l s") - PS.update(xmin,ymin) - PS.update(xmax,ymax) -end - -function PS.box(xmin,xmax,ymin,ymax) - P(xmin.." "..ymin.." m ".. - xmax.." "..ymin.." l ".. - xmax.." "..ymax.." l ".. - xmin.." "..ymax.." l f") - PS.update(xmin,ymin) - PS.update(xmax,ymax) -end - --------------------------------------------------------- update bounding box -- - -function PS.update(x,y) --- if (x>=cxmin and x<=cxmax and y>=cxmin and y<=cxmax) then - if (x<xmin) then xmin=x elseif (x>xmax) then xmax=x end - if (y<ymin) then ymin=y elseif (y>ymax) then ymax=y end - empty=0 --- end -end diff --git a/test/examples/www/README b/test/examples/www/README deleted file mode 100644 index b0e1e8bd..00000000 --- a/test/examples/www/README +++ /dev/null @@ -1,10 +0,0 @@ -This directory contains a database for a fake web site. -Standard web page for the persons listed in db.lua are created -automatically from template.html with staff.lua. -(See http://www.cos.ufrj.br for a real web site created in this way.) - -To run, type lua db.lua. - -This example is meant to show the power of gsub and Lua declarative constructs, -which have been combined here into a "mail-merge" application. - diff --git a/test/examples/www/db.lua b/test/examples/www/db.lua deleted file mode 100644 index 53d78024..00000000 --- a/test/examples/www/db.lua +++ /dev/null @@ -1,46 +0,0 @@ -dofile("staff.lua") - -global{ - ROOT='http://www.tecgraf.puc-rio.br', - EMAIL="|LOGIN|@tecgraf.puc-rio.br", - WWW="|ROOT|/~|LOGIN|", - webmast='|ROOT|/webmaster.html', - TECGRAF='<A HREF="http://www.tecgraf.puc-rio.br">TeCGraf</A>', - CS='<A HREF="http://www.inf.puc-rio.br">Computer Science Department</A>', - PUCRIO='<A HREF="http://www.puc-rio.br">PUC-Rio</A>', -} - -staff{ -DI="inf.puc-rio.br", - LOGIN="roberto", - NAME="Roberto Ierusalimschy", - TITLE="D.Sc., |PUCRIO|, 1990", - POSITION="Associate Professor, |CS|, |PUCRIO|", - AREAS="Programming Languages, Object Oriented Programming", - EMAIL="|LOGIN|@|DI|", - WWW="http://www.|DI|/~|LOGIN|", -} - -staff{ -PCG="http://www.graphics.cornell.edu", - LOGIN="celes", - NAME="Waldemar Celes", - TITLE="D.Sc., |PUCRIO|, 1995", - POSITION="Postdoctoral Associate at ".. -'<A HREF="|PCG|">Program of Computer Graphics</A>, '.. -'<A HREF="http://www.cornell.edu">Cornell University</A>', - WWW="|PCG|/~celes/", - AREAS="Image segmentation and 3D reconstruction; " -.."Physical simulation and educational software;" -.."Geometric modeling and topological data structures;" -.."Extension languages and customizable applications" -} - -staff{ - LOGIN="lhf", - NAME="Luiz Henrique de Figueiredo", - TITLE='D.Sc., <A HREF="http://www.impa.br">IMPA</A>, 1992', - POSITION='Associate Researcher at <A HREF="http://www.lncc.br">LNCC</A>; Consultant at |TECGRAF|', - AREAS="Geometric modeling; Software tools", - WWW="http://www2.lncc.br/~lhf/", -} diff --git a/test/examples/www/staff.lua b/test/examples/www/staff.lua deleted file mode 100644 index f36df4ad..00000000 --- a/test/examples/www/staff.lua +++ /dev/null @@ -1,33 +0,0 @@ -readfrom("template.html") -TEMPLATE=read("*a") -readfrom() - -PAT="|(%a%a*)|" - -GLOBAL={ - DATE=date("%d/%m/%Y %T"), -} - -function get(i) - if LOCAL[i] then return LOCAL[i] - elseif GLOBAL[i] then return GLOBAL[i] - else return "<BLINK>?"..i.."?</BLINK>" end -end - -function global(t) - for i,v in t do - GLOBAL[i]=v - end -end - -function staff(t) - LOCAL=t - if t.AREAS then t.AREAS=gsub(t.AREAS,"[;,] *","\n<LI>") end - local p,n=TEMPLATE - if t.WWW=="" then p=gsub(p,'<A HREF="|WWW|">|NAME|</A>',"|NAME|") end - repeat p,n=gsub(p,PAT,get) until n==0 - write(t.LOGIN,"\n") - writeto(t.LOGIN..".html") - write(p) - writeto() -end diff --git a/test/examples/www/template.html b/test/examples/www/template.html deleted file mode 100644 index c8494b76..00000000 --- a/test/examples/www/template.html +++ /dev/null @@ -1,29 +0,0 @@ -<HTML> -<HEAD> -<TITLE> -Imaginary web site:Staff:|LOGIN| -</TITLE> -</HEAD> - -<BODY> -<H1><A HREF="|WWW|">|NAME|</A></H1> -<A HREF="mailto:|EMAIL|">|EMAIL|</A> -<P> - -|POSITION|<BR> -|TITLE|<P> - -<H2>Research areas</H2> -<UL> -<LI>|AREAS| -</UL> -<P> - -<HR> -Last update in |DATE| by -<A HREF="|webmast|">websmaster</A>. -<P> - -</BODY> - -</HTML> |
