6 Using MapleNet's Image Generation
In this Chapter
6.1 Description of Image Generation
Users can take advantage of MapleNet's image generation capabilities to embed math or plot images in any web page. These images are created dynamically using simple URLs directed to the MapleNet server and returned in either GIF or JPEG format.
The image generation feature of MapleNet has the following capabilities:
6.2 URL Specification
The general form of the URL to generate an image is
http://yourserver:port/maplenet/imaging/image?maple=M&type=T&format=FM&width=W&height=H&fontname=FN&fontsize=FS&fontcolor=FC
where
Hex value |
Color |
Hex value |
Color |
||
---|---|---|---|---|---|
#000000 |
black |
#C0C0C0 |
silver |
||
#808080 |
gray |
#FFFFFF |
white |
||
#800000 |
maroon |
#FF0000 |
red |
||
#800080 |
purple |
#FF00FF |
magenta |
||
#008000 |
green |
#00FF00 |
lime |
||
#808000 |
olive |
#FFFF00 |
yellow |
||
#000080 |
navy |
#0000FF |
blue |
||
#008080 |
teal |
#00FFFF |
cyan |
URL Line Length Limits
The maximum length of the URL is both browser dependent and server dependent.
URL Encoding
URLs by definition have special meaning for certain characters. This is defined in Internet standards. URL encoding replaces certain ASCII characters with "%" followed by two hexadecimal digits. Hex values correspond to values in the ISO-8859-1 characters. If these characters are required in the Maple Expression, they usually should be included in an encoded format. For example,
a+b
should be written as
a%2Bb
The following list shows the special characters and their encoded form:
Name Char. Encoding Notes (if character is not encoded) Space %20 Pound sign # %23 will be used as anchor reference Percent sign % %25 percent is encoding character Ampersand & %26 is delimiter for parameters Plus + %2B will be converted to space Less than < %3C Equal sign = %3D may be confusing in parameter=value sequence Greater than > %3E Question mark ? %3F is delimiter for start of parameters So, a math expression of the form
/maplenet/imaging/image?maple=int(sin(x)+cos(x),x=a..b)&font=Courier
becomes
/maplenet/imaging/image?maple=int(sin(x)%2Bcos(x),x%3Da..b)&font=Courier
6.3 Usage
To include a generated image in a web page, use an image generation URL in the 'href' parameter of any <img> tag.
Note: Images are generated dynamically at the time the href URL is sent back to the server. The image is not stored on the server.
6.4 Examples
Copy and paste the following examples into your browser. Be sure to replace localhost:8080 with the specifications for your server.
Math Examples
Show the equation: x-sin(x)
http://localhost:8080/maplenet/imaging/image?maple=x-sin(x)&fontname=Courier&fontsize=18&fontcolor=8D38C9
Show the equation: distance = (1/2)*a(t)*t^2 + v(t)*t + d0
http://localhost:8080/maplenet/imaging/image?maple=distance%3DInt((1/2)*a(t)*t^2%2Bv(t)*t%2Bd0,t%3D0..tMax)&fontname=Courier&fontsize=18&fontcolor=8D38C9
Plot Examples
Show plot of sin(x) from 0 to 2*Pi
http://localhost:8080/maplenet/imaging/image?maple=plot(sin(x),x=0..2*Pi)&width=400&height=200
Show a 3-D plot of x^2 + y^2
http://localhost:8080/maplenet/imaging/image?maple=plot3d(x^2%2By^2,x=-1..1,y=-1..1)&width=400&height=400