80
NDSolveToSVG[ eqn_, init_, lims_List]:=
Module[ {sol, dep, t, int, t0, t1},
{o,dep,t} = EquationToVariables[ eqn] ;
{t0, t1} = lims ;
sol=NDSolve[Append[init,eqn],dep,{t,t0,t1}];
{int0, int1} = Part[dep /. First[ sol],1,1];
If[ t0 < int0, t0 = int0];
If[ t1 > int1, t1 = int1];
p=ParametricPlot[ {dep[t],dep [t]} /. sol,{t,t0,t1},
ImageSize > 400];
xml = XML SVG GraphicsToSymbolicSVG[p];
pts="M"<>
First[Cases[ xml,
XMLElement["polyline",{"fill" >
_,"points" > x_},_] >x, Infinity]];
newElem=XMLElement["circle",
{"cx" >"0","cy" >"0","r" >".1","fill" >"red",
"stroke" >"blue",
"stroke width" >"0.01"},
{XMLElement[
"animateMotion",{"dur" >"6s","repeatCount"
>"indefinite",
"rotate" >"auto", "path" > pts},{}]}];
newXML=xml/.x:XMLElement["polyline",___] >
Sequence[x,newElem] ;
ExportString[newXML,"XML"]
]
There are a number of other ways of obtaining interactive results with SVG. For example, JavaScript can interact
with and manipulate the SVG tree thereby supporting interactive features such as pop ups when the mouse is moved
over a graphic.
5.4 HTML Formatting
One of the advantages of the HTML templating technique that webMathematica provides is that there is often little
need to try and generate HTML formats with Mathematica programs. In fact many of the HTML formatting issues
can be left to web designers who can use their standard tools. However, sometimes it is useful to apply some HTML
formatting functions to Mathematica expressions. This is particularly the case for HTML tables. In order to allow
this, an HTML utility package is provided with webMathematica that supports Table formatting functions. This
section will explore the use of this HTML formatting. A more general discussion of output is available in the section
on
Evaluation Formatting
.
Remember that if you want to return HTML that is not generated by the
HTML Package
, you should construct
your own string of HTML and return this as shown in the example below.
StringJoin[ "", ToString[ x], ""]
.
<
New Page 1
Comcast Web Hosting