Ver Mensaje Individual
  #2 (permalink)  
Antiguo 03/08/2015, 13:54
marcusaurelio
 
Fecha de Ingreso: enero-2007
Mensajes: 285
Antigüedad: 17 años, 3 meses
Puntos: 21
Respuesta: svg obtener medidas de lineas de un archivo

bueno gente les cuento que avance bastante...

estuve trabajando con Snap.svg

Código:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Documento sin título</title>
<script src="dist/snap.svg-min.js"></script>
<script>
        window.onload = function () {
			var s = Snap("#svg");
			
			Snap.load('cuadro.svg', function (response) {
			
				
				s.append(response);
				
				document.getElementById('txt').value=s.toString();
				path= s.selectAll('path');
				polig= s.selectAll('polygon');
				poliline= s.selectAll('polyline');
				rect= s.selectAll('rect');
				circle= s.selectAll('circle');
				line= s.selectAll('line');
				
				path.forEach( function( myPath ) {
					
					alert('path: '+myPath.getTotalLength())
					
					})
					
				polig.forEach( function( myPath ) {
					
					alert('polyg: '+myPath.getTotalLength())
					
					})
				
				rect.forEach( function( myPath ) {
					
					alert('rect: '+myPath.getBBox()['h'])
					
					})
					
				circle.forEach( function( myPath ) {
					
					alert('circle: '+myPath.getBBox()['r1'])
					
					})
					
				line.forEach( function( myPath ) {
					
					alert('line: '+myPath.getPointAtLength()['angle'])
					
					})
					
				poliline.forEach( function( myPath ) {
					
					alert('poliline: '+myPath.getTotalLength())
					
					})
				
				//s.select('g').select('path').getTotalLength()
			});
			
			
			
	
			
		}
		</script>
</head>

<body>
<div id="svg"></div>

<textarea name="txt" cols="" rows="50" style="width:100%" id="txt"></textarea>

</body>
</html>
con el cual pude obtrener varios datos mas. y separarlos.. pero estoy con problemas con los poligonos, las polilineas y las lineas...

sigo dandole vueltas a la cosa.. cualquier ayuda es bienvenida...