sjnam / mpresty

An openresty web application for metapost and tex graphics

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mpresty

An openresty web application for metapost and tex graphics

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

Author

Soojin Nam, jsunam at gmail.com

About

An openresty web application for metapost and tex graphics


Languages

Language:HTML 65.5%Language:Lua 23.2%Language:TeX 10.2%Language:Dockerfile 1.1%