Search notes:

SVG example: createElementNS

<!DOCTYPE html>
<html>
<head>
  <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
  <title>createElementNS</title>

  <script type="text/javascript">

    var svgNS = "http://www.w3.org/2000/svg";  

    function main() {

      var svg=document.getElementById('svg');

      var w = parseFloat(svg.getAttributeNS(null, 'width'));
      var h = parseFloat(svg.getAttributeNS(null, 'height'));

      var circle = document.createElementNS(svgNS,"circle");

      circle.setAttributeNS(null,"cx"    , w/2);
      circle.setAttributeNS(null,"cy"    , h/2);
      circle.setAttributeNS(null,"r"     , w > h ? h/2 : w/2);
      circle.setAttributeNS(null,"fill"  ,"#f72");
      circle.setAttributeNS(null,"stroke","none");

      svg.appendChild(circle);

    }

  </script>

</head>
<body onload='main()'>

  <svg id='svg' height="500" width="800" />
  

</body>
</html>
Github repository about-svg, path: /javascript/createElementNS.html

See also

SVG examples

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/design/g...', 1759415442, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/design/graphic/svg/examples/javascript/createElementNS(76): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78