燕之庐网站建设 - 优质网站设计公司

Posts Tagged ‘vml’

产业新闻

2009/11/10

VML绘图板⑤浏览–view.php

Tags: ,

<html>
<xmlns:v=”urn:schemas-microsoft-com:vml” />
<head>
<meta http-equiv=”Content-type” content=”text/html; charset=gb2312″>
<title>VML绘图板</title>
<style>
v\:* { behavior: url(#default#VML); }
td { font-size:9pt; }
</style>
</head>
<script src=”XMLtool.js”></script>
<script>
// 钩子函数,用于清除代码显示
function hooke() {
code.innerText = “”;
}
// 从服务器获取XML文档。服务器将返回vml文档,可以根据参数v简单的用readfile函数
function loadXML(v)
{
var xmlHTTP = new ActiveXObject(”Microsoft.XMLHTTP”);
xmlHTTP.open(”GET”,”server.php?info=”+v,false);
xmlHTTP.setRequestHeader(”Contrn-type”,”text/xml”);
xmlHTTP.setRequestHeader(”Contrn-charset”,”gb2312″);

xmlHTTP.send(v);
view.innerHTML = xmlHTTP.responseText;
hooke();
if(xmlHTTP.responseText.indexOf(”Error:”)!=-1) {
alert(xmlHTTP.responseText);
}
}
// 以下函数用于与vml文档交互
function cursor() {}
function mouse_down() {}
function mouse_up() {}
function setOverColor() {}
function setOutColor() {}
function deleteNode() {}
</script>
<body onLoad=”loadXML(1)”>
<table>
<tr>
<td>作品展示</td>
</tr>
<tr>
<td id=”view”></td>
</tr>
<tr>
<td>
<?php
// 变量num为保存的vml文档总数,这里仅简单的指定。请根据实际的组织调整
$num = 10;
for($i=1;$i<=$num;$i++)
echo sprintf(”<span style=\”cursor:hand;\” onClick=\”loadXML(%d)\” nobr>%4d</span>\n”,$i,$i);
?>
</td>
</tr>
<tr>
<td style=”cursor:help;” onClick=”code.innerText=view.innerHTML”>查看VML代码</td>
</tr>
<tr>
<td id=”code”></td>
</tr>
</table>
</body>
</html>

产业新闻

VML绘图板④简化的服务器端–server.php、server.asp

Tags: ,

服务器端
************
* server.php
************
<?php
$s = $HTTP_RAW_POST_DATA;
$t = gettimeofday();
$n = $t[sec].$t[usec];
$filename = “vml/” .$n. “.txt”;
$fp = fopen($filename,”w”);
fwrite($fp,$s);
fclose($fp);
echo $s;
?>

************
* server.asp
************
<%@ Language=VBScript %>
<%
Response.expires=-1
dim xmlrec
set xmlrec=server.CreateObject(”microsoft.xmldom”)
xmlrec.async=false
xmlrec.load(Request)
xmlrec.save Server.MapPath(”.”)&”\xxxx.xml”
%>

产业新闻

VML绘图板③资源–VMLgraph.xml

Tags: ,

资源
***************
* VMLgraph.xml
***************
<?xml version=”1.0″ encoding=”GB2312″ ?>
<root xmlns:v=”urn:schemas-microsoft-com:vml”>
<toolbar id=”1″>
<v:group ID=”cut” style=”width:24; height:24; cursor:hand” coordsize=”30,30″ title=”裁剪” onClick=”select(this)”>
<v:rect style=”width:30; height:30;” fillcolor=”#ffffff” strokecolor=”#000000″ strokeweight=”1″ />
<v:line from=”11,4″ to=”20,26″ />
<v:arc style=”left:6; top:12; width:8; height:12;” startangle=”180″ endangle=”400″>
<v:fill opacity=”0″ />
</v:arc>
<v:line from=”19,4″ to=”10,26″ />
<v:arc style=”left:16; top:12; width:8; height:12;” startangle=”0″ endangle=”180″>
<v:fill opacity=”0″ />
</v:arc>
</v:group>
</toolbar>
<toolbar id=”2″>
<v:group style=”width:24; height:24; cursor:hand” coordsize=”30,30″ title=”正常” onClick=”select(this)”>
<v:rect style=”width:30; height:30;” fillcolor=”#ffffff” strokecolor=”#000000″ strokeweight=”1″ />
<v:shape style=”width:30; height:30;” strokecolor=”#000000″>
<v:path v=”m 9,5 l 9,20, 12,16 17,25 19,23 15,15 19,15 x e” />
<v:fill opacity=”0″ />
</v:shape>
</v:group>
</toolbar>
<toolbar id=”3″>
<v:group style=”width:24; height:24; cursor:hand” coordsize=”30,30″ title=”点、线” onClick=”select(this)”>
<v:rect style=”width:30; height:30;” fillcolor=”#ffffff” strokecolor=”#000000″ strokeweight=”1″ />
<v:line from=”8,8″ to=”22,22″/>
</v:group>
</toolbar>
<toolbar id=”5″>
<v:group style=”width:24; height:24; cursor:hand” coordsize=”30,30″ title=”矩形” onClick=”select(this)”>
<v:rect style=”width:30; height:30;” fillcolor=”#ffffff” strokecolor=”#000000″ strokeweight=”1″ />
<v:rect style=”top:4; left:4; width:22; height:22;”>
<v:fill opacity=”0″ />
</v:rect>
</v:group>
</toolbar>
<toolbar id=”6″>
<v:group style=”width:24; height:24; cursor:hand” coordsize=”30,30″ title=”圆角矩形” onClick=”select(this)”>
<v:rect style=”width:30; height:30;” fillcolor=”#ffffff” strokecolor=”#000000″ strokeweight=”1″ />
<v:roundrect style=”top:4; left:4; width:22; height:22;” arcsize=”0.2″>
<v:fill opacity=”0″ />
</v:roundrect>
</v:group>
</toolbar>
<toolbar id=”8″>
<v:group style=”width:24; height:24; cursor:hand” coordsize=”30,30″ title=”圆、椭圆” onClick=”select(this)”>
<v:rect style=”width:30; height:30;” fillcolor=”#ffffff” strokecolor=”#000000″ strokeweight=”1″ />
<v:oval style=”top:4; left:4; width:22; height:22″>
<v:fill opacity=”0″ />
</v:oval>
</v:group>
</toolbar>
<toolbar id=”7″>
<v:group style=”width:24; height:24; cursor:hand” coordsize=”30,30″ title=”多边形” onClick=”select(this)”>
<v:rect style=”width:30; height:30;” fillcolor=”#ffffff” strokecolor=”#000000″ strokeweight=”1″ />
<v:shape style=”width:30; height:30;” path=”m 14,4 l 4,14 12,24 24,18 15,12 x e”>
<v:fill opacity=”0″ />
</v:shape>
</v:group>
</toolbar>
<toolbar id=”9″>
<v:group style=”width:24; height:24; cursor:hand” coordsize=”30,30″ title=”折线” onClick=”select(this)”>
<v:rect style=”width:30; height:30;” fillcolor=”#ffffff” strokecolor=”#000000″ strokeweight=”1″ />
<v:polyline points=”4,18 20,4 8,20 24,10 10,22 22,20″>
<v:fill opacity=”0″ />
</v:polyline>
</v:group>
</toolbar>
<toolbar id=”4″>
<v:group style=”width:24; height:24; cursor:hand” coordsize=”30,30″ title=”曲线” onClick=”select(this)”>
<v:rect style=”width:30; height:30;” fillcolor=”#ffffff” strokecolor=”#000000″ strokeweight=”1″ />
<v:curve from=”4,24″ control1=”8,-10″ control2=”20,30″ to=”24,4″>
<v:fill opacity=”0″ />
</v:curve>
</v:group>
</toolbar>
<toolbar id=”10″>
<v:group style=”width:24; height:24; cursor:hand” coordsize=”30,30″ fillcolor=”#ffffff” title=”文字” onClick=”select(this)”>
<v:rect style=”width:30; height:30;” strokecolor=”#000000″ strokeweight=”1″ />
<v:line from=”14,4″ to=”4,26″ />
<v:line from=”15,4″ to=”24,26″ />
<v:line from=”10,18″ to=”20,18″ />
</v:group>
</toolbar>
<colorbar>
<table cellspacing=”0″ cellpadding=”0″>
<tr>
<td rowspan=”2″>
<v:group style=”width:30; height:30;” coordsize=”40,40″>
<v:rect style=”width:40; height:40;” fillcolor=”#ccc’” />
<v:rect id=”color2″ style=”left:16; top:16; width:20; height:20;” fillcolor=”#ffffff” onMouseDown=”setcolorkey=this” title=”充填色” />
<v:rect id=”color1″ style=”left:4; top:4; width:20; height:20;” fillcolor=”#000000″ onMouseDown=”setcolorkey=this” title=”绘图色” />
</v:group>
</td>
<td>
<v:rect style=”width:30; height:15;” fillcolor=”#000000″ onClick=”setcolor(this.fillcolor)” />
<v:rect style=”width:30; height:15;” fillcolor=”#808080″ onClick=”setcolor(this.fillcolor)” />
<v:rect style=”width:30; height:15;” fillcolor=”#800000″ onClick=”setcolor(this.fillcolor)” />
<v:rect style=”width:30; height:15;” fillcolor=”#808000″ onClick=”setcolor(this.fillcolor)” />
<v:rect style=”width:30; height:15;” fillcolor=”#008000″ onClick=”setcolor(this.fillcolor)” />
<v:rect style=”width:30; height:15;” fillcolor=”#008080″ onClick=”setcolor(this.fillcolor)” />
<v:rect style=”width:30; height:15;” fillcolor=”#000080″ onClick=”setcolor(this.fillcolor)” />
<v:rect style=”width:30; height:15;” fillcolor=”#800080″ onClick=”setcolor(this.fillcolor)” />
<v:rect style=”width:30; height:15;” fillcolor=”#808040″ onClick=”setcolor(this.fillcolor)” />
<v:rect style=”width:30; height:15;” fillcolor=”#004040″ onClick=”setcolor(this.fillcolor)” />
<v:rect style=”width:30; height:15;” fillcolor=”#0080ff” onClick=”setcolor(this.fillcolor)” />
<v:rect style=”width:30; height:15;” fillcolor=”#004080″ onClick=”setcolor(this.fillcolor)” />
<v:rect style=”width:30; height:15;” fillcolor=”#4000ff” onClick=”setcolor(this.fillcolor)” />
<v:rect style=”width:30; height:15;” fillcolor=”#804000″ onClick=”setcolor(this.fillcolor)” />
</td>
</tr>
<tr>
<td>
<v:rect style=”width:30; height:15;” fillcolor=”#ffffff” onClick=”setcolor(this.fillcolor)” />
<v:rect style=”width:30; height:15;” fillcolor=”#c0c0c0″ onClick=”setcolor(this.fillcolor)” />
<v:rect style=”width:30; height:15;” fillcolor=”#ff0000″ onClick=”setcolor(this.fillcolor)” />
<v:rect style=”width:30; height:15;” fillcolor=”#ffff00″ onClick=”setcolor(this.fillcolor)” />
<v:rect style=”width:30; height:15;” fillcolor=”#00ff00″ onClick=”setcolor(this.fillcolor)” />
<v:rect style=”width:30; height:15;” fillcolor=”#00ffff” onClick=”setcolor(this.fillcolor)” />
<v:rect style=”width:30; height:15;” fillcolor=”#0000ff” onClick=”setcolor(this.fillcolor)” />
<v:rect style=”width:30; height:15;” fillcolor=”#ff00ff” onClick=”setcolor(this.fillcolor)” />
<v:rect style=”width:30; height:15;” fillcolor=”#ffff80″ onClick=”setcolor(this.fillcolor)” />
<v:rect style=”width:30; height:15;” fillcolor=”#80ffff” onClick=”setcolor(this.fillcolor)” />
<v:rect style=”width:30; height:15;” fillcolor=”#80ffff” onClick=”setcolor(this.fillcolor)” />
<v:rect style=”width:30; height:15;” fillcolor=”#8080ff” onClick=”setcolor(this.fillcolor)” />
<v:rect style=”width:30; height:15;” fillcolor=”#ff0080″ onClick=”setcolor(this.fillcolor)” />
<v:rect style=”width:30; height:15;” fillcolor=”#ff8040″ onClick=”setcolor(this.fillcolor)” />
</td>
</tr>
</table>
</colorbar>
<linebox>
<v:group style=”width:50; height:80″ coordsize=”50,80″ title=”线型选择”>
<v:rect style=”width:50; height:80″ />
<v:line from=”4,4″ to=”46,4″ onClick=”dashstyle.dashstyle=this.stroke.dashstyle”>
<v:stroke dashstyle=”solid” />
</v:line>
<v:line from=”4,10″ to=”46,10″ onClick=”dashstyle.dashstyle=this.stroke.dashstyle”>
<v:stroke dashstyle=”shortdash” />
</v:line>
<v:line from=”4,16″ to=”46,16″ onClick=”dashstyle.dashstyle=this.stroke.dashstyle”>
<v:stroke dashstyle=”shortdot” />
</v:line>
<v:line from=”4,22″ to=”46,22″ onClick=”dashstyle.dashstyle=this.stroke.dashstyle”>
<v:stroke dashstyle=”shortdashdot” />
</v:line>
<v:line from=”4,28″ to=”46,28″ onClick=”dashstyle.dashstyle=this.stroke.dashstyle”>
<v:stroke dashstyle=”shortdashdotdot” />
</v:line>
<v:line from=”4,34″ to=”46,34″ onClick=”dashstyle.dashstyle=this.stroke.dashstyle”>
<v:stroke dashstyle=”dash” />
</v:line>
<v:line from=”4,40″ to=”46,40″ onClick=”dashstyle.dashstyle=this.stroke.dashstyle”>
<v:stroke dashstyle=”dot” />
</v:line>
<v:line from=”4,46″ to=”46,46″ onClick=”dashstyle.dashstyle=this.stroke.dashstyle”>
<v:stroke dashstyle=”dashdot” />
</v:line>
<v:line from=”4,52″ to=”46,52″ onClick=”dashstyle.dashstyle=this.stroke.dashstyle”>
<v:stroke dashstyle=”longdash” />
</v:line>
<v:line from=”4,58″ to=”46,58″ onClick=”dashstyle.dashstyle=this.stroke.dashstyle”>
<v:stroke dashstyle=”longdashdot” />
</v:line>
<v:line from=”4,64″ to=”46,64″ onClick=”dashstyle.dashstyle=this.stroke.dashstyle”>
<v:stroke dashstyle=”longdashdotdot” />
</v:line>
<v:rect style=”left:2; top:68; width:46; height:8;” fillcolor=”#c0c0c0″ strokecolor=”#c0c0c0″ />
<v:line from=”6,72″ to=”44,72″>
<v:stroke id=”dashstyle” dashstyle=”solid” size=”4″ />
</v:line>
</v:group>
</linebox>
<gradient>
<v:group style=”WIDTH:120;HEIGHT:120″ coordsize=”120,120″ onMouseMove=”cursor(1)” onMouseOut=”cursor(0)” title=”过渡色充填”>
<v:rect style=”width:120; height:120;” fillcolor=”#ffffff” strokecolor=”#000000″ strokeweight=”1″ />
<v:group style=”left:35; top:13; width:50; height:34″  coordsize=”50,34″>
<v:rect style=”width:50; height:34″ fillcolor=”#ffff80″ />
<v:rect style=”left:6; top:4; width:16; height:20;” fillcolor=”#0000FF” />
<v:oval style=”left:18; top:4; width:26; height:26;” fillcolor=”#00ff00″ />
<v:shape style=”width:50; height:34″ path=”m 8,30 l 22,15 36,30 x e” fillcolor=”#FF0000″ />
</v:group>
<v:rect style=”left:10; top:10; width:100; height:40;”>
<v:fill id=”gradientBar” opacity=”50%” type=”gradient” color=”red” color2=”blue” angle=”270″ colors=”30% yellow,70% green”  focusposition=”50%,50%”/>
</v:rect>
<v:shape id=”gradient1″ style=”left:8; top:50; width:120; height:100;” fillcolor=”red” path=”m 2,0 l 0,4 0,10 5,10 5,4 x e” onClick=”gradientColor(this)” />
<v:shape id=”gradient4″ style=”left:108; top:50; width:120; height:100;” fillcolor=”blue” path=”m 2,0 l 0,4 0,10 5,10 5,4 x e” onClick=”gradientColor(this)” />
<v:shape id=”gradient2″ style=”left:38; top:50; width:120; height:100;” fillcolor=”yellow” path=”m 2,0 l 0,4 0,10 5,10 5,4 x e” onClick=”gradientColor(this)” onMouseMove=”gradientPoint(this)” onMouseOut=”gradientX=-1″ title=”色阶1″ />
<v:shape id=”gradient3″ style=”left:78; top:50; width:120; height:100;” fillcolor=”green” path=”m 2,0 l 0,4 0,10 5,10 5,4 x e” onClick=”gradientColor(this)” onMouseMove=”gradientPoint(this)” onMouseOut=”gradientX=-1″ title=”色阶2″ />
<v:line from=”10,70″ to=”110,70″ title=”焦点1″ />
<v:shape id=”focus1″ style=”left:58; top:66; width:120; height:100;” fillcolor=”white” path=”m 2,0 l 0,4 2,8 4,4 x e” onMouseMove=”gradientPoint(this)” onMouseOut=”gradientX=-1″ title=”焦点1″ />
<v:line from=”10,80″ to=”110,80″ title=”焦点2″ />
<v:shape id=”focus2″ style=”left:58; top:76; width:120; height:100;” fillcolor=”red” path=”m 2,0 l 0,4 2,8 4,4 x e” onMouseMove=”gradientPoint(this)” onMouseOut=”gradientX=-1″ title=”焦点2″ />
<v:line from=”10,90″ to=”110,90″ title=”旋转角” />
<v:line from=”10,90″ to=”10,95″ title=”0°” onClick=”anglePoint(this)” />
<v:line from=”35,90″ to=”35,95″ title=”90°” onClick=”anglePoint(this)” />
<v:line from=”60,90″ to=”60,95″ title=”180°” onClick=”anglePoint(this)” />
<v:line from=”85,90″ to=”85,95″ title=”270°” onClick=”anglePoint(this)” />
<v:line from=”110,90″ to=”110,95″ title=”360°” onClick=”anglePoint(this)” />
<v:shape id=”angle” style=”left:83; top:86; width:120; height:100;” fillcolor=”white” path=”m 2,0 l 0,4 2,8 4,4 x e” onMouseMove=”gradientPoint(this)” onMouseOut=”gradientX=-1″ title=”旋转角” />
<v:line from=”10,100″ to=”110,100″ title=”透明度” />
<v:line from=”10,100″ to=”10,105″ title=”100%” onClick=”opacityPoint(this)” />
<v:line from=”60,100″ to=”60,105″ title=”50%” onClick=”opacityPoint(this)” />
<v:line from=”110,100″ to=”110,105″ title=”0%” onClick=”opacityPoint(this)” />
<v:shape id=”opacity” style=”left:58; top:96; width:120; height:100;” fillcolor=”white” path=”m 2,0 l 0,4 2,8 4,4 x e” onMouseMove=”gradientPoint(this)” onMouseOut=”gradientX=-1″ title=”透明度” />
</v:group>
</gradient>
</root>

产业新闻

VML绘图板②脚本–VMLgraph.js、XMLtool.js

Tags: ,

脚本
*************
* VMLgraph.js
*************
var xo=0;
var yo=0;
var ox=80;
var oy=20;
var dx=0;
var dy=0;
var drawKey = false;
var itemID = 0;
var ShapeItemNum = 0;
var ShapeItemX = 0;
var ShapeItemY = 0;
var CurveItemNum = 0;
var NodeDelete = false;
var ToolBarNum = 2; // 预置的工具编号
var gradientX = -1;

function cursor(k) {
xo = event.clientX – ox;
yo = event.clientY – oy;
if(k && xo>=0 && yo>=0)
oxy.innerHTML = xo+”,”+yo;
else
oxy.innerHTML = “”;
if(drawKey) {
paint();
view.innerHTML = tree(canvas.documentElement,0);
}
}

function setOverColor(v) {
if(! NodeDelete) return;
v.myColor = v.strokecolor;
if(v.strokecolor == “red”)
v.strokecolor=’#000000′;
else
v.strokecolor=’#ff0000′;
}
function setOutColor(v) {
if(! NodeDelete) return;
v.strokecolor = v.myColor;
view.innerHTML = tree(canvas.documentElement,0);
}
function deleteNode(v) {
if(! NodeDelete) return;
var id = v.id;
for(i=0;i<canvas.selectNodes(”/*//*”).length;i++) {
var node = canvas.selectNodes(”/*//*”)[i];
if(node.getAttribute(”id”) == id) {
canvas.documentElement.childNodes[0].removeChild(node);
view.innerHTML = tree(canvas.documentElement,0);
return;
}
}
}

function setElement(node) {
node.setAttribute(”id”) = itemID;
node.setAttribute(”myColor”) = “#”;
node.setAttribute(”onMouseOver”) = “setOverColor(this)”;
node.setAttribute(”onMouseOut”) = “setOutColor(this)”;
node.setAttribute(”onClick”) = “deleteNode(this)”;

var subobjField = canvas.createElement(”v:stroke”);
subobjField.setAttribute(”color”) = color1.fillcolor;
subobjField.setAttribute(”dashstyle”) = dashstyle.dashstyle;
node.appendChild(subobjField);
if(textbox.style.visibility == “visible” && txt.value.length) {
var subobjField = canvas.createElement(”v:path”);
subobjField.setAttribute(”textpathok”) = “true”;
node.appendChild(subobjField);
var subobjField = canvas.createElement(”v:textpath”);
subobjField.setAttribute(”on”) = “true”;
subobjField.setAttribute(”string”) = txt.value;
subobjField.setAttribute(”style”) = “font:normal normal normal 16pt ‘Arial Black’”;
node.appendChild(subobjField);
}
canvas.documentElement.childNodes[0].appendChild(node);
}

function mouse_down() {
drawKey = true;
dx = xo;
dy = yo;
itemID++;
if(ToolBarNum != 7) ShapeItemNum = 0;
switch(ToolBarNum) {
case 3:
var objField = canvas.createElement(”v:line”);
objField.setAttribute(”from”) = xo+”,”+yo;
objField.setAttribute(”to”) = xo+”,”+yo;
return setElement(objField);
case 4:
if(CurveItemNum == 0) {
CurveItemNum = 1;
var objField = canvas.createElement(”v:curve”);
objField.setAttribute(”from”) = xo+”,”+yo;
objField.setAttribute(”to”) = xo+”,”+yo;
objField.setAttribute(”control1″) = xo+”,”+yo;
objField.setAttribute(”control2″) = xo+”,”+yo;
var subobjField = canvas.createElement(”v:fill”);
subobjField.setAttribute(”opacity”) = 0;
objField.appendChild(subobjField);
return setElement(objField);
}
return;
case 9:
var objField = canvas.createElement(”v:polyline”);
objField.setAttribute(”points”) = xo+”,”+yo+” “+xo+”,”+yo;
var subobjField = canvas.createElement(”v:fill”);
subobjField.setAttribute(”opacity”) = 0;
objField.appendChild(subobjField);
return setElement(objField);
case 7:
if(ShapeItemNum == 0) {
var objField = canvas.createElement(”v:shape”);
objField.setAttribute(”style”) = “width:500; height:309″;
objField.setAttribute(”path”) = “m “+xo+”,”+yo+” l “+xo+”,”+yo;
ShapeItemX = xo;
ShapeItemY = yo;
}else {
objField = canvas.documentElement.childNodes[0].lastChild;
objField.setAttribute(”path”) = objField.getAttribute(”path”) + ” “+xo+”,”+yo;
return;
}
ShapeItemNum++;
break;
case 5:
var objField = canvas.createElement(”v:rect”);
break;
case 6:
var objField = canvas.createElement(”v:roundrect”);
objField.setAttribute(”arcsize”) = 0.2;
break;
case 8:
var objField = canvas.createElement(”v:oval”);
break;
case 10:
s = “”;
s = tree(canvas.documentElement,1);
view.innerHTML = s;
return;
defaule:
drawKey = false;
return;
}
if(objField) {
if(ToolBarNum != 7)
objField.setAttribute(”style”) = “left:”+xo+”; top:”+yo+”; width:0; height:0;”;
var subobjField = canvas.createElement(”v:fill”);
subobjField.setAttribute(”opacity”) = gradientBar.opacity;
subobjField.setAttribute(”angle”) = gradientBar.angle;
subobjField.setAttribute(”type”) = gradientBar.type;
subobjField.setAttribute(”color”) = gradientBar.color.value;
subobjField.setAttribute(”color2″) = gradientBar.color2.value;
subobjField.setAttribute(”colors”) = gradientBar.colors.value;
subobjField.setAttribute(”focusposition”) = gradientBar.focusposition;
objField.appendChild(subobjField);
return setElement(objField);
}
return;
}

function mouse_up() {
drawKey = false;
if(CurveItemNum > 0) CurveItemNum++;
if(CurveItemNum > 3) CurveItemNum = 0;
if(ToolBarNum == 7) {
if(Math.abs(xo – ShapeItemX) < 2 && Math.abs(yo – ShapeItemY) < 2) {
ShapeItemNum = 0;
Element = canvas.documentElement.childNodes[0].lastChild;
var regerp = / [0-9]+,[0-9]+$/
var str = Element.getAttribute(”path”);
Element.setAttribute(”path”) = str.replace(regerp,” x e”);
view.innerHTML = tree(canvas.documentElement,0);
}
}
}

function paint() {
Element = canvas.documentElement.childNodes[0].lastChild;
var x0,y0,x1,y1;
x0 = Math.min(dx,xo);
y0 = Math.min(dy,yo);
x1 = Math.max(dx,xo);
y1 = Math.max(dy,yo);
var box = “left:”+x0+”; top:”+y0+”; width:”+(x1-x0)+”; height:”+(y1-y0)+”;”;
switch(ToolBarNum) {
case 4:
if(CurveItemNum ==2) {
Element.setAttribute(”control1″) = xo+”,”+yo;
Element.setAttribute(”control2″) = Element.getAttribute(”to”);
break;
}
if(CurveItemNum ==3) {
Element.setAttribute(”control2″) = xo+”,”+yo;
break;
}
case 3:
Element.setAttribute(”to”) = xo+”,”+yo;
break;
case 7:
var regerp = /[0-9]+,[0-9]+$/
var str = Element.getAttribute(”path”);
Element.setAttribute(”path”) = str.replace(regerp,xo+”,”+yo);
break;
case 5:
case 6:
case 8:
var regerp = /left.+height:[0-9]+;/
var str = Element.getAttribute(”style”);
Element.setAttribute(”style”) = str.replace(regerp,box);
break;
case 9:
var regerp = / [0-9]+,[0-9]+$/
var str = Element.getAttribute(”points”);
Element.setAttribute(”points”) = str+” “+xo+”,”+yo;
break;
defaule:
break;
}

}

function init() {
tool_box_refresh();  // 工具栏初始
view.innerHTML = tree(canvas.documentElement);  // 绘图区初始
color.innerHTML = tree(tools.selectNodes(”*/colorbar”)[0]);  // 颜色选择初始
linebox.innerHTML = tree(tools.selectNodes(”*/linebox”)[0]);  // 线型选择初始
gradientBox.innerHTML = tree(tools.selectNodes(”*/gradient”)[0]);  // 充填选择初始
}

// 绘制工具栏
function tool_box_refresh() {
var buffer = “”;
var i;
for(i=0;i<tools.selectNodes(”*/toolbar”).length;i++) {
var node = tools.selectNodes(”*/toolbar”)[i];
var id = node.getAttribute(”id”);
node.childNodes[0].setAttribute(”onClick”) = “tool_box_select(”+id+”,this.title)”;
var node1 = node.selectNodes(”*/v:rect”)[0];
if(id == ToolBarNum) {
node1.setAttribute(”fillcolor”) = “#ffcccc”
node1.setAttribute(”strokecolor”) = “#ff0000″
}else {
node1.setAttribute(”fillcolor”) = “#ffffff”
node1.setAttribute(”strokecolor”) = “#000000″
}
buffer += tree(node.childNodes[0]);
}
toolbox.innerHTML = buffer;
}

// 工具选择
function tool_box_select(v,t) {
var key = ToolBarNum;
ToolBarNum = v;
tool_box_refresh();
hooke();
if(v == 7) {
if(key == 7 && ShapeItemNum > 0) {
Element = canvas.documentElement.childNodes[0].lastChild;
var str = Element.getAttribute(”path”);
Element.setAttribute(”path”) = str + ” x e”;
view.innerHTML = tree(canvas.documentElement,0);
ShapeItemNum = 0;
}
}
if(v == 10)
if(textbox.style.visibility == “hidden”)
textbox.style.visibility = “visible”;
else
textbox.style.visibility = “hidden”;
NodeDelete = false;
if(v == 1) {
NodeDelete = true;
view.innerHTML = tree(canvas.documentElement,0);
}
}

// 颜色选择
//var setcolorkey = color1;
function setcolor(c) {
var setcolorkey = color1;
setcolorkey.fillcolor = c;
}

function gradientColor(v) {
v.fillcolor = color1.fillcolor;
gradientRefresh();
return;
var m = tools.documentElement.selectNodes(”/*/gradient//v:shape”).length;
var node = tools.documentElement.selectNodes(”/*/gradient//v:shape”);
for(i=0;i<m;i++) {
if(node[i].getAttribute(”id”) == v.id)
node[i].setAttribute(”fillcolor”) = color1.fillcolor;
}
gradientRefresh();
}
function gradientPoint(v) {
if(gradientX < 0)
gradientX = xo – 508 – parseInt(v.style.left);
n = xo – 508 – gradientX;
if(n < 8) n = 8;
if(n > 108) n = 108;
v.style.left = n;
gradientRefresh();
}
function anglePoint(v) {
angle.style.left = Math.floor((xo-516)/25)*25+8;
gradientRefresh();
}
function opacityPoint(v) {
opacity.style.left = Math.floor((xo-516)/25)*25+8;
gradientRefresh();
}
function settype(v) {
if(v.style.borderColor == “black”)
v.style.borderColor = “red”;
else
v.style.borderColor = “black”;
gradientRefresh();
}
function setGradientX() {
gradientX = -1;
}

function gradientRefresh() {
var m = (parseInt(gradient4.style.left)-parseInt(gradient1.style.left));
var n1 = (parseInt(gradient2.style.left)-parseInt(gradient1.style.left))/m*100;
var n2 = (parseInt(gradient3.style.left)-parseInt(gradient1.style.left))/m*100;
gradientBar.color.value = gradient1.fillcolor;
gradientBar.color2.value = gradient4.fillcolor;
if(type3.style.borderColor == “black”)
gradientBar.colors.value = “,”;
else
gradientBar.colors.value = n1 + “% ” + gradient2.fillcolor + “,” + n2 + “% ” + gradient3.fillcolor;
if(type1.style.borderColor == “black”)
gradientBar.type = “solid”;
else
gradientBar.type = “gradient”;
if(type2.style.borderColor == “red”)
gradientBar.type = “gradientradial”;
n1 = (parseInt(focus1.style.left)-8)/m*100;
n2 = (parseInt(focus2.style.left)-8)/m*100;
gradientBar.focusposition.value = n1 + “%,” + n2 + “%”;
gradientBar.angle = (parseInt(angle.style.left)-8) * 3.6;
gradientBar.opacity = (parseInt(opacity.style.left)-8)/m
}

*************
* XMLtool.js
*************

// 传送XML文档到服务器
function saveXML()
{
var xmlHTTP = new ActiveXObject(”Microsoft.XMLHTTP”);
xmlHTTP.open(”POST”,”server.php”,false); // 使用ASP时用server.asp
xmlHTTP.setRequestHeader(”Contrn-type”,”text/xml”);
xmlHTTP.setRequestHeader(”Contrn-charset”,”gb2312″);

xmlHTTP.send(tree(canvas.documentElement));
var s = xmlHTTP.responseText;
minview.innerHTML = s.replace(/WIDTH:500;HEIGHT:300/,”WIDTH:120;HEIGHT:72″)
if(xmlHTTP.responseText.indexOf(”Error:”)!=-1) {
alert(xmlHTTP.responseText);
}
}

// 遍历xml对象,解析xml的核心函数集
function tree(Element,debug) {
var buffer = “”;
var node = “”;
if(Element.nodeType != 3) {
node = Element;
buffer += onElement(Element,debug);
}
if(Element.nodeType == 3)
buffer += onData(Element);
if(Element.hasChildNodes) {
for(var i=0;i<Element.childNodes.length;i++) {
buffer += tree(Element.childNodes(i),debug);
}
}
if(node)
buffer += endElement(node,debug);
return buffer;
}

/***** 以下三个函数请根据需要自行修改 *****/
// 遍历xml对象–节点开始
function onElement(Element,debug) {
var buffer = (debug ? “<” : “<”) + Element.nodeName;
n = Element.attributes.length
if(n>0) {  // 若该节点有参数
for(var i=0;i<n;i++)
buffer += ‘ ‘ + Element.attributes(i).name + ‘=\”‘ + Element.attributes(i).value + ‘”‘;
}
buffer += debug ? “>” : “>”;
return buffer;
}

// 遍历xml对象–节点结束
function endElement(Element,debug) {
return (debug ? “</” : “</”) + Element.nodeName + (debug ? “><br>” : “>”);
}

// 遍历xml对象–节点数据
function onData(Element) {
return Element.nodeValue
}