somewhere near the beginning.

IllustRender

Filed under: Programming — Alex @ 12:25 am 1/2/2005

IllustRender [25Kb] is a plugin for WordPress, heavily based on LatexRender, which replaces illustration code in your posts with the actual illustration. Currently, it handles metapost code and postscript code. To use it, you need ghostscript and imagemagick (for convert & identify), mpost, and latex. Of course, if you’re not going to use MetaPost, you don’t need mpost or latex. IllustRender comes bundled with PSMath, a very nice library for making mathematical illustrations in PostScript.

IllustRender is provided without any guarantees. There might still be some bugs; if you see any, let me know.

Here are some examples:


pickup pencircle scaled 4pt yscaled .2pt rotated 60;
n := 5;
for i:= (n*20) step -(n) until (n):
 draw (i,0)..(0,i)..(-i,0)..(0,-(i-n))..(i-n,0);
endfor

pickup pencircle scaled 4pt yscaled .2pt rotated 60;
n := 5;
for i:= (n*20) step -(n) until (n):
 draw (i,0)..(0,i)..(-i,0)..(0,-(i-n))..(i-n,0);
endfor

picture p; path q;
p := thelabel(btex \Large
\begin{minipage}{4in}
\begin{gather}
\iint\limits_A f(x,y)\,dx\,dy\qquad
\iiint\limits_A f(x,y,z)\,dx\,dy\,dz\
\iiiint\limits_A f(w,x,y,z)\,dw\,dx\,dy\,dz
\qquad\idotsint\limits_A f(x_1,\dots,x_k)
\end{gather}
\end{minipage}
etex,(0,0));
q := fullcircle scaled 2.5in;
fill q withcolor black;
clip p to q;
draw p rotated (90) withcolor white;
  

picture p; path q;
p := thelabel(btex \Large
\begin{minipage}{4in}
\begin{gather}
\iint\limits_A f(x,y)\,dx\,dy\qquad
\iiint\limits_A f(x,y,z)\,dx\,dy\,dz\
\iiiint\limits_A f(w,x,y,z)\,dw\,dx\,dy\,dz
\qquad\idotsint\limits_A f(x_1,\dots,x_k)
\end{gather}
\end{minipage}
etex,(0,0));
q := fullcircle scaled 2.5in;
fill q withcolor black;
clip p to q;
draw p rotated (90) withcolor white;

%PS
% Set 3D perspective
100 0 translate
[0 0 0] [[20 -5] p2r aload pop 5] 600 3Dinit

% Define 3D points, circles, and planes
/circ* {/p xdef /s xdef s cos s sin 1 p astore} 2 ldef
/circ {3 array circ*} def
/P [0 0 0] def /R 1.75 def /r -0.5 def

% Find the tangent angles of the cone seen from the observer
/X 3 array def /X' 2 array def /P' P 3D def
0 360 {X circ* X' 3D* P' vsub r2p 1 get} extrema
/u2 xdef /u1 xdef

% Draw section plane
[R 0 R] [R neg 0 R] line
[0 R R] [0 R neg R] line
[r 0 r] [r neg 0 r] line
[0 r r] [0 r neg r] line
[1 0 1] [-1 0 1] line
[0 1 1] [0 -1 1] line
[0 0 r] [0 0 R] line dash stroke nodash

/p 3 array def /p' 2 array def
0 360 {p circ* R p smul*} plot closepath stroke
u1 u2 {p circ* r p smul*} plot stroke
u2 u1 360 add {p circ* r p smul*} plot dash stroke nodash
u1 circ r smul 3D u1 circ R smul line stroke
u2 circ r smul 3D u2 circ R smul line stroke

% Draw conic section
u1 u2 {p circ*} plot dash stroke nodash
u2 u1 360 add {p circ*} plot stroke

/d 1.5 def /-d d neg def
[[d d 1] [d -d 1] [-d -d 1] [-d d 1]] lines closepath stroke

% Label points
($z=1$) [1.5 1.5 1] 3D 1 1 label

 

%PS
% Set 3D perspective
100 0 translate
[0 0 0] [[20 -5] p2r aload pop 5] 600 3Dinit
% Define 3D points, circles, and planes
/circ* {/p xdef /s xdef s cos s sin 1 p astore} 2 ldef
/circ {3 array circ*} def
/P [0 0 0] def /R 1.75 def /r -0.5 def
% Find the tangent angles of the cone seen from the observer
/X 3 array def /X' 2 array def /P' P 3D def
0 360 {X circ* X' 3D* P' vsub r2p 1 get} extrema
/u2 xdef /u1 xdef
% Draw section plane
[R 0 R] [R neg 0 R] line
[0 R R] [0 R neg R] line
[r 0 r] [r neg 0 r] line
[0 r r] [0 r neg r] line
[1 0 1] [-1 0 1] line
[0 1 1] [0 -1 1] line
[0 0 r] [0 0 R] line dash stroke nodash
/p 3 array def /p' 2 array def
0 360 {p circ* R p smul*} plot closepath stroke
u1 u2 {p circ* r p smul*} plot stroke
u2 u1 360 add {p circ* r p smul*} plot dash stroke nodash
u1 circ r smul 3D u1 circ R smul line stroke
u2 circ r smul 3D u2 circ R smul line stroke
% Draw conic section
u1 u2 {p circ*} plot dash stroke nodash
u2 u1 360 add {p circ*} plot stroke
/d 1.5 def /-d d neg def
[[d d 1] [d -d 1] [-d -d 1] [-d d 1]] lines closepath stroke
% Label points
($z=1$) [1.5 1.5 1] 3D 1 1 label

Possibly relevant posts:

8 Comments »

RSS feed for comments on this post. TrackBack URL

Leave a comment