生活随笔
收集整理的這篇文章主要介紹了
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);}
</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
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>
總結
以上是生活随笔為你收集整理的VML实例-铅笔画的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。