amath
A page with dynamic pictures illustrating Pythagoras' Theorem
\begin{graph}
width=480;
height=240;
initPicture(-6,6,-1);
svgpicture.setAttribute("onmousemove","displayCoord(evt);dynamic.update2(evt)");
a = 2;
s = 5;
function rtriangle(x,y,a,b,id) {
path([[x,y],[x,y+b],[x+a,y],[x,y]],id)
};
dynamic.update2 = function(evt) {
switchTo("picture2");
b = s-a;
x = 1;
y = 0;
stroke = "black";
fill = "green";
path([[x+a,y],[x,y+b],[x+b,y+s],[x+s,y+a],[x+a,y]],"csquare");
fill = "yellow";
rtriangle(x,y,a,b,"tcl");
rtriangle(x,y+s,b,-a,"tca");
rtriangle(x+s,y+s,-a,-b,"tcr");
rtriangle(x+s,y,-b,a,"tcb");
x = -1-s;
y = 0;
rtriangle(x,y,a,b,"tl");
rtriangle(x+a,y+s,b,-a,"ta");
rtriangle(x+a,y+b,-a,-b,"tr");
rtriangle(x+s,y+b,-b,a,"tb");
fill = "red";
rect([x,y+b],[x+a,y+s],"asquare");
fill = "blue";
rect([x+a,y],[x+s,y+b],"bsquare");
if (evt!=undefined) a = getX(evt)+s+1;
if (a>4.5) a = 4.5;
if (a<.5) a = .5;
};
dynamic.update2();
\end{graph}