Skip to content
This repository was archived by the owner on Aug 21, 2026. It is now read-only.

Latest commit

 

History

523 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mpresty

An openresty web application for metapost and tex graphics

See also go-mpresty, a port of this application to Go. It draws metapost and graphviz from a single binary, with no OpenResty or Lua involved.

Getting started

You can write the metapost or tikz or graphviz script of the image you want to draw in the html file, and the mpresty converts the script into the image.

The graphics scripts are inserted into the html in codes or they are stored in a file and inserted into uri format of img'src attribute.

<html>
<body>
<H1>Metapost</H1>
<metapost width="200">
beginfig(1)
  u:=1.3cm; transform T; z1=(0,2u); n:=5;
  for i=1 upto n-1: z[i+1]=z1 rotated (360*i/n);
  endfor;
  z1 transformed T=0.1[z1,z2];
  z2 transformed T=0.1[z2,z3];
  z3 transformed T=0.1[z3,z4];
  path p;
  p = for i=1 upto n: z[i]--endfor cycle;
  for i=0 upto 100:
    fill p withcolor 0.2*white; p:=p transformed T;
    fill p withcolor white;     p:=p transformed T;
  endfor;
endfig;
</metapost>
<img src="tree.mp" width="200">
<img src="/source/riemann.mp" width="200">
<img src="http://ktug.org/~sjnam/source/rgb.mp" width="200">
</body>
</html>

Run

% git clone https://github.com/sjnam/mpresty.git
% cd mpresty
% docker-compose up -d

Try to visit the following pages

Create a fun.html file with the above Getting started and put it in the $(pwd)/html directory and visit http://localhost:8080/fun.html

Advanced Usage

update-node customization

See exemples.lua

See upnode.lua

About

An openresty web application for metapost and tex graphics

Topics

Resources

Stars

8 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages