VML实例-铅笔画

VML铅笔画

<HTML xmlns:v>
<HEAD>
<META http-equiv='Content-Type' content='text/html;charset=gb2312'>
<Meta name='Gemeratpr' content='网络程序员伴侣(Lshdic)2005'>
<TITLE>VML最简实现铅笔绘图功能</TITLE>
<STYLE>
v\:*{behavior:url(#default#VML);}   /*声明V为VML变量*/
</STYLE>
</HEAD>
<body bgcolor=black>
<div id=div1 style="background-color:white;width:400;height:400"></div><br><input type=button value="清空" onclick="div1.innerHTML=''">
<script>  //
var xx=0,yy=0,oldvalue="",poly1,zz=1
function div1.onmousedown(){   //鼠标按下
if(event.button==1){
div1.setCapture()       //画笔绘画开始,锁定鼠标
color1="red"  //定义画笔基本颜色
size1=1  //定义画笔基本粗度
xx=event.x;yy=event.y;zz+=1  //定义基本起始坐标,zz是第三维,默认递增
poly1=div1.appendChild(document.createElement("<v:shape filled=false path='m0,0 l0,0' style='position:absolute;z-index:"+zz+";left:"+xx+";top:"+yy+";width:100;height:100' strokecolor='"+color1+"' strokeweight='"+size1+"' coordsize='100,100'/>"))
oldvalue=poly1.path.value.replace("e","")
}}
function div1.onmousemove(){  //鼠标移动
if(event.button==1){
if(event.srcElement.tagName=="BODY"){div1.releaseCapture();return false}
oldvalue+=","+(event.x-xx)+","+(event.y-yy);poly1.path.value=oldvalue
poly1.path.value=poly1.path.value.replace(",0,",",").replace(",0 e","e")
}}
function div1.onmouseup(){  //鼠标弹起
div1.releaseCapture();
}
</script>
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值