用js绘图 程序员文章站 2023-12-17 16:01:28 <object id=directdraw classid="clsid:369303c2-d7ac-11d0-89d5-00a0c90833e6" style="positiion:absolute;top:0;left:0;width:320;height:200" > <param name="line0001" value="绘图指令1"> <param name="line0002" value="绘图指令2"> ... </object> 绘图指令分类: (一)常见形状 1.矩形类 //rotation是以度为单位的旋转角度 rect(x ,y, width, height, rotation) //矩形 oval(x ,y, width, height, rotation) //椭圆 roundrect(x ,y, width, height, arcwidth, archeight, rotation) 2.弧形类 arc(x ,y, width, height, startangle, arcangle, rotation) //弧形 pie(x ,y, width, height, startangle, arcangle, rotation) //饼图 3.多边形类 polygon(npoints, x1, y1, x2, y2, [x3, y3, ....], rotation) //闭合 polyline(npoints, x1, y1, x2, y2, [xn, yn, ....], rotation) //不闭合 (二)效果函数 1.线条效果 setlinecolor(r, g, b) //设置画线颜色 setlinestyle(style) //style=(1:实线;2:虚线;0:隐藏) 2.填充效果 setfillcolor(r, g, b, backr, backg, backb) setfillstyle(style) //style=(1:实心;2:透明;3:-;4:|;5:\;6:/;7:+;8:x) (三)文字输出函数 setfont('字体',width,height,r,g,b) //设置字体 text('要输出的文字内容', x,y,z) //输出文字 控制函数 //定义<object>后在<script></script>里使用。 引用格式:directdraw.functionname() rotate(x-rotation, y-rotation, z-rotation) //旋转 scale(x-scale,y-scale,z-scale) //缩放 translate(x-coordinate,y-coordinate,z-coordinate) //平移 setidentity() //复原 clear() //清除,清除后无法恢复! 上一篇: 下一篇: 推荐阅读 在ASP.NET 2.0中操作数据之四十七:用SqlDataSource控件插入、更新、删除数据 利用thrift实现js与C#通讯的实例代码 MySQL 可以用localhost 连接,但不能用IP连接的问题解决方法 使用ANT与YUI压缩js的实现方法 深入分析:用1K内存实现高效I/O的RandomAccessFile类的详解 深入多线程之:用Wait与Pulse模拟一些同步构造的应用详解 Android用文件存储数据的方法 js尾调用优化的实现 js console.log打印对象时属性缺失的解决方法 JS定义函数的几种常用方法小结