| 90 | } |
| 91 | |
| 92 | function build() { |
| 93 | var svg = { }; |
| 94 | |
| 95 | svg.FRAMERATE = 30; |
| 96 | svg.MAX_VIRTUAL_PIXELS = 30000; |
| 97 | |
| 98 | // globals |
| 99 | svg.init = function(ctx) { |
| 100 | svg.Definitions = {}; |
| 101 | svg.Styles = {}; |
| 102 | svg.Animations = []; |
| 103 | svg.Images = []; |
| 104 | svg.ctx = ctx; |
| 105 | svg.ViewPort = new (function () { |
| 106 | this.viewPorts = []; |
| 107 | this.Clear = function() { this.viewPorts = []; } |
| 108 | this.SetCurrent = function(width, height) { this.viewPorts.push({ width: width, height: height }); } |
| 109 | this.RemoveCurrent = function() { this.viewPorts.pop(); } |
| 110 | this.Current = function() { return this.viewPorts[this.viewPorts.length - 1]; } |
| 111 | this.width = function() { return this.Current().width; } |
| 112 | this.height = function() { return this.Current().height; } |
| 113 | this.ComputeSize = function(d) { |
| 114 | if (d != null && typeof(d) == 'number') return d; |
| 115 | if (d == 'x') return this.width(); |
| 116 | if (d == 'y') return this.height(); |
| 117 | return Math.sqrt(Math.pow(this.width(), 2) + Math.pow(this.height(), 2)) / Math.sqrt(2); |
| 118 | } |
| 119 | }); |
| 120 | } |
| 121 | svg.init(); |
| 122 | |
| 123 | // images loaded |
| 124 | svg.ImagesLoaded = function() { |
| 125 | for (var i=0; i<svg.Images.length; i++) { |
| 126 | if (!svg.Images[i].loaded) return false; |
| 127 | } |
| 128 | return true; |
| 129 | } |
| 130 | |
| 131 | // trim |
| 132 | svg.trim = function(s) { return s.replace(/^\s+|\s+$/g, ''); } |
| 133 | |
| 134 | // compress spaces |
| 135 | svg.compressSpaces = function(s) { return s.replace(/[\s\r\t\n]+/gm,' '); } |
| 136 | |
| 137 | // ajax |
| 138 | svg.ajax = function(url) { |
| 139 | var AJAX; |
| 140 | if(window.XMLHttpRequest){AJAX=new XMLHttpRequest();} |
| 141 | else{AJAX=new ActiveXObject('Microsoft.XMLHTTP');} |
| 142 | if(AJAX){ |
| 143 | AJAX.open('GET',url,false); |
| 144 | AJAX.send(null); |
| 145 | return AJAX.responseText; |
| 146 | } |
| 147 | return null; |
| 148 | } |
| 149 | |