otsdaq_utilities  v2_05_02_indev
three.svg_renderer_footer.js
1 
2 // END of SVGRenderer.js
3 
4  return new THREE.SVGRenderer();
5 
6  }
7 
8  var rndr = null;
9 
10  if (as_is) {
11  if ((typeof doc=='undefined') && (typeof window=='object')) doc = window.document;
12 
13  rndr = Create(doc);
14  } else {
15  var doc_wrapper = {
16  svg_attr: {},
17  svg_style: {},
18  path_attr: {},
19  accPath: "",
20  createElementNS: function(ns,kind) {
21  if (kind == 'path')
22  return {
23  _wrapper: this,
24  setAttribute: function(name, value) {
25  this._wrapper.path_attr[name] = value;
26  }
27  }
28 
29  if (kind != 'svg') {
30  console.error('not supported element for SVGRenderer', kind);
31  return null;
32  }
33 
34  return {
35  _wrapper: this,
36  childNodes: [], // may be accessed - make dummy
37  style: this.svg_style, // for background color
38  setAttribute: function(name, value) {
39  this._wrapper.svg_attr[name] = value;
40  },
41  appendChild: function(node) {
42  this._wrapper.accPath += '<path style="' + this._wrapper.path_attr['style'] + '" d="' + this._wrapper.path_attr['d'] + '"/>';
43  this._wrapper.path_attr = {};
44  },
45  removeChild: function(node) {
46  this.childNodes = [];
47  }
48  };
49  }
50  };
51 
52  rndr = Create(doc_wrapper);
53 
54  rndr.doc_wrapper = doc_wrapper; // use it to get final SVG code
55 
56  rndr.makeOuterHTML = function() {
57 
58  var wrap = this.doc_wrapper;
59 
60  var _textSizeAttr = ' viewBox="' + wrap.svg_attr['viewBox'] + '" width="' + wrap.svg_attr['width'] + '" height="' + wrap.svg_attr['height'] + '"';
61 
62  var _textClearAttr = '';
63 
64  if (wrap.svg_style.backgroundColor) _textClearAttr = ' style="background:' + wrap.svg_style.backgroundColor + '"';
65 
66  return '<svg xmlns="http://www.w3.org/2000/svg"' + _textSizeAttr + _textClearAttr + '>' + wrap.accPath + '</svg>';
67  }
68  }
69 
70  rndr.setPrecision(precision);
71 
72  return rndr;
73 
74 }