<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> <script src="snap.svg.js"></script> <script src="snap.svg.zpd.js"></script> <script> window.onload = function () { var s = Snap("#theDiv"); Snap.load("inkscape-drawing2.svg", function(f) { s.append(f); var square = s.select("#rect3336") console.log(square); square.attr({fill:"red"}); console.log(square);
// Determine if the square is a closed shape var squarePathString = square.attr("d"); console.log(squarePathString); var squarePathStringLen = squarePathString.length-1; console.log(squarePathStringLen); var closedCharacter = squarePathString[squarePathStringLen]; console.log(closedCharacter); var isClosed = closedCharacter == 'z' || closedCharacter == 'Z' console.log(isClosed);
// Gets coordinates for a circle some distance along the square (1/4 perimeter increments) var pathLength = Snap.path.getTotalLength(square); console.log(pathLength); var circleIndex = 2; var totalCircleIndex = 4; var circleAlongPathLen = (circleIndex* pathLength/ (isClosed ? totalCircleIndex : totalCircleIndex-1));
// Draw the above circle var point = Snap.path.getPointAtLength(square,circleAlongPathLen); console.log(point); var circle = s.circle(point.x,point.y,50); circle.attr({"fill-opacity": "0"}); circle.attr({stroke:"green"}); circle.attr({"stroke-width": "3"}); console.log(circle);
// drag = false means that the whole screen gets dragged, not // individual objects s.zpd({ zoom: true, pan: true, drag: false, zoomScale: 0.2 }); document.onkeydown = function (e) { console.log(e.keyCode); switch(e.keyCode) { case 84: // 't' console.log("toggle"); s.zpd("toggle"); // can or can not drag break; } };
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Snapsvg, craigu...@gmail.com
P.S. Here is the original file that did work:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title>