日期:2010-11-20 浏览次数:20462 次
脚本
*************
* 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;