<script>
var xorg,yorg;
var xo,yo;
var bili=50;//方法比例
var blue="blue";
var red="red";
with(document)
{
//设置左边原点的位置
setOrg(150,150);
//绘制左边轴
drawOrg();
//绘制所选图形
showDraw(parseInt(dialogArguments));
}
//根据用户指定坐标画点
function drawPoint(x,y,color,width)
{
var xp=xToSystem(x);
var yp=yToSystem(y);
var str="<table border='0' cellspacing=0 cellpadding=0><tr><td style='position:absolute;width:"+width+" px; height:"+width+" px; ";
str+="left:"+xp+"px;top:"+yp+"px; background:"+color+"'></td></tr></table>";
document.write(str);
}
// 根据指定起始位置和终止位置画线
function drawLine(x1,y1,x2,y2,color,width)
{
if(x1!=x2)
{
for(var i=x1;i<=x2;i++)
{
var a=(y2-y1)*(i-x1)/(x2-x1);
var j=y1+a;
drawPoint(i,j,color,width);
}
}
else
{
for(var i=y1;i<=y2;i++)
{
drawPoint(x1,i,color,width);
}
}
}
//根据指定的参数设置坐标原点的位置
function setOrg(x,y)
{
xorg=x;
yorg=y;
}
//将自定义横坐标值转化为系统的横坐标值
function xToSystem(x)
{
return xorg+x;
}
//将自定义纵坐标值转化为系统的纵坐标值
function yToSystem(y)
{
return yorg-y;
}
//绘制x y坐标
function drawOrg()
{
drawLine(-1*xorg,0,xorg,0,blue,1);
drawLine(0,-1*yorg,0,yorg,blue,1);
}
/*
绘制正弦函数曲线
区间-pi到pi
*/
function drawSin()
{
xo=-1*Math.PI;
yo=Math.sin(xo);
for(var x=-1*Math.PI+0.1;x<=Math.PI;x+=0.1)
{
var y=Math.sin(x);
drawLine(xo*bili,yo*bili,x*bili,y*bili,red,2);
xo=x;
yo=y;
}
document.write("y=sin(x)");
}
/*
绘制余弦函数曲线
区间-pi到pi
*/
function drawCos()
{
xo=-1*Math.PI;
yo=Math.cos(xo);
for(var x=-1*Math.PI+0.1;x<=Math.PI;x+=0.1)
{
var y=Math.cos(x);
drawLine(xo*bili,yo*bili,x*bili,y*bili,red,2);
xo=x;
yo=y;
}
document.write("y=cos(x)");
}
/*
绘制自然对数函数曲线
区间0.02到3.5
*/
function drawLog()
{
xo=0.01;
yo=Math.log(xo);
for(var x=0.02;x<=3.5;x+=0.01)
{
var y=Math.log(x);
drawLine(xo*bili,yo*bili,x*bili,y*bili,red,2);
xo=x;
yo=y;
}
document.write("y=Log"+"e".sub()+"(x)");
}
/*
绘制指数函数曲线
区间-2.9到1.5
*/
function drawExp()
{
xo=-3;
yo=Math.exp(xo);
for(var x=-2.9;x<=1.5;x+=0.1)
{
var y=Math.exp(x);
drawLine(xo*bili,yo*bili,x*bili,y*bili,red,2);
xo=x;
yo=y;
}
document.write("y=e"+"x".sup());
}
//根据选择绘制函数曲线
function showDraw(num)
{
switch(num)
{
case 1:
drawSin();
break;
case 2:
drawCos();
break;
case 3:
drawLog();
break;
case 4:
drawExp();
break
}
}
</script>
</body>
没有合适的资源?快使用搜索试试~ 我知道了~
javascript学习
共282个文件
html:272个
mdb:2个
js:2个
需积分: 10 34 下载量 180 浏览量
2008-07-15
14:29:24
上传
评论
收藏 149KB RAR 举报
温馨提示
javascript学习
资源推荐
资源详情
资源评论
收起资源包目录
javascript学习 (282个子文件)
11.1.2 LN2属性 157B
16.2.8 returnValue属性 400B
9.1.14 setMonth方法.htm 572B
drawWindow.html 3KB
14.3.5 列表框.html 3KB
13.4.1 二维数组的实现.html 3KB
11.3.1 掷骰子游戏.html 2KB
Filter属性.html 2KB
19.4.3 分页显示.html 2KB
19.2.1 RollBackTrans方法.html 2KB
19.4.4 Delete方法.html 2KB
13.2.2 eval方法.html 2KB
19.4.3 Sort 属性.html 2KB
9.1.5 getDay方法.html 1KB
19.3.3 带参数查询.html 1KB
19.4.4 Move方法.html 1KB
14.1.1 引用表单控件.html 1KB
19.4.4 AddNew方法.html 1KB
11.2.11 max方法.html 1KB
19.4.4 MoveNext方法.html 1KB
19.4.3 BOF、EOF属性.html 1KB
19.4.3 AbsolutePosition属性.html 1KB
13.4 错误处理与Error对象2.html 1KB
9.1.16 setHours方法.html 1KB
16.3.2 location对象_hash.html 1KB
14.2.2 elements属性.html 1012B
19.4.4 Resync 方法.html 1010B
9.3 使用Date对象1.html 1004B
14.2.3 all属性.html 977B
16.16 resizeTo方法.html 969B
10.2.11 indexOf方法.html 961B
13.2.2 prototype属性.html 959B
16.13 open方法.html 959B
13.4 错误处理与Error对象3.html 949B
10.2.5 charCodeAt方法.html 937B
14.2.1 action属性.html 925B
16.3.2 location对象_pathname属性.html 875B
13.3.8 sort方法.html 861B
16.2.11 status属性.html 846B
10.3.2 prototype属性.html 838B
19.4.4 Clone方法.html 832B
14.3.2 文本框.html 831B
9.2.1 prototype属性.html 817B
19.2.1 State属性.html 782B
16.2.9 screenTop、screenLeft属性.html 775B
6.3.1 数组排序2.html 758B
6.1.2 Switch条件语句.html 758B
10.2.4 charAt方法.html 748B
6.3.1 数组排序.html 734B
9.2.3 Connection对象的Errors集合.html 710B
14.2.4 disabled属性.html 702B
5.6.html 692B
10.2.1 anchor方法.html 690B
16.5 setInterval方法.html 674B
3.5.html 672B
19.4.4 seek方法.html 664B
13.4 错误处理与Error对象.html 656B
9.1.20 getTimezoneOffset方法.html 644B
16.20 showModalLessDialog方法.html 644B
10.3.2 prototype属性.html 636B
19.3.1 CommandType 属性.html 629B
12.1.2 创建数组2.html 622B
6.3.2 素数与闰年问题2.html 621B
19.4.3 BookMark属性.html 616B
16.3.2 location对象_reload方法.html 609B
13.3.4 push方法.html 608B
13.4 错误处理与Error对象1.html 599B
draw.html 595B
6.3.html 576B
6.4.html 576B
16.3.1 screen对象_availHeight.html 573B
16.17 scroll方法.html 568B
12.1.2 创建数组.html 560B
16.2.8 returnValue属性.html 554B
19.4.5 Fields集合及Field对象.html 544B
13.3.9 splice方法.html 538B
13.1.5 test方法.html 532B
13.3.1 concat属性.html 521B
13.1.4 $1,S2,…,$9属性2.html 520B
6.0.html 517B
16.2.6 opener属性.html 517B
14.3.6 文本域.html 514B
10.2.22 substring方法.html 512B
11.2.5 atan2方法.html 505B
6.3.2 素数与闰年问题.html 502B
16.12 moveTo方法.html 494B
16.19 showModalDialog方法.html 488B
19.2 Connection对象 OLEDB.html 478B
16.11 moveby方法.html 457B
9.1.12 setFullYear方法.html 455B
11.1.6 PI属性.html 453B
14.3.1 表单按钮.html 447B
10.2.15 localeCompare方法.html 446B
6.10.html 446B
13.3.7 slice方法.html 443B
14.2.7 reset方法.html 440B
13.4.1 二维数组和多位数组的实现.html 437B
16.6 clearInterval方法.html 437B
19.2 Connection对象 ODBC.html 437B
8.4.html 434B
共 282 条
- 1
- 2
- 3
资源评论
lium_c
- 粉丝: 4
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功