| 2464 | // render loop |
| 2465 | var isFirstRender = true; |
| 2466 | var draw = function() { |
| 2467 | svg.ViewPort.Clear(); |
| 2468 | if (ctx.canvas.parentNode) svg.ViewPort.SetCurrent(ctx.canvas.parentNode.clientWidth, ctx.canvas.parentNode.clientHeight); |
| 2469 | |
| 2470 | if (svg.opts['ignoreDimensions'] != true) { |
| 2471 | // set canvas size |
| 2472 | if (e.style('width').hasValue()) { |
| 2473 | ctx.canvas.width = e.style('width').Length.toPixels('x'); |
| 2474 | ctx.canvas.style.width = ctx.canvas.width + 'px'; |
| 2475 | } |
| 2476 | if (e.style('height').hasValue()) { |
| 2477 | ctx.canvas.height = e.style('height').Length.toPixels('y'); |
| 2478 | ctx.canvas.style.height = ctx.canvas.height + 'px'; |
| 2479 | } |
| 2480 | } |
| 2481 | var cWidth = ctx.canvas.clientWidth || ctx.canvas.width; |
| 2482 | var cHeight = ctx.canvas.clientHeight || ctx.canvas.height; |
| 2483 | svg.ViewPort.SetCurrent(cWidth, cHeight); |
| 2484 | |
| 2485 | if (svg.opts != null && svg.opts['offsetX'] != null) e.attribute('x', true).value = svg.opts['offsetX']; |
| 2486 | if (svg.opts != null && svg.opts['offsetY'] != null) e.attribute('y', true).value = svg.opts['offsetY']; |
| 2487 | if (svg.opts != null && svg.opts['scaleWidth'] != null && svg.opts['scaleHeight'] != null) { |
| 2488 | var xRatio = 1, yRatio = 1; |
| 2489 | if (e.attribute('width').hasValue()) xRatio = e.attribute('width').Length.toPixels('x') / svg.opts['scaleWidth']; |
| 2490 | if (e.attribute('height').hasValue()) yRatio = e.attribute('height').Length.toPixels('y') / svg.opts['scaleHeight']; |
| 2491 | |
| 2492 | e.attribute('width', true).value = svg.opts['scaleWidth']; |
| 2493 | e.attribute('height', true).value = svg.opts['scaleHeight']; |
| 2494 | e.attribute('viewBox', true).value = '0 0 ' + (cWidth * xRatio) + ' ' + (cHeight * yRatio); |
| 2495 | e.attribute('preserveAspectRatio', true).value = 'none'; |
| 2496 | } |
| 2497 | |
| 2498 | // clear and render |
| 2499 | if (svg.opts['ignoreClear'] != true) { |
| 2500 | ctx.clearRect(0, 0, cWidth, cHeight); |
| 2501 | } |
| 2502 | e.render(ctx); |
| 2503 | if (isFirstRender) { |
| 2504 | isFirstRender = false; |
| 2505 | if (svg.opts != null && typeof(svg.opts['renderCallback']) == 'function') svg.opts['renderCallback'](); |
| 2506 | } |
| 2507 | } |
| 2508 | |
| 2509 | var waitingForImages = true; |
| 2510 | if (svg.ImagesLoaded()) { |