- 浏览: 140359 次
- 性别:
- 来自: 未来
-
文章分类
- 全部博客 (174)
- Eclispe (3)
- javaScript (33)
- SVG学习 (22)
- Java (21)
- 网站 (12)
- learn English (1)
- 文档 (25)
- 常用网站收录 (11)
- struts (6)
- 常用API (1)
- html (2)
- jsp (2)
- spring (2)
- IDE (1)
- 数据结构 (1)
- JDBC (2)
- html + css (1)
- xml (3)
- 心声 (1)
- Axis2 (1)
- svg (4)
- webService (2)
- unix (2)
- c/c++ (3)
- html5 (1)
- Android (2)
- Jet标签 (1)
- oracle (2)
- 工具 (1)
- ideas (0)
- lean plan (1)
- java技术网站,信息收集综合及分类 (0)
最新评论
-
calosteward:
感谢博主对svg convert to PDF资源的分享。我也 ...
How to Convert a SVG File to PDF Format -
long316:
fhhhh
WinArchiver 2.7 -
long316:
ddddd
WinArchiver 2.7
该例实现了,画线,圆,矩形,以及选择图形,并把图形至于顶层,还有拖动图形等功能。对于使用Javascript语言分析SVG文件有很大的帮助。感谢不知名的提供者。
http://www.cnblogs.com/mydriverc/archive/2008/01/21/1047563.html
<?xml version="1.0" encoding="iso-8859-1"?>
<svg id="svg" viewBox="0 0 1006 616">
<script type="text/javascript">
<![CDATA[
//编辑 删除
//----------------draw circle---------------------
var xCenter;
var yCenter;
var rCircle;
var circleFlag=0;
var codeCircle;
var sd=document.getElementById("SD");
function drawCircle(){
var newCircle=document.createElement("circle");
xCenter=evt.getClientX();
yCenter=evt.getClientY();
newCircle.setAttribute("cx",xCenter);
newCircle.setAttribute("cy",yCenter);
newCircle.setAttribute("r",0);
newCircle.setAttribute("stroke","red");
newCircle.setAttribute("stroke-width","1");
newCircle.setAttribute("fill","blue");
var plat=document.getElementById("plat");
plat.appendChild(newCircle);
circleFlag=1
}
function modifyCircle(){
if(circleFlag==1){
var plat=document.getElementById("plat");
var theCircle=plat.lastChild;
var screenX =evt.getClientX();
var screenY =evt.getClientY();
x=screenX-xCenter;
y=screenY-yCenter;
rCircle= parseInt(Math.sqrt(x*x+y*y));
theCircle.setAttribute("r",rCircle);
}
}
function endCircle(){
//codeCircle="<circle cx=""+xCenter+"" cy=""+yCenter+"" r=""+rCircle+"" stroke="red" stroke-width="1"
fill="blue" />";
//codeAll=codeAll+codeCircle;
circleFlag=0;
var plat=document.getElementById("plat");
theCircle=plat.lastChild;
plat.appendChild(theCircle);
sd.firstChild.setData(codeCircle);
}
//-----------------draw rect----------------------
var xRectStart;
var yRectStart;
var rectFlag=0;
var codeRect;
var widthRect;
var heightRect;
var sd=document.getElementById("SD");
function drawRect(){
var newRect=document.createElement("rect");
xRectStart=evt.getClientX();
yRectStart=evt.getClientY();
newRect.setAttribute("x",xRectStart);
newRect.setAttribute("y",yRectStart);
newRect.setAttribute("width",0);
newRect.setAttribute("height",0);
newRect.setAttribute("stroke","red");
newRect.setAttribute("stroke-width","1");
newRect.setAttribute("fill","blue");
var plat=document.getElementById("plat");
plat.appendChild(newRect);
rectFlag=1
}
function modifyRect(){
if(rectFlag==1){
var plat=document.getElementById("plat");
var theCircle=plat.lastChild;
var screenX =evt.getClientX();
var screenY =evt.getClientY();
widthRect=screenX-xRectStart;
heightRect=screenY-yRectStart;
theCircle.setAttribute("width",widthRect);
theCircle.setAttribute("height",heightRect);
}
}
function endRect(){
//codeRect="<rect x=""+xRectStart+"" y=""+yRectStart+"" width=""+widthRect+"" height=""+heightRect+""
stroke="red" stroke-width="1" fill="blue" />";
//codeAll=codeAll+codeRect;
rectFlag=0;
var plat=document.getElementById("plat");
theRect=plat.lastChild;
plat.appendChild(theRect);
sd.firstChild.setData(codeRect);
}
//---------------------draw with Image---------
var xImageScreen;
var yImageScreen;
var plat;
var switchScr="12.jpg";
var imageFlag;
var codeImage;
var sd=document.getElementById("SD");
function startImage(){
plat=document.getElementById("plat");
var newImg=document.createElement("image");
xImageScreen=evt.getClientX();
yImageScreen=evt.getClientY();
newImg.setAttribute("x",xImageScreen);
newImg.setAttribute("y",yImageScreen);
newImg.setAttribute("width","60");
newImg.setAttribute("height","60");
newImg.setAttributeNS("http://www.w3.org/2000/xlink/namespace/","xlink:href",switchScr);
plat.appendChild(newImg);
imageFlag=true;
}
function modifyImage(){
if(imageFlag==true){
theImg=plat.lastChild;
xImageScreen=evt.getClientX();
yImageScreen=evt.getClientY();
theImg.setAttribute("x",xImageScreen);
theImg.setAttribute("y",yImageScreen);
}
}
function endImage(){
//codeImage="<image x=""+xImageScreen+"" y=""+yImageScreen+"" width="60" height="60"
xlink:href=""+switchScr+""/>";
//codeAll=codeAll+codeImage;
theImg=plat.lastChild;
plat.appendChild(theImg);
imageFlag=false;
sd.firstChild.setData(codeImage);
}
//---------------------drawLine()----------------------
var xLineEnd=0;
var yLineEnd=60;
var xLineStart;
var yLineStart;
var lineFlag=false;
var codeLine;
var sd=document.getElementById("SD");
function drawLine(){
var newLine=document.createElement("line");
xLineStart=evt.getClientX();
yLineStart=evt.getClientY();
newLine.setAttribute("x1",xLineStart);
newLine.setAttribute("y1",yLineStart);
newLine.setAttribute("x2",xLineEnd);
newLine.setAttribute("y2",yLineEnd);
newLine.setAttribute("stroke","red");
newLine.setAttribute("stroke-width","2");
var plat=document.getElementById("plat");
plat.appendChild(newLine);
lineFlag=true;
}
function modifyLine(){
if(lineFlag==true){
var plat=document.getElementById("plat");
var theLine=plat.lastChild;
xLineEnd =evt.getClientX();
yLineEnd =evt.getClientY();
theLine.setAttribute("x2",xLineEnd);
theLine.setAttribute("y2",yLineEnd);
}
}
function endLine(){
// codeLine="<line x1=""+xLineStart+"" y1=""+yLineStart+"" x2=""+xLineEnd+"" y2=""+yLineEnd+""
stroke="red" stroke-width="2" />";
// codeAll=codeAll+codeLine;
lineFlag=false;
var plat=document.getElementById("plat");
theLine=plat.lastChild;
plat.appendChild(theLine);
xLineEnd=0;
yLineEnd=60;
sd.firstChild.setData(codeLine);
}
//------------------drag images-------------------
var targetMaxtrix;
var dragTarget;
var dragStartX;
var dragStartY;
var dragFlag=false;
//var backRect=document.getElementById("backRect");
var dragID;
//var hasTransform;
function startDrag(){
dragTarget=evt.target;
dragID=dragTarget.getAttribute("id");
if(dragID!="backRect"){
//dragID=dragTarget.getAttribute("id");
dragStartX=evt.getClientX();
dragStartY=evt.getClientY();
targetMaxtrix=dragTarget.getCTM();
dragFlag=true;
}
}
function modifyDrag(){
if(dragFlag){
dragModifyX=evt.getClientX();
dragModifyY=evt.getClientY();
distanceX=dragModifyX-dragStartX;
distanceY=dragModifyY-dragStartY;
newTranX=targetMaxtrix.e+distanceX;
newTranY=targetMaxtrix.f+distanceY;
dragTarget.setAttributeNS(null, 'transform', 'translate(' + newTranX + ',' + newTranY + ')');
}
}
function endDrag(){
if(dragFlag){dragTarget.parentNode.appendChild(dragTarget);}
dragFlag=false;
}
//---------------------common function---
function getActiveId(){
var id=0;
for(i=0;i<toolStatus.length;i++){
if(toolStatus[i]==1){
id=i;
break;
}
}
return id;
}
function newFile(){
alert("0");
var p=document.getElementById("plat");
var l=p.childNodes.length;
while(l!=1){
p.removeChild(p.lastChild);
l=p.childNodes.length;
}
codeAll="<?xml version="1.0" encoding="utf-8"?> <svg width="100%" height="100%"
xmlns:xlink="http://www.w3.org/1999/xlink">";
}
//-#############################--operate files-----############################
function saveFile(){
var codeContent="";
//codeAll=codeAll+codeEnd
//-----------saveObject--------------
p=evt.target.ownerDocument.getElementById("plat");
nodeList=p.childNodes;
//------------------learn new knowledge printNode(node)----------------------
for(i=0;i<nodeList.length;i++){
codeContent=codeContent+printNode(nodeList.item(i))+" ";
}
alert(codeContent);
codeAll=codeAll+codeContent;
codeAll=codeAll+codeEnd;
//---------save file --------
var fso, f1;
fso = new ActiveXObject("Scripting.FileSystemObject");
f1 = fso.CreateTextFile(fileName, true);
f1.WriteLine(codeAll);
f1.Close();
alert("the location of the file : "+fileName);
//--------------------
//codeAll=codeAll.substring(0,codeAll.length-6);
codeAll="<?xml version="1.0" encoding="utf-8"?> <svg width="100%" height="100%"
xmlns:xlink="http://www.w3.org/1999/xlink">";
}
//---------------open file---------------------
function openFile(){
xmlDoc = getURL(fileName,fn)
}
function fn(xmlDoc)
{
alert("the location of the opened file: "+fileName);
var x = parseXML(xmlDoc.content,document)
openFilePlat=document.getElementById("plat");
var nodeList=x.getChildNodes();
var nodeListInner=nodeList.item(0).getChildNodes();
removeAllChild();//clear all the Elements in <g>
for(i=0;i<nodeListInner.length;i++){
if(nodeListInner.item(i).nodeType==1){
openFilePlat.appendChild(nodeListInner.item(i));
}
}
}
function removeAllChild(){
var platRemoveAll=document.getElementById("plat");
var removeAllLength=platRemoveAll.childNodes.length;
while(removeAllLength!=0){
platRemoveAll.removeChild(platRemoveAll.lastChild);
removeAllLength=platRemoveAll.childNodes.length;
}
}
//--#############################common vars########################
//-----------file vars-----------------------
var codeAll="<?xml version="1.0" encoding="utf-8"?> <svg width="100%" height="100%"
xmlns:xlink="http://www.w3.org/1999/xlink">";
var codeEnd="</svg>";
var fileName="./svgFile/test.svg";
//-------------------mainDraw-----------------
function startDraw(){
id=getActiveId();
switch(id){
case 0 :{startDrag();break;}
case 1 :{ drawRect();break;}
case 2 :{ drawCircle();break;}
case 3 :{ drawLine();break;}
case 4 :{ startImage();break;}
}
}
function modifyDraw(){
id=getActiveId();
switch(id){
case 0 :{modifyDrag();break;}
case 1 :{ modifyRect();break;}
case 2 :{ modifyCircle();break;}
case 3 :{ modifyLine();break;}
case 4 :{ modifyImage();break;}
}
}
function endDraw(){
id=getActiveId();
switch(id){
case 0 :{endDrag();break;}
case 1 :{ endRect();break;}
case 2 :{ endCircle();break;}
case 3 :{ endLine();break;}
case 4 :{ endImage();break;}
}
}
//---------------------------------------
//-------------------------changStatus And hiddenTool----------
var toolStatus=new Array(1,0,0,0,0);
var toolName=new Array('move','rect','circle','line','switch');
function changeStatus(name){
var id=0;
for(i=0;i<toolName.length;i++){
if(name==toolName[i]){
id=i;
break;
}
}
for(i=0;i<toolStatus.length;i++){
if(id==i){
toolStatus[i]=1;
}else{
toolStatus[i]=0;
}
}
showHidden1(id);
}
function showHidden1(id){
if(toolStatus[id]==1){
theMove=document.getElementById(id);
theMove.setAttribute("display", "inline");
setTimeout('showHidden2('+id+')',500);
}else{
theMove=document.getElementById(id);
theMove.setAttribute("display", "inline");
}
}
function showHidden2(id){
if(toolStatus[id]==1){
theMove=document.getElementById(id);
theMove.setAttribute("display", "none");
setTimeout('showHidden1('+id+')',500);
}else{
theMove=document.getElementById(id);
theMove.setAttribute("display", "inline");
}
}
]]>
</script>
<g id="plat" onmousedown="startDraw()" onmousemove="modifyDraw()" onmouseup="endDraw()">
<rect id="backRect" x="0" y="60" width="720" height="450" fill="white"
stroke="gray" stroke-width="1"/>
</g>
<g id="saveFlie" onclick="saveFile()">
<rect x="498" y="527" width="45" height="25" stroke="black" stroke-width="1" fill="white"/>
<text x="500" y="545" style="stroke:#83C75D;font-size:20">Save</text>
</g>
<g id="newFie" onclick="newFile()">
<rect x="578" y="527" width="45" height="25" stroke="black" stroke-width="1" fill="white"/>
<text x="584" y="545" style="stroke:#83C75D;font-size:20"> New</text>
</g>
<g id="openFie" onclick="openFile()">
<rect x="658" y="527" width="45" height="25" stroke="black" stroke-width="1" fill="none"/>
<text x="662" y="545" style="stroke:#83C75D;font-size:20"> Open</text>
</g>
<text id="SD" fill="#FFFFFF" stroke="black" x="1" y="40">show code</text>
<polyline id="0" points="40,546 50,563 42,557 38,566 40,546"
stroke="#426EB4" fill="blue" onclick="changeStatus('move')"/>
<rect id="1" x="70" y="544.5" width="25" height="20" stroke="#426EB4"
fill="blue" onclick="changeStatus('rect')"/>
<circle id="2" cx="130" cy="555.5" r="12" stroke="#426EB4"
fill="blue" onclick="changeStatus('circle')"/>
<polyline id="3" points="183,559 190,543 194,546 187,562 182.5,565.5 183,559 187,562"
stroke="#555555" fill="blue" onclick="changeStatus('line')"/>
<image id="4" x="220" y="535" width="40" height="40"
xlink:href="12.jpg" onclick="changeStatus('switch')"/>
</svg>
http://www.cnblogs.com/mydriverc/archive/2008/01/21/1047563.html
<?xml version="1.0" encoding="iso-8859-1"?>
<svg id="svg" viewBox="0 0 1006 616">
<script type="text/javascript">
<![CDATA[
//编辑 删除
//----------------draw circle---------------------
var xCenter;
var yCenter;
var rCircle;
var circleFlag=0;
var codeCircle;
var sd=document.getElementById("SD");
function drawCircle(){
var newCircle=document.createElement("circle");
xCenter=evt.getClientX();
yCenter=evt.getClientY();
newCircle.setAttribute("cx",xCenter);
newCircle.setAttribute("cy",yCenter);
newCircle.setAttribute("r",0);
newCircle.setAttribute("stroke","red");
newCircle.setAttribute("stroke-width","1");
newCircle.setAttribute("fill","blue");
var plat=document.getElementById("plat");
plat.appendChild(newCircle);
circleFlag=1
}
function modifyCircle(){
if(circleFlag==1){
var plat=document.getElementById("plat");
var theCircle=plat.lastChild;
var screenX =evt.getClientX();
var screenY =evt.getClientY();
x=screenX-xCenter;
y=screenY-yCenter;
rCircle= parseInt(Math.sqrt(x*x+y*y));
theCircle.setAttribute("r",rCircle);
}
}
function endCircle(){
//codeCircle="<circle cx=""+xCenter+"" cy=""+yCenter+"" r=""+rCircle+"" stroke="red" stroke-width="1"
fill="blue" />";
//codeAll=codeAll+codeCircle;
circleFlag=0;
var plat=document.getElementById("plat");
theCircle=plat.lastChild;
plat.appendChild(theCircle);
sd.firstChild.setData(codeCircle);
}
//-----------------draw rect----------------------
var xRectStart;
var yRectStart;
var rectFlag=0;
var codeRect;
var widthRect;
var heightRect;
var sd=document.getElementById("SD");
function drawRect(){
var newRect=document.createElement("rect");
xRectStart=evt.getClientX();
yRectStart=evt.getClientY();
newRect.setAttribute("x",xRectStart);
newRect.setAttribute("y",yRectStart);
newRect.setAttribute("width",0);
newRect.setAttribute("height",0);
newRect.setAttribute("stroke","red");
newRect.setAttribute("stroke-width","1");
newRect.setAttribute("fill","blue");
var plat=document.getElementById("plat");
plat.appendChild(newRect);
rectFlag=1
}
function modifyRect(){
if(rectFlag==1){
var plat=document.getElementById("plat");
var theCircle=plat.lastChild;
var screenX =evt.getClientX();
var screenY =evt.getClientY();
widthRect=screenX-xRectStart;
heightRect=screenY-yRectStart;
theCircle.setAttribute("width",widthRect);
theCircle.setAttribute("height",heightRect);
}
}
function endRect(){
//codeRect="<rect x=""+xRectStart+"" y=""+yRectStart+"" width=""+widthRect+"" height=""+heightRect+""
stroke="red" stroke-width="1" fill="blue" />";
//codeAll=codeAll+codeRect;
rectFlag=0;
var plat=document.getElementById("plat");
theRect=plat.lastChild;
plat.appendChild(theRect);
sd.firstChild.setData(codeRect);
}
//---------------------draw with Image---------
var xImageScreen;
var yImageScreen;
var plat;
var switchScr="12.jpg";
var imageFlag;
var codeImage;
var sd=document.getElementById("SD");
function startImage(){
plat=document.getElementById("plat");
var newImg=document.createElement("image");
xImageScreen=evt.getClientX();
yImageScreen=evt.getClientY();
newImg.setAttribute("x",xImageScreen);
newImg.setAttribute("y",yImageScreen);
newImg.setAttribute("width","60");
newImg.setAttribute("height","60");
newImg.setAttributeNS("http://www.w3.org/2000/xlink/namespace/","xlink:href",switchScr);
plat.appendChild(newImg);
imageFlag=true;
}
function modifyImage(){
if(imageFlag==true){
theImg=plat.lastChild;
xImageScreen=evt.getClientX();
yImageScreen=evt.getClientY();
theImg.setAttribute("x",xImageScreen);
theImg.setAttribute("y",yImageScreen);
}
}
function endImage(){
//codeImage="<image x=""+xImageScreen+"" y=""+yImageScreen+"" width="60" height="60"
xlink:href=""+switchScr+""/>";
//codeAll=codeAll+codeImage;
theImg=plat.lastChild;
plat.appendChild(theImg);
imageFlag=false;
sd.firstChild.setData(codeImage);
}
//---------------------drawLine()----------------------
var xLineEnd=0;
var yLineEnd=60;
var xLineStart;
var yLineStart;
var lineFlag=false;
var codeLine;
var sd=document.getElementById("SD");
function drawLine(){
var newLine=document.createElement("line");
xLineStart=evt.getClientX();
yLineStart=evt.getClientY();
newLine.setAttribute("x1",xLineStart);
newLine.setAttribute("y1",yLineStart);
newLine.setAttribute("x2",xLineEnd);
newLine.setAttribute("y2",yLineEnd);
newLine.setAttribute("stroke","red");
newLine.setAttribute("stroke-width","2");
var plat=document.getElementById("plat");
plat.appendChild(newLine);
lineFlag=true;
}
function modifyLine(){
if(lineFlag==true){
var plat=document.getElementById("plat");
var theLine=plat.lastChild;
xLineEnd =evt.getClientX();
yLineEnd =evt.getClientY();
theLine.setAttribute("x2",xLineEnd);
theLine.setAttribute("y2",yLineEnd);
}
}
function endLine(){
// codeLine="<line x1=""+xLineStart+"" y1=""+yLineStart+"" x2=""+xLineEnd+"" y2=""+yLineEnd+""
stroke="red" stroke-width="2" />";
// codeAll=codeAll+codeLine;
lineFlag=false;
var plat=document.getElementById("plat");
theLine=plat.lastChild;
plat.appendChild(theLine);
xLineEnd=0;
yLineEnd=60;
sd.firstChild.setData(codeLine);
}
//------------------drag images-------------------
var targetMaxtrix;
var dragTarget;
var dragStartX;
var dragStartY;
var dragFlag=false;
//var backRect=document.getElementById("backRect");
var dragID;
//var hasTransform;
function startDrag(){
dragTarget=evt.target;
dragID=dragTarget.getAttribute("id");
if(dragID!="backRect"){
//dragID=dragTarget.getAttribute("id");
dragStartX=evt.getClientX();
dragStartY=evt.getClientY();
targetMaxtrix=dragTarget.getCTM();
dragFlag=true;
}
}
function modifyDrag(){
if(dragFlag){
dragModifyX=evt.getClientX();
dragModifyY=evt.getClientY();
distanceX=dragModifyX-dragStartX;
distanceY=dragModifyY-dragStartY;
newTranX=targetMaxtrix.e+distanceX;
newTranY=targetMaxtrix.f+distanceY;
dragTarget.setAttributeNS(null, 'transform', 'translate(' + newTranX + ',' + newTranY + ')');
}
}
function endDrag(){
if(dragFlag){dragTarget.parentNode.appendChild(dragTarget);}
dragFlag=false;
}
//---------------------common function---
function getActiveId(){
var id=0;
for(i=0;i<toolStatus.length;i++){
if(toolStatus[i]==1){
id=i;
break;
}
}
return id;
}
function newFile(){
alert("0");
var p=document.getElementById("plat");
var l=p.childNodes.length;
while(l!=1){
p.removeChild(p.lastChild);
l=p.childNodes.length;
}
codeAll="<?xml version="1.0" encoding="utf-8"?> <svg width="100%" height="100%"
xmlns:xlink="http://www.w3.org/1999/xlink">";
}
//-#############################--operate files-----############################
function saveFile(){
var codeContent="";
//codeAll=codeAll+codeEnd
//-----------saveObject--------------
p=evt.target.ownerDocument.getElementById("plat");
nodeList=p.childNodes;
//------------------learn new knowledge printNode(node)----------------------
for(i=0;i<nodeList.length;i++){
codeContent=codeContent+printNode(nodeList.item(i))+" ";
}
alert(codeContent);
codeAll=codeAll+codeContent;
codeAll=codeAll+codeEnd;
//---------save file --------
var fso, f1;
fso = new ActiveXObject("Scripting.FileSystemObject");
f1 = fso.CreateTextFile(fileName, true);
f1.WriteLine(codeAll);
f1.Close();
alert("the location of the file : "+fileName);
//--------------------
//codeAll=codeAll.substring(0,codeAll.length-6);
codeAll="<?xml version="1.0" encoding="utf-8"?> <svg width="100%" height="100%"
xmlns:xlink="http://www.w3.org/1999/xlink">";
}
//---------------open file---------------------
function openFile(){
xmlDoc = getURL(fileName,fn)
}
function fn(xmlDoc)
{
alert("the location of the opened file: "+fileName);
var x = parseXML(xmlDoc.content,document)
openFilePlat=document.getElementById("plat");
var nodeList=x.getChildNodes();
var nodeListInner=nodeList.item(0).getChildNodes();
removeAllChild();//clear all the Elements in <g>
for(i=0;i<nodeListInner.length;i++){
if(nodeListInner.item(i).nodeType==1){
openFilePlat.appendChild(nodeListInner.item(i));
}
}
}
function removeAllChild(){
var platRemoveAll=document.getElementById("plat");
var removeAllLength=platRemoveAll.childNodes.length;
while(removeAllLength!=0){
platRemoveAll.removeChild(platRemoveAll.lastChild);
removeAllLength=platRemoveAll.childNodes.length;
}
}
//--#############################common vars########################
//-----------file vars-----------------------
var codeAll="<?xml version="1.0" encoding="utf-8"?> <svg width="100%" height="100%"
xmlns:xlink="http://www.w3.org/1999/xlink">";
var codeEnd="</svg>";
var fileName="./svgFile/test.svg";
//-------------------mainDraw-----------------
function startDraw(){
id=getActiveId();
switch(id){
case 0 :{startDrag();break;}
case 1 :{ drawRect();break;}
case 2 :{ drawCircle();break;}
case 3 :{ drawLine();break;}
case 4 :{ startImage();break;}
}
}
function modifyDraw(){
id=getActiveId();
switch(id){
case 0 :{modifyDrag();break;}
case 1 :{ modifyRect();break;}
case 2 :{ modifyCircle();break;}
case 3 :{ modifyLine();break;}
case 4 :{ modifyImage();break;}
}
}
function endDraw(){
id=getActiveId();
switch(id){
case 0 :{endDrag();break;}
case 1 :{ endRect();break;}
case 2 :{ endCircle();break;}
case 3 :{ endLine();break;}
case 4 :{ endImage();break;}
}
}
//---------------------------------------
//-------------------------changStatus And hiddenTool----------
var toolStatus=new Array(1,0,0,0,0);
var toolName=new Array('move','rect','circle','line','switch');
function changeStatus(name){
var id=0;
for(i=0;i<toolName.length;i++){
if(name==toolName[i]){
id=i;
break;
}
}
for(i=0;i<toolStatus.length;i++){
if(id==i){
toolStatus[i]=1;
}else{
toolStatus[i]=0;
}
}
showHidden1(id);
}
function showHidden1(id){
if(toolStatus[id]==1){
theMove=document.getElementById(id);
theMove.setAttribute("display", "inline");
setTimeout('showHidden2('+id+')',500);
}else{
theMove=document.getElementById(id);
theMove.setAttribute("display", "inline");
}
}
function showHidden2(id){
if(toolStatus[id]==1){
theMove=document.getElementById(id);
theMove.setAttribute("display", "none");
setTimeout('showHidden1('+id+')',500);
}else{
theMove=document.getElementById(id);
theMove.setAttribute("display", "inline");
}
}
]]>
</script>
<g id="plat" onmousedown="startDraw()" onmousemove="modifyDraw()" onmouseup="endDraw()">
<rect id="backRect" x="0" y="60" width="720" height="450" fill="white"
stroke="gray" stroke-width="1"/>
</g>
<g id="saveFlie" onclick="saveFile()">
<rect x="498" y="527" width="45" height="25" stroke="black" stroke-width="1" fill="white"/>
<text x="500" y="545" style="stroke:#83C75D;font-size:20">Save</text>
</g>
<g id="newFie" onclick="newFile()">
<rect x="578" y="527" width="45" height="25" stroke="black" stroke-width="1" fill="white"/>
<text x="584" y="545" style="stroke:#83C75D;font-size:20"> New</text>
</g>
<g id="openFie" onclick="openFile()">
<rect x="658" y="527" width="45" height="25" stroke="black" stroke-width="1" fill="none"/>
<text x="662" y="545" style="stroke:#83C75D;font-size:20"> Open</text>
</g>
<text id="SD" fill="#FFFFFF" stroke="black" x="1" y="40">show code</text>
<polyline id="0" points="40,546 50,563 42,557 38,566 40,546"
stroke="#426EB4" fill="blue" onclick="changeStatus('move')"/>
<rect id="1" x="70" y="544.5" width="25" height="20" stroke="#426EB4"
fill="blue" onclick="changeStatus('rect')"/>
<circle id="2" cx="130" cy="555.5" r="12" stroke="#426EB4"
fill="blue" onclick="changeStatus('circle')"/>
<polyline id="3" points="183,559 190,543 194,546 187,562 182.5,565.5 183,559 187,562"
stroke="#555555" fill="blue" onclick="changeStatus('line')"/>
<image id="4" x="220" y="535" width="40" height="40"
xlink:href="12.jpg" onclick="changeStatus('switch')"/>
</svg>
发表评论
-
使用脚本动态操作 SVG 文档
2012-08-20 23:25 748http://www.ibm.com/developerwor ... -
SVG脚本编程的一些技巧 .
2012-08-20 23:24 861http://blog.csdn.net/mtfsoft/ar ... -
有鼠标位置获取元素
2012-12-23 23:36 648document.elementFromPoint(x,y) ... -
getCTM
2012-08-19 17:22 761<svg xmlns="http://www. ... -
Svg事件响应:获取鼠标即时屏幕坐标
2012-08-19 17:04 4410http://ribbonchen.blog.163.com/ ... -
svg_example
2012-04-26 00:54 817http://srufaculty.sru.edu/david ... -
textPath element | SVGTextPathElement object
2012-02-13 22:51 909http://msdn.microsoft.com/ZH-CN ... -
path element | SVGPathElement object
2012-02-13 22:49 1297http://msdn.microsoft.com/ZH-CN ... -
svg text参考
2012-02-13 14:20 742http://www.w3.org/TR/SVG11/text ... -
How to Convert a SVG File to PDF Format
2012-02-05 22:40 1177http://xmlgraphics.apache.org/b ... -
在svg文间画图过程中放大缩小图片后,坐标偏移问题
2012-01-01 16:48 1763http://blog.csdn.net/qingcai200 ... -
创建随内容动态缩放的SVG图形
2012-01-01 16:47 1959创建随内容动态缩放的S ... -
svg矩阵变换
2012-01-01 16:16 953svg矩阵变换 -
svg变换参考
2012-01-01 16:14 942<?xml version="1.0" ... -
svg网站 参考信息
2011-12-31 10:53 947http://blog.csdn.net/xuezhimeng ... -
用CorelDRAW制作SVG手机主题界面图片
2011-10-25 23:57 2312用CorelDRAW制作SVG手机主题界面图片 Ljmsto ... -
动态创建 svg
2011-10-20 17:34 649http://riso.iteye.com/blog/3934 ... -
参考网站收录
2011-10-12 15:22 802PDM中文网运维(http://www.pdmcn.com/b ... -
svg网站
2011-10-08 15:03 1129http://smartblack.iteye.com/blo ... -
svg学习
2011-09-26 00:11 515<?xml version="1.0" ...
相关推荐
本资源包含50个SVG实例,是学习SVG基础知识和实践技巧的宝贵资料。 SVG实例涵盖了以下几个核心知识点: 1. **基本形状绘制**:SVG支持绘制各种基本形状,如矩形(`<rect>`)、圆形(`<circle>`)、椭圆(`...
在SVG实例和教程中,我们可以学习到以下几个核心知识点: 1. **SVG的基本元素**:SVG图形由一系列基本元素构成,如矩形(rect)、圆形(circle)、椭圆(ellipse)、线条(line)、折线(polyline)、多边形...
SVG实例通常包括路径数据、形状元素(如圆形、矩形、多边形)、文本元素、渐变、滤镜和其他复杂效果。 这个"SVG实例 代码下载"压缩包可能包含了一系列用于展示SVG用法和功能的示例代码。"demo1"可能是其中一个...
在本实例中,"SVG实例-可交互式中国地图"可能是通过使用SVG的路径数据、形状元素和事件监听器来实现的。路径数据描述了地图各省份的轮廓,形状元素如`<path>`用于绘制这些轮廓,每个省份可能都有独立的ID或类名以...
SVG(Scalable Vector Graphics)则是一种基于XML的矢量图像格式,可提供高质量、可缩放的图形。将JS与SVG结合使用,我们可以实现丰富的交互式图形界面。下面将详细介绍如何在HTML或JSP页面中使用JavaScript来操作...
个人感觉SVG很有未来 比如可以用于电子地图 股票行情
本文将深入探讨SVG的基本图形元素,包括点、线、圆以及旋转等概念,通过实例来帮助你理解和掌握这些知识点。 首先,我们来看SVG中的基本图形——矩形(RECT)。在`rect.html`这个文件中,你可能会看到如何定义一个...
在这个实例中,我们利用HTML5的SVG元素来制作一个过山车动画演示,这涉及到多个核心概念和技术。 首先,SVG是一种基于XML的矢量图格式,它允许在网页上绘制清晰、可缩放的图形,不受分辨率限制。SVG图像通过数学...
例如,一个简单的SVG实例可能是一个按钮,当鼠标悬停时,按钮颜色会改变;另一个复杂实例可能是一个数据图表,使用SVG路径绘制曲线图,并根据数据实时更新。 学习SVG,不仅需要掌握SVG的基本元素和属性,还需要理解...
"压缩包子文件的文件名称列表"中的TMs-SVG-Package可能包含一系列SVG实例、模板或者工具,你可以解压后查看和学习,这将帮助你更好地理解SVG的实际应用和编程技巧。 总的来说,SVG是现代Web开发中不可或缺的一部分...
**SVG实例:** 下面是一个简单的SVG示例,展示了一个红色的圆形: ```xml <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg width="100%" height="100%...
1. **SVG实例**:压缩包中的"SVG实例"可能包含各种SVG图形的代码示例,比如圆形(circle)、矩形(rect)、线(line)、多边形(polygon)、路径(path)等基本形状的创建,以及组合形状、渐变填充、透明度控制、...
SVG,全称Scalable Vector Graphics,是一种基于XML的矢量图像格式,它允许开发者创建清晰、可缩放且不失真的图形。与像素图(如JPEG或PNG)不同,SVG图像在放大时不会出现模糊,这使得它们在网页设计、移动应用以及...
以下是一个简单的SVG实例代码: ```xml <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg width="100%" height="100%" version="1.1" xmlns=...
SVG(Scalable Vector Graphics)是一种基于XML的矢量图像格式,它允许在网页上创建和展示复杂的图形。在SVG中,JavaScript可以用来对图形进行动态操作,提供丰富的交互体验。在本节中,我们将深入探讨SVG中...
基于HTML5 svg技术创作的圆形加载动画,是一个带数字的进度条,HTML5 SVG技术实例,请在...本SVG实例是生成一个圆形的进度条,并且带有数字百分比显示,演示页面会看到圆形加载条一点一点变化的过程。兼容PC和移动端。
本实例将探讨如何在Android中使用SVG,并通过JavaScript进行数据交互。 首先,Android应用程序需要一个库来解析和显示SVG图形。常见的库有AndroidSVG库,它允许在Android项目中直接加载SVG文件。在项目中引入该库后...
pref火焰图实例svg pref火焰图实例svg pref火焰图实例svg pref火焰图实例svg
这篇文章“SVG 画动态线 实例”可能探讨了如何使用SVG元素和JavaScript来创建动态的线条动画。SVG提供了多种绘制线条的元素,如`<line>`、`<path>`或者`<polyline>`,每种都有其特定的应用场景。 1. `<line>`元素:...