<!--#include file="diagram.asp"-->
<%
'function.asp
Dim PI
PI=3.14159265
xmin=CDbl(Request.QueryString("xmin"))
xmax=CDbl(Request.QueryString("xmax"))
ymin=CDbl(Request.QueryString("ymin"))
ymax=CDbl(Request.QueryString("ymax"))
fx=Request.QueryString("fx")
if xmin<>"" and xmax<>"" and ymin<>"" and ymax<>"" and fx<>"" then
Set D=New Diagram
Set D.Img=CreateObject("gdImage.Images.1")
D.Img.ImageCreate 720, 400
D.Img.ImageColorAllocate 0,255,255,255 'Background Color
D.SetFrame 60, 40, 700, 340
D.SetBorder xmin, xmax, ymin, ymax
D.SetText "", "", "f(x)=" & fx
D.SetGridColor "#FFFFFF", "#EEEEEE"
D.Draw "#DDDDDD", "#000000", false, "", ""
y=0
for i=60 to 700
x = D.RealX(i)
y=eval(fx)
if ymin<=y And y<=ymax then D.Pixel i, D.ScreenY(y), "#0000FF"
next
if isObject(Server) then
Set objFS=Server.CreateObject("Scripting.FileSystemObject")
FN = objFS.GetTempName()
FN=Server.mappath(FN)
D.Img.ImagePng 0, FN
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Charset = "x-ansi"
objStream.Type = 2
objStream.Open
objStream.LoadFromFile FN
Response.ContentType = "image/png"
Response.AddHeader "Content-Disposition","filename=image.png"
objStream.Position = 0
objStream.Type = 1
Response.BinaryWrite objStream.Read()
objStream.Close
Set objStream = Nothing
objFS.DeleteFile FN, false
Set objFS=Nothing
end if
D.Img.ImageDestroy 0
Set D.Img=Nothing
end if
%> |