Advertisement
Guest User

Updates to code

a guest
Mar 27th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function Paper(w, h) {
  2.     var res,
  3.         desc,
  4.         defs,
  5.         proto = Paper.prototype;
  6.     if (w && w.tagName == "svg") {
  7.         if (w.snap in hub) {
  8.             return hub[w.snap];
  9.         }
  10.         var doc = w.ownerDocument;
  11.         res = new Element(w);
  12.         desc = w.getElementsByTagName("desc")[0];
  13.         defs = w.getElementsByTagName("defs")[0];
  14.         /*
  15.         if (!desc) {
  16.             desc = $("desc");
  17.             desc.appendChild(doc.createTextNode("Created with Snap"));
  18.             res.node.appendChild(desc);
  19.         }
  20.         if (!defs) {
  21.             defs = $("defs");
  22.             res.node.appendChild(defs);
  23.         }
  24.         */
  25.         res.defs = defs;
  26.         for (var key in proto) if (proto[has](key)) {
  27.             res[key] = proto[key];
  28.         }
  29.         res.paper = res.root = res;
  30.     } else {
  31.         res = make("svg", glob.doc.body);
  32.         $(res.node, {
  33.             height: h,
  34.             version: 1.1,
  35.             width: w,
  36.             xmlns: xmlns
  37.         });
  38.     }
  39.     return res;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement