2017-12-08 15:39:51   Visit  358

JavaScript 生成 SVG 圆角矩形 PATH

  var length = 12 * text.length; //横向直线长度
     
          var height = 28;//高度
          var r = 10;//圆角半径
          var half_h = height/2;
          var s_half_h = half_h - r;
          var H_all = length + r + r;//横向总长度
          var path = "M0 0 V " + s_half_h + " "; 
          path += "Q 0 "+ half_h+" "+ r +" "+half_h+" H " + (length  + r) + " ";
          path += "Q " + H_all + " " + half_h + " " + H_all + " " + s_half_h +" V -" + s_half_h + " ";
          path += "Q " + H_all + " -" + half_h + " " + (H_all-r) + " -" + half_h +" H " + r + " "; 
          path += "Q 0 -" + half_h + " 0 -" + s_half_h +" V " + 0 + " Z"; 
©2017 Leechg.com