jquery svg - Finding the svg image center -


I'm a new SVG. I want to search the STVG Image Center as a program, also display a 'dots' in the middle point.

Here I have made a simple SVG. How to show dots in the center point

  & lt ;! DOCTYPE html & gt; & Lt; Html & gt; & Lt; Body & gt; & Lt; Svg height = "210" width = "400" & gt; & Lt; Path d = "M75 0 L56 105 L225 200 Z" /> & Lt; / Svg & gt; & Lt; / Body & gt; & Lt; / Html & gt;    

You have to ...

  Lt; Script type = "text / javascript" & gt; Var svg = document.query Selector ("SVG"); Var svgns = "http://www.w3.org/2000/svg"; // get the center = var = lll Document.query Selector ("Path"); Var bbox = el.getBBox (); Var center = {x: bbox.left + bbox.width / 2, y: bbox.top + bbox.height / 2}; // dot word dot = document Create a Secret Elementian (SVGN, Circle); Dot.setAttribute ("cx", center.x); Dot.setAttribute ("cy", center.y); Dot.setAttribute ("r", 10); Svg.appendChild (dot); & Lt; / Script & gt;    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -