aw-highstock_rails 7.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +22 -0
- data/LICENSE.txt +21 -0
- data/README.md +53 -0
- data/Rakefile +10 -0
- data/aw-highstock_rails.gemspec +28 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/aw/highstock_rails.rb +9 -0
- data/lib/aw/highstock_rails/version.rb +5 -0
- data/vendor/assets/javascripts/highstock/css/annotations/popup.css +229 -0
- data/vendor/assets/javascripts/highstock/css/annotations/popup.scss +235 -0
- data/vendor/assets/javascripts/highstock/css/highcharts.css +890 -0
- data/vendor/assets/javascripts/highstock/css/highcharts.scss +788 -0
- data/vendor/assets/javascripts/highstock/css/stocktools/gui.css +268 -0
- data/vendor/assets/javascripts/highstock/css/stocktools/gui.scss +270 -0
- data/vendor/assets/javascripts/highstock/css/themes/dark-unica.css +951 -0
- data/vendor/assets/javascripts/highstock/css/themes/dark-unica.scss +122 -0
- data/vendor/assets/javascripts/highstock/css/themes/grid-light.css +904 -0
- data/vendor/assets/javascripts/highstock/css/themes/grid-light.scss +33 -0
- data/vendor/assets/javascripts/highstock/css/themes/sand-signika.css +920 -0
- data/vendor/assets/javascripts/highstock/css/themes/sand-signika.scss +74 -0
- data/vendor/assets/javascripts/highstock/es-modules/annotations/ControlPoint.js +130 -0
- data/vendor/assets/javascripts/highstock/es-modules/annotations/MockPoint.js +415 -0
- data/vendor/assets/javascripts/highstock/es-modules/annotations/annotations.src.js +1231 -0
- data/vendor/assets/javascripts/highstock/es-modules/annotations/controllable/ControllableCircle.js +92 -0
- data/vendor/assets/javascripts/highstock/es-modules/annotations/controllable/ControllableImage.js +101 -0
- data/vendor/assets/javascripts/highstock/es-modules/annotations/controllable/ControllableLabel.js +452 -0
- data/vendor/assets/javascripts/highstock/es-modules/annotations/controllable/ControllablePath.js +175 -0
- data/vendor/assets/javascripts/highstock/es-modules/annotations/controllable/ControllableRect.js +93 -0
- data/vendor/assets/javascripts/highstock/es-modules/annotations/controllable/controllableMixin.js +411 -0
- data/vendor/assets/javascripts/highstock/es-modules/annotations/controllable/markerMixin.js +214 -0
- data/vendor/assets/javascripts/highstock/es-modules/annotations/eventEmitterMixin.js +271 -0
- data/vendor/assets/javascripts/highstock/es-modules/annotations/navigationBindings.js +1283 -0
- data/vendor/assets/javascripts/highstock/es-modules/annotations/popup.js +1069 -0
- data/vendor/assets/javascripts/highstock/es-modules/annotations/types/CrookedLine.js +191 -0
- data/vendor/assets/javascripts/highstock/es-modules/annotations/types/ElliottWave.js +76 -0
- data/vendor/assets/javascripts/highstock/es-modules/annotations/types/Fibonacci.js +247 -0
- data/vendor/assets/javascripts/highstock/es-modules/annotations/types/InfinityLine.js +185 -0
- data/vendor/assets/javascripts/highstock/es-modules/annotations/types/Measure.js +928 -0
- data/vendor/assets/javascripts/highstock/es-modules/annotations/types/Pitchfork.js +203 -0
- data/vendor/assets/javascripts/highstock/es-modules/annotations/types/Tunnel.js +242 -0
- data/vendor/assets/javascripts/highstock/es-modules/annotations/types/VerticalLine.js +157 -0
- data/vendor/assets/javascripts/highstock/es-modules/error-messages.js +128 -0
- data/vendor/assets/javascripts/highstock/es-modules/error.js +1 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/acceleration-bands.src.js +199 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/accumulation-distribution.src.js +129 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/ao.src.js +206 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/apo.src.js +148 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/aroon-oscillator.src.js +128 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/aroon.src.js +173 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/atr.src.js +151 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/bollinger-bands.src.js +209 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/cci.src.js +131 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/chaikin.src.js +167 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/cmf.src.js +246 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/dema.src.js +191 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/dpo.src.js +138 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/ema.src.js +166 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/ichimoku-kinko-hyo.src.js +850 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/indicators.src.js +425 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/keltner-channels.src.js +193 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/macd.src.js +417 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/mfi.src.js +198 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/momentum.src.js +119 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/natr.src.js +74 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/pivot-points.src.js +360 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/ppo.src.js +152 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/price-channel.src.js +149 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/price-envelopes.src.js +251 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/psar.src.js +307 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/regressions.src.js +427 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/roc.src.js +149 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/rsi.src.js +163 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/stochastic.src.js +193 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/supertrend.src.js +544 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/tema.src.js +247 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/trix.src.js +96 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/volume-by-price.src.js +671 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/vwap.src.js +189 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/williams-r.src.js +128 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/wma.src.js +146 -0
- data/vendor/assets/javascripts/highstock/es-modules/indicators/zigzag.src.js +221 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/highcharts-3d.src.js +17 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/highcharts-more.src.js +22 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/highstock.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/acceleration-bands.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/accumulation-distribution.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/ao.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/apo.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/aroon-oscillator.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/aroon.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/atr.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/bollinger-bands.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/cci.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/chaikin.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/cmf.src.js +10 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/dema.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/dpo.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/ema.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/ichimoku-kinko-hyo.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/indicators-all.src.js +49 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/indicators.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/keltner-channels.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/macd.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/mfi.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/momentum.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/natr.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/pivot-points.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/ppo.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/price-channel.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/price-envelopes.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/psar.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/regressions.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/roc.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/rsi.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/stochastic.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/supertrend.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/tema.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/trix.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/volume-by-price.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/vwap.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/williams-r.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/wma.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/zigzag.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/accessibility.src.js +13 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/annotations-advanced.src.js +20 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/annotations.src.js +12 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/arrow-symbols.src.js +10 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/boost-canvas.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/boost.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/bullet.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/current-date-indicator.src.js +10 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/cylinder.src.js +10 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/data.src.js +10 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/datagrouping.src.js +12 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/debugger.src.js +13 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/dependency-wheel.src.js +10 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/drag-panes.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/draggable-points.src.js +9 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/drilldown.src.js +10 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/export-data.src.js +10 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/exporting.src.js +10 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/full-screen.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/funnel.src.js +10 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/grid-axis.src.js +10 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/heatmap.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/histogram-bellcurve.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/item-series.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/networkgraph.src.js +10 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/no-data-to-display.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/offline-exporting.src.js +10 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/oldie-polyfills.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/oldie.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/overlapping-datalabels.src.js +9 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/parallel-coordinates.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/pareto.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/pathfinder.src.js +10 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/pattern-fill.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/price-indicator.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/sankey.src.js +10 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/series-label.src.js +9 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/solid-gauge.src.js +10 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/sonification.src.js +12 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/static-scale.src.js +10 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/stock-tools.src.js +12 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/stock.src.js +19 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/streamgraph.src.js +10 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/sunburst.src.js +10 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/tilemap.src.js +10 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/timeline.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/treegrid.src.js +10 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/treemap.src.js +10 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/variable-pie.src.js +11 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/variwide.src.js +10 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/vector.src.js +10 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/venn.src.js +10 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/windbarb.src.js +10 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/wordcloud.src.js +10 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/modules/xrange.src.js +10 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/themes/avocado.js +9 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/themes/avocado.src.js +9 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/themes/dark-blue.src.js +9 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/themes/dark-green.src.js +9 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/themes/dark-unica.src.js +9 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/themes/gray.src.js +9 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/themes/grid-light.src.js +9 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/themes/grid.src.js +9 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/themes/sand-signika.src.js +9 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/themes/skies.src.js +9 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/themes/sunset.js +9 -0
- data/vendor/assets/javascripts/highstock/es-modules/masters/themes/sunset.src.js +9 -0
- data/vendor/assets/javascripts/highstock/es-modules/mixins/ajax.js +123 -0
- data/vendor/assets/javascripts/highstock/es-modules/mixins/centered-series.js +116 -0
- data/vendor/assets/javascripts/highstock/es-modules/mixins/derived-series.js +150 -0
- data/vendor/assets/javascripts/highstock/es-modules/mixins/download-url.js +103 -0
- data/vendor/assets/javascripts/highstock/es-modules/mixins/draw-point.js +51 -0
- data/vendor/assets/javascripts/highstock/es-modules/mixins/geometry-circles.js +300 -0
- data/vendor/assets/javascripts/highstock/es-modules/mixins/geometry.js +50 -0
- data/vendor/assets/javascripts/highstock/es-modules/mixins/indicator-required.js +49 -0
- data/vendor/assets/javascripts/highstock/es-modules/mixins/multipe-lines.js +223 -0
- data/vendor/assets/javascripts/highstock/es-modules/mixins/navigation.js +59 -0
- data/vendor/assets/javascripts/highstock/es-modules/mixins/nodes.js +76 -0
- data/vendor/assets/javascripts/highstock/es-modules/mixins/on-series.js +167 -0
- data/vendor/assets/javascripts/highstock/es-modules/mixins/polygon.js +293 -0
- data/vendor/assets/javascripts/highstock/es-modules/mixins/reduce-array.js +53 -0
- data/vendor/assets/javascripts/highstock/es-modules/mixins/tree-series.js +256 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/a11y-i18n.src.js +524 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/annotations-legacy.src.js +1951 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/bellcurve.src.js +173 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/boost-canvas.src.js +732 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/boost.src.js +3730 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/bullet.src.js +361 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/cylinder.src.js +389 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/data.src.js +2417 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/debugger.src.js +109 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/dependency-wheel.src.js +199 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/drag-panes.src.js +624 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/draggable-points.src.js +2625 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/drilldown.src.js +1300 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/export-data.src.js +983 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/exporting.src.js +2149 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/full-screen.src.js +40 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/funnel.src.js +552 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/histogram.src.js +229 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/item-series.src.js +150 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/keyboard-navigation.src.js +1606 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/networkgraph/QuadTree.js +175 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/networkgraph/layouts.js +506 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/networkgraph/networkgraph.src.js +740 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/no-data-to-display.src.js +260 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/offline-exporting.src.js +710 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/oldie-polyfills.src.js +121 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/oldie.src.js +1556 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/overlapping-datalabels.src.js +250 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/parallel-coordinates.src.js +492 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/pareto.src.js +152 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/pattern-fill.src.js +607 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/price-indicator.src.js +149 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/sankey.src.js +809 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/screen-reader.src.js +954 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/series-label.src.js +1042 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/solid-gauge.src.js +486 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/sonification/Earcon.js +184 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/sonification/Instrument.js +582 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/sonification/Timeline.js +702 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/sonification/chartSonify.js +1026 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/sonification/instrumentDefinitions.js +37 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/sonification/musicalFrequencies.js +113 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/sonification/pointSonify.js +385 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/sonification/sonification.js +107 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/sonification/utilities.js +178 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/static-scale.src.js +88 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/stock-tools-bindings.js +1950 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/stock-tools-gui.js +1458 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/streamgraph.src.js +132 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/sunburst.src.js +1041 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/tilemap.src.js +769 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/timeline.src.js +750 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/treemap.src.js +1803 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/variable-pie.src.js +459 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/variwide.src.js +350 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/vector.src.js +354 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/venn.src.js +1192 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/windbarb.src.js +380 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/wordcloud.src.js +1103 -0
- data/vendor/assets/javascripts/highstock/es-modules/modules/xrange.src.js +761 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-3d/Axis.js +669 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-3d/Chart.js +1753 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-3d/Column.js +437 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-3d/Math.js +206 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-3d/Pie.js +207 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-3d/SVGRenderer.js +1002 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-3d/Scatter.js +154 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-3d/Series.js +73 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-3d/VMLRenderer.js +62 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-gantt/ArrowSymbols.js +198 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-gantt/CurrentDateIndicator.js +100 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-gantt/GanttChart.js +140 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-gantt/GanttSeries.js +415 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-gantt/GridAxis.js +961 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-gantt/Pathfinder.js +1298 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-gantt/PathfinderAlgorithms.js +816 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-gantt/Tree.js +158 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-gantt/TreeGrid.js +1003 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-map/ColorAxis.js +1103 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-map/ColorSeriesMixin.js +138 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-map/GeoJSON.js +435 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-map/HeatmapSeries.js +474 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-map/Map.js +477 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-map/MapAxis.js +124 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-map/MapBubbleSeries.js +274 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-map/MapLineSeries.js +143 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-map/MapNavigation.js +357 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-map/MapPointSeries.js +187 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-map/MapPointer.js +132 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-map/MapSeries.js +1294 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-more/AreaRangeSeries.js +725 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-more/AreaSplineRangeSeries.js +98 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-more/BoxPlotSeries.js +617 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-more/BubbleLegend.js +1167 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-more/BubbleSeries.js +661 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-more/ColumnPyramidSeries.js +288 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-more/ColumnRangeSeries.js +278 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-more/ErrorBarSeries.js +172 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-more/GaugeSeries.js +618 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-more/PackedBubbleSeries.js +567 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-more/Pane.js +399 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-more/Polar.js +634 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-more/PolygonSeries.js +151 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-more/RadialAxis.js +685 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts-more/WaterfallSeries.js +765 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts.js +684 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/AreaSeries.js +578 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/AreaSplineSeries.js +122 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/Axis.js +6453 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/BarSeries.js +153 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/CandlestickSeries.js +358 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/Chart.js +2307 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/Color.js +301 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/ColumnSeries.js +1125 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/DataGrouping.js +1115 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/DataLabels.js +1431 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/DateTimeAxis.js +134 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/Dynamics.js +1301 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/FlagsSeries.js +739 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/Globals.js +75 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/Html.js +539 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/Interaction.js +1299 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/Legend.js +1411 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/LogarithmicAxis.js +168 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/MSPointer.js +176 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/Navigator.js +2486 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/OHLCSeries.js +412 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/Options.js +3732 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/OrdinalAxis.js +962 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/PieSeries.js +1328 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/PlotBandSeries.experimental.js +74 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/PlotLineOrBand.js +1061 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/Point.js +681 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/Pointer.js +1332 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/RangeSelector.js +2063 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/Responsive.js +295 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/ScatterSeries.js +278 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/ScrollablePlotArea.js +266 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/Scrollbar.js +1134 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/Series.js +5864 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/SplineSeries.js +267 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/Stacking.js +604 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/StockChart.js +951 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/SvgRenderer.js +5109 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/Tick.js +746 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/Time.js +881 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/Tooltip.js +1318 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/TouchPointer.js +404 -0
- data/vendor/assets/javascripts/highstock/es-modules/parts/Utilities.js +2751 -0
- data/vendor/assets/javascripts/highstock/es-modules/themes/avocado.js +37 -0
- data/vendor/assets/javascripts/highstock/es-modules/themes/dark-blue.js +259 -0
- data/vendor/assets/javascripts/highstock/es-modules/themes/dark-green.js +261 -0
- data/vendor/assets/javascripts/highstock/es-modules/themes/dark-unica.js +220 -0
- data/vendor/assets/javascripts/highstock/es-modules/themes/gray.js +267 -0
- data/vendor/assets/javascripts/highstock/es-modules/themes/grid-light.js +81 -0
- data/vendor/assets/javascripts/highstock/es-modules/themes/grid.js +110 -0
- data/vendor/assets/javascripts/highstock/es-modules/themes/sand-signika.js +111 -0
- data/vendor/assets/javascripts/highstock/es-modules/themes/skies.js +100 -0
- data/vendor/assets/javascripts/highstock/es-modules/themes/sunset.js +36 -0
- data/vendor/assets/javascripts/highstock/highcharts-3d.js +85 -0
- data/vendor/assets/javascripts/highstock/highcharts-3d.js.map +1 -0
- data/vendor/assets/javascripts/highstock/highcharts-more.js +101 -0
- data/vendor/assets/javascripts/highstock/highcharts-more.js.map +1 -0
- data/vendor/assets/javascripts/highstock/highstock.js +583 -0
- data/vendor/assets/javascripts/highstock/highstock.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/acceleration-bands.js +16 -0
- data/vendor/assets/javascripts/highstock/indicators/acceleration-bands.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/acceleration-bands.src.js +448 -0
- data/vendor/assets/javascripts/highstock/indicators/accumulation-distribution.js +12 -0
- data/vendor/assets/javascripts/highstock/indicators/accumulation-distribution.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/accumulation-distribution.src.js +156 -0
- data/vendor/assets/javascripts/highstock/indicators/ao.js +13 -0
- data/vendor/assets/javascripts/highstock/indicators/ao.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/ao.src.js +233 -0
- data/vendor/assets/javascripts/highstock/indicators/apo.js +13 -0
- data/vendor/assets/javascripts/highstock/indicators/apo.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/apo.src.js +223 -0
- data/vendor/assets/javascripts/highstock/indicators/aroon-oscillator.js +15 -0
- data/vendor/assets/javascripts/highstock/indicators/aroon-oscillator.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/aroon-oscillator.src.js +426 -0
- data/vendor/assets/javascripts/highstock/indicators/aroon.js +16 -0
- data/vendor/assets/javascripts/highstock/indicators/aroon.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/aroon.src.js +423 -0
- data/vendor/assets/javascripts/highstock/indicators/atr.js +12 -0
- data/vendor/assets/javascripts/highstock/indicators/atr.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/atr.src.js +178 -0
- data/vendor/assets/javascripts/highstock/indicators/bollinger-bands.js +16 -0
- data/vendor/assets/javascripts/highstock/indicators/bollinger-bands.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/bollinger-bands.src.js +458 -0
- data/vendor/assets/javascripts/highstock/indicators/cci.js +12 -0
- data/vendor/assets/javascripts/highstock/indicators/cci.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/cci.src.js +158 -0
- data/vendor/assets/javascripts/highstock/indicators/chaikin.js +15 -0
- data/vendor/assets/javascripts/highstock/indicators/chaikin.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/chaikin.src.js +370 -0
- data/vendor/assets/javascripts/highstock/indicators/cmf.js +12 -0
- data/vendor/assets/javascripts/highstock/indicators/cmf.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/cmf.src.js +273 -0
- data/vendor/assets/javascripts/highstock/indicators/dema.js +13 -0
- data/vendor/assets/javascripts/highstock/indicators/dema.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/dema.src.js +266 -0
- data/vendor/assets/javascripts/highstock/indicators/dpo.js +12 -0
- data/vendor/assets/javascripts/highstock/indicators/dpo.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/dpo.src.js +166 -0
- data/vendor/assets/javascripts/highstock/indicators/ema.js +12 -0
- data/vendor/assets/javascripts/highstock/indicators/ema.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/ema.src.js +193 -0
- data/vendor/assets/javascripts/highstock/indicators/ichimoku-kinko-hyo.js +22 -0
- data/vendor/assets/javascripts/highstock/indicators/ichimoku-kinko-hyo.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/ichimoku-kinko-hyo.src.js +877 -0
- data/vendor/assets/javascripts/highstock/indicators/indicators-all.js +117 -0
- data/vendor/assets/javascripts/highstock/indicators/indicators-all.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/indicators-all.src.js +9389 -0
- data/vendor/assets/javascripts/highstock/indicators/indicators.js +17 -0
- data/vendor/assets/javascripts/highstock/indicators/indicators.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/indicators.src.js +500 -0
- data/vendor/assets/javascripts/highstock/indicators/keltner-channels.js +16 -0
- data/vendor/assets/javascripts/highstock/indicators/keltner-channels.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/keltner-channels.src.js +442 -0
- data/vendor/assets/javascripts/highstock/indicators/macd.js +18 -0
- data/vendor/assets/javascripts/highstock/indicators/macd.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/macd.src.js +444 -0
- data/vendor/assets/javascripts/highstock/indicators/mfi.js +13 -0
- data/vendor/assets/javascripts/highstock/indicators/mfi.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/mfi.src.js +225 -0
- data/vendor/assets/javascripts/highstock/indicators/momentum.js +12 -0
- data/vendor/assets/javascripts/highstock/indicators/momentum.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/momentum.src.js +146 -0
- data/vendor/assets/javascripts/highstock/indicators/natr.js +12 -0
- data/vendor/assets/javascripts/highstock/indicators/natr.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/natr.src.js +101 -0
- data/vendor/assets/javascripts/highstock/indicators/pivot-points.js +16 -0
- data/vendor/assets/javascripts/highstock/indicators/pivot-points.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/pivot-points.src.js +387 -0
- data/vendor/assets/javascripts/highstock/indicators/ppo.js +13 -0
- data/vendor/assets/javascripts/highstock/indicators/ppo.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/ppo.src.js +227 -0
- data/vendor/assets/javascripts/highstock/indicators/price-channel.js +16 -0
- data/vendor/assets/javascripts/highstock/indicators/price-channel.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/price-channel.src.js +450 -0
- data/vendor/assets/javascripts/highstock/indicators/price-envelopes.js +15 -0
- data/vendor/assets/javascripts/highstock/indicators/price-envelopes.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/price-envelopes.src.js +278 -0
- data/vendor/assets/javascripts/highstock/indicators/psar.js +13 -0
- data/vendor/assets/javascripts/highstock/indicators/psar.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/psar.src.js +334 -0
- data/vendor/assets/javascripts/highstock/indicators/regressions.js +14 -0
- data/vendor/assets/javascripts/highstock/indicators/regressions.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/regressions.src.js +454 -0
- data/vendor/assets/javascripts/highstock/indicators/roc.js +12 -0
- data/vendor/assets/javascripts/highstock/indicators/roc.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/roc.src.js +176 -0
- data/vendor/assets/javascripts/highstock/indicators/rsi.js +12 -0
- data/vendor/assets/javascripts/highstock/indicators/rsi.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/rsi.src.js +190 -0
- data/vendor/assets/javascripts/highstock/indicators/stochastic.js +17 -0
- data/vendor/assets/javascripts/highstock/indicators/stochastic.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/stochastic.src.js +494 -0
- data/vendor/assets/javascripts/highstock/indicators/supertrend.js +17 -0
- data/vendor/assets/javascripts/highstock/indicators/supertrend.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/supertrend.src.js +571 -0
- data/vendor/assets/javascripts/highstock/indicators/tema.js +14 -0
- data/vendor/assets/javascripts/highstock/indicators/tema.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/tema.src.js +322 -0
- data/vendor/assets/javascripts/highstock/indicators/trix.js +12 -0
- data/vendor/assets/javascripts/highstock/indicators/trix.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/trix.src.js +171 -0
- data/vendor/assets/javascripts/highstock/indicators/volume-by-price.js +21 -0
- data/vendor/assets/javascripts/highstock/indicators/volume-by-price.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/volume-by-price.src.js +698 -0
- data/vendor/assets/javascripts/highstock/indicators/vwap.js +12 -0
- data/vendor/assets/javascripts/highstock/indicators/vwap.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/vwap.src.js +216 -0
- data/vendor/assets/javascripts/highstock/indicators/williams-r.js +13 -0
- data/vendor/assets/javascripts/highstock/indicators/williams-r.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/williams-r.src.js +207 -0
- data/vendor/assets/javascripts/highstock/indicators/wma.js +12 -0
- data/vendor/assets/javascripts/highstock/indicators/wma.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/wma.src.js +173 -0
- data/vendor/assets/javascripts/highstock/indicators/zigzag.js +13 -0
- data/vendor/assets/javascripts/highstock/indicators/zigzag.js.map +1 -0
- data/vendor/assets/javascripts/highstock/indicators/zigzag.src.js +248 -0
- data/vendor/assets/javascripts/highstock/lib/canvg.js +130 -0
- data/vendor/assets/javascripts/highstock/lib/canvg.src.js +3073 -0
- data/vendor/assets/javascripts/highstock/lib/jspdf.js +283 -0
- data/vendor/assets/javascripts/highstock/lib/jspdf.src.js +21627 -0
- data/vendor/assets/javascripts/highstock/lib/rgbcolor.js +17 -0
- data/vendor/assets/javascripts/highstock/lib/rgbcolor.src.js +299 -0
- data/vendor/assets/javascripts/highstock/lib/svg2pdf.js +38 -0
- data/vendor/assets/javascripts/highstock/lib/svg2pdf.src.js +4390 -0
- data/vendor/assets/javascripts/highstock/modules/accessibility.js +73 -0
- data/vendor/assets/javascripts/highstock/modules/accessibility.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/accessibility.src.js +3103 -0
- data/vendor/assets/javascripts/highstock/modules/annotations-advanced.js +132 -0
- data/vendor/assets/javascripts/highstock/modules/annotations-advanced.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/annotations-advanced.src.js +8230 -0
- data/vendor/assets/javascripts/highstock/modules/annotations.js +94 -0
- data/vendor/assets/javascripts/highstock/modules/annotations.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/annotations.src.js +6001 -0
- data/vendor/assets/javascripts/highstock/modules/arrow-symbols.js +11 -0
- data/vendor/assets/javascripts/highstock/modules/arrow-symbols.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/arrow-symbols.src.js +225 -0
- data/vendor/assets/javascripts/highstock/modules/boost-canvas.js +23 -0
- data/vendor/assets/javascripts/highstock/modules/boost-canvas.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/boost-canvas.src.js +756 -0
- data/vendor/assets/javascripts/highstock/modules/boost.js +65 -0
- data/vendor/assets/javascripts/highstock/modules/boost.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/boost.src.js +3752 -0
- data/vendor/assets/javascripts/highstock/modules/bullet.js +14 -0
- data/vendor/assets/javascripts/highstock/modules/bullet.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/bullet.src.js +388 -0
- data/vendor/assets/javascripts/highstock/modules/current-date-indicator.js +11 -0
- data/vendor/assets/javascripts/highstock/modules/current-date-indicator.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/current-date-indicator.src.js +127 -0
- data/vendor/assets/javascripts/highstock/modules/cylinder.js +14 -0
- data/vendor/assets/javascripts/highstock/modules/cylinder.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/cylinder.src.js +413 -0
- data/vendor/assets/javascripts/highstock/modules/data.js +37 -0
- data/vendor/assets/javascripts/highstock/modules/data.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/data.src.js +2565 -0
- data/vendor/assets/javascripts/highstock/modules/datagrouping.js +25 -0
- data/vendor/assets/javascripts/highstock/modules/datagrouping.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/datagrouping.src.js +1140 -0
- data/vendor/assets/javascripts/highstock/modules/debugger.js +28 -0
- data/vendor/assets/javascripts/highstock/modules/debugger.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/debugger.src.js +267 -0
- data/vendor/assets/javascripts/highstock/modules/dependency-wheel.js +15 -0
- data/vendor/assets/javascripts/highstock/modules/dependency-wheel.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/dependency-wheel.src.js +301 -0
- data/vendor/assets/javascripts/highstock/modules/drag-panes.js +18 -0
- data/vendor/assets/javascripts/highstock/modules/drag-panes.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/drag-panes.src.js +649 -0
- data/vendor/assets/javascripts/highstock/modules/draggable-points.js +40 -0
- data/vendor/assets/javascripts/highstock/modules/draggable-points.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/draggable-points.src.js +2650 -0
- data/vendor/assets/javascripts/highstock/modules/drilldown.js +29 -0
- data/vendor/assets/javascripts/highstock/modules/drilldown.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/drilldown.src.js +1321 -0
- data/vendor/assets/javascripts/highstock/modules/export-data.js +27 -0
- data/vendor/assets/javascripts/highstock/modules/export-data.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/export-data.src.js +1234 -0
- data/vendor/assets/javascripts/highstock/modules/exporting.js +35 -0
- data/vendor/assets/javascripts/highstock/modules/exporting.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/exporting.src.js +2233 -0
- data/vendor/assets/javascripts/highstock/modules/full-screen.js +11 -0
- data/vendor/assets/javascripts/highstock/modules/full-screen.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/full-screen.src.js +68 -0
- data/vendor/assets/javascripts/highstock/modules/funnel.js +14 -0
- data/vendor/assets/javascripts/highstock/modules/funnel.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/funnel.src.js +576 -0
- data/vendor/assets/javascripts/highstock/modules/grid-axis.js +23 -0
- data/vendor/assets/javascripts/highstock/modules/grid-axis.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/grid-axis.src.js +988 -0
- data/vendor/assets/javascripts/highstock/modules/heatmap.js +28 -0
- data/vendor/assets/javascripts/highstock/modules/heatmap.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/heatmap.src.js +1731 -0
- data/vendor/assets/javascripts/highstock/modules/histogram-bellcurve.js +16 -0
- data/vendor/assets/javascripts/highstock/modules/histogram-bellcurve.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/histogram-bellcurve.src.js +570 -0
- data/vendor/assets/javascripts/highstock/modules/item-series.js +13 -0
- data/vendor/assets/javascripts/highstock/modules/item-series.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/item-series.src.js +176 -0
- data/vendor/assets/javascripts/highstock/modules/networkgraph.js +31 -0
- data/vendor/assets/javascripts/highstock/modules/networkgraph.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/networkgraph.src.js +1348 -0
- data/vendor/assets/javascripts/highstock/modules/no-data-to-display.js +13 -0
- data/vendor/assets/javascripts/highstock/modules/no-data-to-display.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/no-data-to-display.src.js +285 -0
- data/vendor/assets/javascripts/highstock/modules/offline-exporting.js +22 -0
- data/vendor/assets/javascripts/highstock/modules/offline-exporting.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/offline-exporting.src.js +838 -0
- data/vendor/assets/javascripts/highstock/modules/oldie-polyfills.js +13 -0
- data/vendor/assets/javascripts/highstock/modules/oldie-polyfills.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/oldie-polyfills.src.js +150 -0
- data/vendor/assets/javascripts/highstock/modules/oldie.js +35 -0
- data/vendor/assets/javascripts/highstock/modules/oldie.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/oldie.src.js +1582 -0
- data/vendor/assets/javascripts/highstock/modules/overlapping-datalabels.js +9 -0
- data/vendor/assets/javascripts/highstock/modules/overlapping-datalabels.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/overlapping-datalabels.src.js +22 -0
- data/vendor/assets/javascripts/highstock/modules/parallel-coordinates.js +18 -0
- data/vendor/assets/javascripts/highstock/modules/parallel-coordinates.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/parallel-coordinates.src.js +517 -0
- data/vendor/assets/javascripts/highstock/modules/pareto.js +14 -0
- data/vendor/assets/javascripts/highstock/modules/pareto.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/pareto.src.js +327 -0
- data/vendor/assets/javascripts/highstock/modules/pathfinder.js +34 -0
- data/vendor/assets/javascripts/highstock/modules/pathfinder.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/pathfinder.src.js +2336 -0
- data/vendor/assets/javascripts/highstock/modules/pattern-fill.js +21 -0
- data/vendor/assets/javascripts/highstock/modules/pattern-fill.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/pattern-fill.src.js +634 -0
- data/vendor/assets/javascripts/highstock/modules/price-indicator.js +13 -0
- data/vendor/assets/javascripts/highstock/modules/price-indicator.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/price-indicator.src.js +176 -0
- data/vendor/assets/javascripts/highstock/modules/sankey.js +22 -0
- data/vendor/assets/javascripts/highstock/modules/sankey.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/sankey.src.js +911 -0
- data/vendor/assets/javascripts/highstock/modules/series-label.js +23 -0
- data/vendor/assets/javascripts/highstock/modules/series-label.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/series-label.src.js +1065 -0
- data/vendor/assets/javascripts/highstock/modules/solid-gauge.js +15 -0
- data/vendor/assets/javascripts/highstock/modules/solid-gauge.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/solid-gauge.src.js +510 -0
- data/vendor/assets/javascripts/highstock/modules/sonification.js +53 -0
- data/vendor/assets/javascripts/highstock/modules/sonification.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/sonification.src.js +3341 -0
- data/vendor/assets/javascripts/highstock/modules/static-scale.js +12 -0
- data/vendor/assets/javascripts/highstock/modules/static-scale.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/static-scale.src.js +114 -0
- data/vendor/assets/javascripts/highstock/modules/stock-tools.js +65 -0
- data/vendor/assets/javascripts/highstock/modules/stock-tools.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/stock-tools.src.js +3437 -0
- data/vendor/assets/javascripts/highstock/modules/stock.js +151 -0
- data/vendor/assets/javascripts/highstock/modules/stock.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/stock.src.js +10907 -0
- data/vendor/assets/javascripts/highstock/modules/streamgraph.js +10 -0
- data/vendor/assets/javascripts/highstock/modules/streamgraph.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/streamgraph.src.js +158 -0
- data/vendor/assets/javascripts/highstock/modules/sunburst.js +52 -0
- data/vendor/assets/javascripts/highstock/modules/sunburst.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/sunburst.src.js +3174 -0
- data/vendor/assets/javascripts/highstock/modules/tilemap.js +26 -0
- data/vendor/assets/javascripts/highstock/modules/tilemap.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/tilemap.src.js +1402 -0
- data/vendor/assets/javascripts/highstock/modules/timeline.js +23 -0
- data/vendor/assets/javascripts/highstock/modules/timeline.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/timeline.src.js +778 -0
- data/vendor/assets/javascripts/highstock/modules/treegrid.js +50 -0
- data/vendor/assets/javascripts/highstock/modules/treegrid.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/treegrid.src.js +2917 -0
- data/vendor/assets/javascripts/highstock/modules/treemap.js +39 -0
- data/vendor/assets/javascripts/highstock/modules/treemap.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/treemap.src.js +2083 -0
- data/vendor/assets/javascripts/highstock/modules/variable-pie.js +16 -0
- data/vendor/assets/javascripts/highstock/modules/variable-pie.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/variable-pie.src.js +485 -0
- data/vendor/assets/javascripts/highstock/modules/variwide.js +15 -0
- data/vendor/assets/javascripts/highstock/modules/variwide.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/variwide.src.js +376 -0
- data/vendor/assets/javascripts/highstock/modules/vector.js +13 -0
- data/vendor/assets/javascripts/highstock/modules/vector.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/vector.src.js +381 -0
- data/vendor/assets/javascripts/highstock/modules/venn.js +30 -0
- data/vendor/assets/javascripts/highstock/modules/venn.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/venn.src.js +1624 -0
- data/vendor/assets/javascripts/highstock/modules/windbarb.js +17 -0
- data/vendor/assets/javascripts/highstock/modules/windbarb.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/windbarb.src.js +574 -0
- data/vendor/assets/javascripts/highstock/modules/wordcloud.js +25 -0
- data/vendor/assets/javascripts/highstock/modules/wordcloud.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/wordcloud.src.js +1475 -0
- data/vendor/assets/javascripts/highstock/modules/xrange.js +20 -0
- data/vendor/assets/javascripts/highstock/modules/xrange.js.map +1 -0
- data/vendor/assets/javascripts/highstock/modules/xrange.src.js +788 -0
- data/vendor/assets/javascripts/highstock/themes/avocado.js +9 -0
- data/vendor/assets/javascripts/highstock/themes/avocado.js.map +1 -0
- data/vendor/assets/javascripts/highstock/themes/avocado.src.js +63 -0
- data/vendor/assets/javascripts/highstock/themes/dark-blue.js +15 -0
- data/vendor/assets/javascripts/highstock/themes/dark-blue.js.map +1 -0
- data/vendor/assets/javascripts/highstock/themes/dark-blue.src.js +285 -0
- data/vendor/assets/javascripts/highstock/themes/dark-green.js +15 -0
- data/vendor/assets/javascripts/highstock/themes/dark-green.js.map +1 -0
- data/vendor/assets/javascripts/highstock/themes/dark-green.src.js +287 -0
- data/vendor/assets/javascripts/highstock/themes/dark-unica.js +14 -0
- data/vendor/assets/javascripts/highstock/themes/dark-unica.js.map +1 -0
- data/vendor/assets/javascripts/highstock/themes/dark-unica.src.js +246 -0
- data/vendor/assets/javascripts/highstock/themes/gray.js +15 -0
- data/vendor/assets/javascripts/highstock/themes/gray.js.map +1 -0
- data/vendor/assets/javascripts/highstock/themes/gray.src.js +293 -0
- data/vendor/assets/javascripts/highstock/themes/grid-light.js +11 -0
- data/vendor/assets/javascripts/highstock/themes/grid-light.js.map +1 -0
- data/vendor/assets/javascripts/highstock/themes/grid-light.src.js +107 -0
- data/vendor/assets/javascripts/highstock/themes/grid.js +11 -0
- data/vendor/assets/javascripts/highstock/themes/grid.js.map +1 -0
- data/vendor/assets/javascripts/highstock/themes/grid.src.js +136 -0
- data/vendor/assets/javascripts/highstock/themes/sand-signika.js +11 -0
- data/vendor/assets/javascripts/highstock/themes/sand-signika.js.map +1 -0
- data/vendor/assets/javascripts/highstock/themes/sand-signika.src.js +137 -0
- data/vendor/assets/javascripts/highstock/themes/skies.js +11 -0
- data/vendor/assets/javascripts/highstock/themes/skies.js.map +1 -0
- data/vendor/assets/javascripts/highstock/themes/skies.src.js +126 -0
- data/vendor/assets/javascripts/highstock/themes/sunset.js +9 -0
- data/vendor/assets/javascripts/highstock/themes/sunset.js.map +1 -0
- data/vendor/assets/javascripts/highstock/themes/sunset.src.js +62 -0
- metadata +781 -0
@@ -0,0 +1,130 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
canvg.js - Javascript SVG parser and renderer on Canvas
|
4
|
+
MIT Licensed
|
5
|
+
Gabe Lerner (gabelerner@gmail.com)
|
6
|
+
http://code.google.com/p/canvg/
|
7
|
+
|
8
|
+
Requires: rgbcolor.js - http://www.phpied.com/rgb-color-parser-in-javascript/
|
9
|
+
*/
|
10
|
+
(function(x,y){"undefined"!==typeof define&&define.amd?define("canvgModule",["vendor/assets/javascripts/highstock/lib/rgbcolor","stackblur"],y):"undefined"!==typeof module&&module.exports&&(module.exports=y(require("vendor/assets/javascripts/highstock/lib/rgbcolor"),require("stackblur")));x.canvg=y(x.RGBColor,x.stackBlur)})("undefined"!==typeof window?window:this,function(x, y){function A(h){var a=[0,0,0],l=function(c, b){var e=h.match(c);null!=e&&(a[b]+=e.length,h=h.replace(c," "))};h=h.replace(/:not\(([^\)]*)\)/g," $1 ");h=h.replace(/{[^]*/gm," ");l(B,1);l(C,0);l(D,1);l(E,
|
11
|
+
2);l(F,1);l(G,1);h=h.replace(/[\*\s\+>~]/g," ");h=h.replace(/[#\.]/g," ");l(H,2);return a.join("")}function I(h){var a={opts:h,FRAMERATE:30,MAX_VIRTUAL_PIXELS:3E4,log:function(a){}};1==a.opts.log&&"undefined"!=typeof console&&(a.log=function(a){console.log(a)});a.init=function(c){var b=0;a.UniqueId=function(){b++;return"canvg"+b};a.Definitions={};a.Styles={};a.StylesSpecificity={};a.Animations=[];a.Images=[];a.ctx=c;a.ViewPort=new function(){this.viewPorts=[];this.Clear=function(){this.viewPorts=
|
12
|
+
[]};this.SetCurrent=function(a,b){this.viewPorts.push({width:a,height:b})};this.RemoveCurrent=function(){this.viewPorts.pop()};this.Current=function(){return this.viewPorts[this.viewPorts.length-1]};this.width=function(){return this.Current().width};this.height=function(){return this.Current().height};this.ComputeSize=function(a){return null!=a&&"number"==typeof a?a:"x"==a?this.width():"y"==a?this.height():Math.sqrt(Math.pow(this.width(),2)+Math.pow(this.height(),2))/Math.sqrt(2)}}};a.init();a.ImagesLoaded=
|
13
|
+
function(){for(var c=0;c<a.Images.length;c++)if(!a.Images[c].loaded)return!1;return!0};a.trim=function(a){return a.replace(/^\s+|\s+$/g,"")};a.compressSpaces=function(a){return a.replace(/[\s\r\t\n]+/gm," ")};a.ajax=function(a){var b;b=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");b.open("GET",a,!1);b.send(null);return b.responseText};a.parseXml=function(a){if("undefined"!=typeof Windows&&"undefined"!=typeof Windows.Data&&"undefined"!=typeof Windows.Data.Xml){var b=
|
14
|
+
new Windows.Data.Xml.Dom.XmlDocument,e=new Windows.Data.Xml.Dom.XmlLoadSettings;e.prohibitDtd=!1;b.loadXml(a,e);return b}if(window.DOMParser)return(new DOMParser).parseFromString(a,"text/xml");a=a.replace(/<!DOCTYPE svg[^>]*>/,"");b=new ActiveXObject("Microsoft.XMLDOM");b.async="false";b.loadXML(a);return b};a.Property=function(a,b){this.name=a;this.value=b};a.Property.prototype.getValue=function(){return this.value};a.Property.prototype.hasValue=function(){return null!=this.value&&""!==this.value};
|
15
|
+
a.Property.prototype.numValue=function(){if(!this.hasValue())return 0;var a=parseFloat(this.value);(this.value+"").match(/%$/)&&(a/=100);return a};a.Property.prototype.valueOrDefault=function(a){return this.hasValue()?this.value:a};a.Property.prototype.numValueOrDefault=function(a){return this.hasValue()?this.numValue():a};a.Property.prototype.addOpacity=function(c){var b=this.value;if(null!=c.value&&""!=c.value&&"string"==typeof this.value){var e=new x(this.value);e.ok&&(b="rgba("+e.r+", "+e.g+", "+
|
16
|
+
e.b+", "+c.numValue()+")")}return new a.Property(this.name,b)};a.Property.prototype.getDefinition=function(){var c=this.value.match(/#([^\)'"]+)/);c&&(c=c[1]);c||(c=this.value);return a.Definitions[c]};a.Property.prototype.isUrlDefinition=function(){return 0==this.value.indexOf("url(")};a.Property.prototype.getFillStyleDefinition=function(c,b){var e=this.getDefinition();if(null!=e&&e.createGradient)return e.createGradient(a.ctx,c,b);if(null!=e&&e.createPattern){if(e.getHrefAttribute().hasValue()){var d=
|
17
|
+
e.attribute("patternTransform"),e=e.getHrefAttribute().getDefinition();d.hasValue()&&(e.attribute("patternTransform",!0).value=d.value)}return e.createPattern(a.ctx,c)}return null};a.Property.prototype.getDPI=function(a){return 96};a.Property.prototype.getEM=function(c){var b=12,e=new a.Property("fontSize",a.Font.Parse(a.ctx.font).fontSize);e.hasValue()&&(b=e.toPixels(c));return b};a.Property.prototype.getUnits=function(){return(this.value+"").replace(/[0-9\.\-]/g,"")};a.Property.prototype.toPixels=
|
18
|
+
function(c,b){if(!this.hasValue())return 0;var e=this.value+"";if(e.match(/em$/))return this.numValue()*this.getEM(c);if(e.match(/ex$/))return this.numValue()*this.getEM(c)/2;if(e.match(/px$/))return this.numValue();if(e.match(/pt$/))return this.numValue()*this.getDPI(c)*(1/72);if(e.match(/pc$/))return 15*this.numValue();if(e.match(/cm$/))return this.numValue()*this.getDPI(c)/2.54;if(e.match(/mm$/))return this.numValue()*this.getDPI(c)/25.4;if(e.match(/in$/))return this.numValue()*this.getDPI(c);
|
19
|
+
if(e.match(/%$/))return this.numValue()*a.ViewPort.ComputeSize(c);e=this.numValue();return b&&1>e?e*a.ViewPort.ComputeSize(c):e};a.Property.prototype.toMilliseconds=function(){if(!this.hasValue())return 0;var a=this.value+"";if(a.match(/s$/))return 1E3*this.numValue();a.match(/ms$/);return this.numValue()};a.Property.prototype.toRadians=function(){if(!this.hasValue())return 0;var a=this.value+"";return a.match(/deg$/)?this.numValue()*(Math.PI/180):a.match(/grad$/)?this.numValue()*(Math.PI/200):a.match(/rad$/)?
|
20
|
+
this.numValue():this.numValue()*(Math.PI/180)};var l={baseline:"alphabetic","before-edge":"top","text-before-edge":"top",middle:"middle",central:"middle","after-edge":"bottom","text-after-edge":"bottom",ideographic:"ideographic",alphabetic:"alphabetic",hanging:"hanging",mathematical:"alphabetic"};a.Property.prototype.toTextBaseline=function(){return this.hasValue()?l[this.value]:null};a.Font=new function(){this.Styles="normal|italic|oblique|inherit";this.Variants="normal|small-caps|inherit";this.Weights=
|
21
|
+
"normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit";this.CreateFont=function(b,e,d,c,f,g){g=null!=g?this.Parse(g):this.CreateFont("","","","","",a.ctx.font);return{fontFamily:f||g.fontFamily,fontSize:c||g.fontSize,fontStyle:b||g.fontStyle,fontWeight:d||g.fontWeight,fontVariant:e||g.fontVariant,toString:function(){return[this.fontStyle,this.fontVariant,this.fontWeight,this.fontSize,this.fontFamily].join(" ")}}};var c=this;this.Parse=function(b){var e={};b=a.trim(a.compressSpaces(b||
|
22
|
+
"")).split(" ");for(var d=!1,k=!1,f=!1,g=!1,m="",n=0;n<b.length;n++)k||-1==c.Styles.indexOf(b[n])?g||-1==c.Variants.indexOf(b[n])?f||-1==c.Weights.indexOf(b[n])?d?"inherit"!=b[n]&&(m+=b[n]):("inherit"!=b[n]&&(e.fontSize=b[n].split("/")[0]),k=g=f=d=!0):("inherit"!=b[n]&&(e.fontWeight=b[n]),k=g=f=!0):("inherit"!=b[n]&&(e.fontVariant=b[n]),k=g=!0):("inherit"!=b[n]&&(e.fontStyle=b[n]),k=!0);""!=m&&(e.fontFamily=m);return e}};a.ToNumberArray=function(c){c=a.trim(a.compressSpaces((c||"").replace(/,/g," "))).split(" ");
|
23
|
+
for(var b=0;b<c.length;b++)c[b]=parseFloat(c[b]);return c};a.Point=function(a,b){this.x=a;this.y=b};a.Point.prototype.angleTo=function(a){return Math.atan2(a.y-this.y,a.x-this.x)};a.Point.prototype.applyTransform=function(a){var b=this.x*a[1]+this.y*a[3]+a[5];this.x=this.x*a[0]+this.y*a[2]+a[4];this.y=b};a.CreatePoint=function(c){c=a.ToNumberArray(c);return new a.Point(c[0],c[1])};a.CreatePath=function(c){c=a.ToNumberArray(c);for(var b=[],e=0;e<c.length;e+=2)b.push(new a.Point(c[e],c[e+1]));return b};
|
24
|
+
a.BoundingBox=function(a,b,e,d){this.y2=this.x2=this.y1=this.x1=Number.NaN;this.x=function(){return this.x1};this.y=function(){return this.y1};this.width=function(){return this.x2-this.x1};this.height=function(){return this.y2-this.y1};this.addPoint=function(a,b){if(null!=a){if(isNaN(this.x1)||isNaN(this.x2))this.x2=this.x1=a;a<this.x1&&(this.x1=a);a>this.x2&&(this.x2=a)}if(null!=b){if(isNaN(this.y1)||isNaN(this.y2))this.y2=this.y1=b;b<this.y1&&(this.y1=b);b>this.y2&&(this.y2=b)}};this.addX=function(a){this.addPoint(a,
|
25
|
+
null)};this.addY=function(a){this.addPoint(null,a)};this.addBoundingBox=function(a){this.addPoint(a.x1,a.y1);this.addPoint(a.x2,a.y2)};this.addQuadraticCurve=function(a,b,e,d,c,r){e=a+2/3*(e-a);d=b+2/3*(d-b);this.addBezierCurve(a,b,e,e+1/3*(c-a),d,d+1/3*(r-b),c,r)};this.addBezierCurve=function(a,b,e,d,c,r,u,p){var t=[a,b],h=[e,d],q=[c,r],l=[u,p];this.addPoint(t[0],t[1]);this.addPoint(l[0],l[1]);for(i=0;1>=i;i++)a=function(a){return Math.pow(1-a,3)*t[i]+3*Math.pow(1-a,2)*a*h[i]+3*(1-a)*Math.pow(a,
|
26
|
+
2)*q[i]+Math.pow(a,3)*l[i]},b=6*t[i]-12*h[i]+6*q[i],e=-3*t[i]+9*h[i]-9*q[i]+3*l[i],d=3*h[i]-3*t[i],0==e?0!=b&&(b=-d/b,0<b&&1>b&&(0==i&&this.addX(a(b)),1==i&&this.addY(a(b)))):(d=Math.pow(b,2)-4*d*e,0>d||(c=(-b+Math.sqrt(d))/(2*e),0<c&&1>c&&(0==i&&this.addX(a(c)),1==i&&this.addY(a(c))),b=(-b-Math.sqrt(d))/(2*e),0<b&&1>b&&(0==i&&this.addX(a(b)),1==i&&this.addY(a(b)))))};this.isPointInBox=function(a,b){return this.x1<=a&&a<=this.x2&&this.y1<=b&&b<=this.y2};this.addPoint(a,b);this.addPoint(e,d)};a.Transform=
|
27
|
+
function(c){var b=this;this.Type={};this.Type.translate=function(b){this.p=a.CreatePoint(b);this.apply=function(a){a.translate(this.p.x||0,this.p.y||0)};this.unapply=function(a){a.translate(-1*this.p.x||0,-1*this.p.y||0)};this.applyToPoint=function(a){a.applyTransform([1,0,0,1,this.p.x||0,this.p.y||0])}};this.Type.rotate=function(b){b=a.ToNumberArray(b);this.angle=new a.Property("angle",b[0]);this.cx=b[1]||0;this.cy=b[2]||0;this.apply=function(a){a.translate(this.cx,this.cy);a.rotate(this.angle.toRadians());
|
28
|
+
a.translate(-this.cx,-this.cy)};this.unapply=function(a){a.translate(this.cx,this.cy);a.rotate(-1*this.angle.toRadians());a.translate(-this.cx,-this.cy)};this.applyToPoint=function(a){var b=this.angle.toRadians();a.applyTransform([1,0,0,1,this.p.x||0,this.p.y||0]);a.applyTransform([Math.cos(b),Math.sin(b),-Math.sin(b),Math.cos(b),0,0]);a.applyTransform([1,0,0,1,-this.p.x||0,-this.p.y||0])}};this.Type.scale=function(b){this.p=a.CreatePoint(b);this.apply=function(a){a.scale(this.p.x||1,this.p.y||this.p.x||
|
29
|
+
1)};this.unapply=function(a){a.scale(1/this.p.x||1,1/this.p.y||this.p.x||1)};this.applyToPoint=function(a){a.applyTransform([this.p.x||0,0,0,this.p.y||0,0,0])}};this.Type.matrix=function(b){this.m=a.ToNumberArray(b);this.apply=function(a){a.transform(this.m[0],this.m[1],this.m[2],this.m[3],this.m[4],this.m[5])};this.unapply=function(a){var b=this.m[0],e=this.m[2],d=this.m[4],c=this.m[1],f=this.m[3],k=this.m[5],h=1/(b*(1*f-0*k)-e*(1*c-0*k)+d*(0*c-0*f));a.transform(h*(1*f-0*k),h*(0*k-1*c),h*(0*d-1*
|
30
|
+
e),h*(1*b-0*d),h*(e*k-d*f),h*(d*c-b*k))};this.applyToPoint=function(a){a.applyTransform(this.m)}};this.Type.SkewBase=function(e){this.base=b.Type.matrix;this.base(e);this.angle=new a.Property("angle",e)};this.Type.SkewBase.prototype=new this.Type.matrix;this.Type.skewX=function(a){this.base=b.Type.SkewBase;this.base(a);this.m=[1,0,Math.tan(this.angle.toRadians()),1,0,0]};this.Type.skewX.prototype=new this.Type.SkewBase;this.Type.skewY=function(a){this.base=b.Type.SkewBase;this.base(a);this.m=[1,Math.tan(this.angle.toRadians()),
|
31
|
+
0,1,0,0]};this.Type.skewY.prototype=new this.Type.SkewBase;this.transforms=[];this.apply=function(a){for(var b=0;b<this.transforms.length;b++)this.transforms[b].apply(a)};this.unapply=function(a){for(var b=this.transforms.length-1;0<=b;b--)this.transforms[b].unapply(a)};this.applyToPoint=function(a){for(var b=0;b<this.transforms.length;b++)this.transforms[b].applyToPoint(a)};c=a.trim(a.compressSpaces(c)).replace(/\)([a-zA-Z])/g,") $1").replace(/\)(\s?,\s?)/g,") ").split(/\s(?=[a-z])/);for(var e=0;e<
|
32
|
+
c.length;e++){var d=a.trim(c[e].split("(")[0]),k=c[e].split("(")[1].replace(")",""),k=new this.Type[d](k);k.type=d;this.transforms.push(k)}};a.AspectRatio=function(c,b,e,d,k,f,g,m,n,r){b=a.compressSpaces(b);b=b.replace(/^defer\s/,"");var h=b.split(" ")[0]||"xMidYMid";b=b.split(" ")[1]||"meet";var p=e/d,t=k/f,l=Math.min(p,t),q=Math.max(p,t);"meet"==b&&(d*=l,f*=l);"slice"==b&&(d*=q,f*=q);n=new a.Property("refX",n);r=new a.Property("refY",r);n.hasValue()&&r.hasValue()?c.translate(-l*n.toPixels("x"),
|
33
|
+
-l*r.toPixels("y")):(h.match(/^xMid/)&&("meet"==b&&l==t||"slice"==b&&q==t)&&c.translate(e/2-d/2,0),h.match(/YMid$/)&&("meet"==b&&l==p||"slice"==b&&q==p)&&c.translate(0,k/2-f/2),h.match(/^xMax/)&&("meet"==b&&l==t||"slice"==b&&q==t)&&c.translate(e-d,0),h.match(/YMax$/)&&("meet"==b&&l==p||"slice"==b&&q==p)&&c.translate(0,k-f));"none"==h?c.scale(p,t):"meet"==b?c.scale(l,l):"slice"==b&&c.scale(q,q);c.translate(null==g?0:-g,null==m?0:-m)};a.Element={};a.EmptyProperty=new a.Property("EMPTY","");a.Element.ElementBase=
|
34
|
+
function(c){this.attributes={};this.styles={};this.stylesSpecificity={};this.children=[];this.attribute=function(b,e){var d=this.attributes[b];if(null!=d)return d;1==e&&(d=new a.Property(b,""),this.attributes[b]=d);return d||a.EmptyProperty};this.getHrefAttribute=function(){for(var b in this.attributes)if("href"==b||b.match(/:href$/))return this.attributes[b];return a.EmptyProperty};this.style=function(b,e,d){var c=this.styles[b];if(null!=c)return c;var k=this.attribute(b);if(null!=k&&k.hasValue())return this.styles[b]=
|
35
|
+
k;if(1!=d&&(d=this.parent,null!=d&&(d=d.style(b),null!=d&&d.hasValue())))return d;1==e&&(c=new a.Property(b,""),this.styles[b]=c);return c||a.EmptyProperty};this.render=function(a){if("none"!=this.style("display").value&&"hidden"!=this.style("visibility").value){a.save();if(this.style("mask").hasValue()){var b=this.style("mask").getDefinition();null!=b&&b.apply(a,this)}else this.style("filter").hasValue()?(b=this.style("filter").getDefinition(),null!=b&&b.apply(a,this)):(this.setContext(a),this.renderChildren(a),
|
36
|
+
this.clearContext(a));a.restore()}};this.setContext=function(a){};this.clearContext=function(a){};this.renderChildren=function(a){for(var b=0;b<this.children.length;b++)this.children[b].render(a)};this.addChild=function(b,e){var d=b;e&&(d=a.CreateElement(b));d.parent=this;"title"!=d.type&&this.children.push(d)};this.addStylesFromStyleDefinition=function(){for(var b in a.Styles)if("@"!=b[0]&&w(c,b)){var e=a.Styles[b],d=a.StylesSpecificity[b];if(null!=e)for(var k in e){var r=this.stylesSpecificity[k];
|
37
|
+
"undefined"==typeof r&&(r="000");d>r&&(this.styles[k]=e[k],this.stylesSpecificity[k]=d)}}};if(null!=c&&1==c.nodeType){for(var b=0;b<c.attributes.length;b++){var e=c.attributes[b];this.attributes[e.nodeName]=new a.Property(e.nodeName,e.value)}this.addStylesFromStyleDefinition();if(this.attribute("style").hasValue())for(e=this.attribute("style").value.split(";"),b=0;b<e.length;b++)if(""!=a.trim(e[b])){var d=e[b].split(":"),k=a.trim(d[0]),d=a.trim(d[1]);this.styles[k]=new a.Property(k,d)}this.attribute("id").hasValue()&&
|
38
|
+
null==a.Definitions[this.attribute("id").value]&&(a.Definitions[this.attribute("id").value]=this);for(b=0;b<c.childNodes.length;b++)e=c.childNodes[b],1==e.nodeType&&this.addChild(e,!0),!this.captureTextNodes||3!=e.nodeType&&4!=e.nodeType||""!=a.compressSpaces(e.value||e.text||e.textContent||"")&&this.addChild(new a.Element.tspan(e),!1)}};a.Element.RenderedElementBase=function(c){this.base=a.Element.ElementBase;this.base(c);this.setContext=function(b){if(this.style("fill").isUrlDefinition()){var e=
|
39
|
+
this.style("fill").getFillStyleDefinition(this,this.style("fill-opacity"));null!=e&&(b.fillStyle=e)}else this.style("fill").hasValue()&&(e=this.style("fill"),"currentColor"==e.value&&(e.value=this.style("color").value),"inherit"!=e.value&&(b.fillStyle="none"==e.value?"rgba(0,0,0,0)":e.value));this.style("fill-opacity").hasValue()&&(e=new a.Property("fill",b.fillStyle),e=e.addOpacity(this.style("fill-opacity")),b.fillStyle=e.value);this.style("stroke").isUrlDefinition()?(e=this.style("stroke").getFillStyleDefinition(this,
|
40
|
+
this.style("stroke-opacity")),null!=e&&(b.strokeStyle=e)):this.style("stroke").hasValue()&&(e=this.style("stroke"),"currentColor"==e.value&&(e.value=this.style("color").value),"inherit"!=e.value&&(b.strokeStyle="none"==e.value?"rgba(0,0,0,0)":e.value));this.style("stroke-opacity").hasValue()&&(e=new a.Property("stroke",b.strokeStyle),e=e.addOpacity(this.style("stroke-opacity")),b.strokeStyle=e.value);this.style("stroke-width").hasValue()&&(e=this.style("stroke-width").toPixels(),b.lineWidth=0==e?
|
41
|
+
.001:e);this.style("stroke-linecap").hasValue()&&(b.lineCap=this.style("stroke-linecap").value);this.style("stroke-linejoin").hasValue()&&(b.lineJoin=this.style("stroke-linejoin").value);this.style("stroke-miterlimit").hasValue()&&(b.miterLimit=this.style("stroke-miterlimit").value);this.style("stroke-dasharray").hasValue()&&"none"!=this.style("stroke-dasharray").value&&(e=a.ToNumberArray(this.style("stroke-dasharray").value),"undefined"!=typeof b.setLineDash?b.setLineDash(e):"undefined"!=typeof b.webkitLineDash?
|
42
|
+
b.webkitLineDash=e:"undefined"==typeof b.mozDash||1==e.length&&0==e[0]||(b.mozDash=e),e=this.style("stroke-dashoffset").numValueOrDefault(1),"undefined"!=typeof b.lineDashOffset?b.lineDashOffset=e:"undefined"!=typeof b.webkitLineDashOffset?b.webkitLineDashOffset=e:"undefined"!=typeof b.mozDashOffset&&(b.mozDashOffset=e));"undefined"!=typeof b.font&&(b.font=a.Font.CreateFont(this.style("font-style").value,this.style("font-variant").value,this.style("font-weight").value,this.style("font-size").hasValue()?
|
43
|
+
this.style("font-size").toPixels()+"px":"",this.style("font-family").value).toString());this.style("transform",!1,!0).hasValue()&&(new a.Transform(this.style("transform",!1,!0).value)).apply(b);this.style("clip-path",!1,!0).hasValue()&&(e=this.style("clip-path",!1,!0).getDefinition(),null!=e&&e.apply(b));this.style("opacity").hasValue()&&(b.globalAlpha=this.style("opacity").numValue())}};a.Element.RenderedElementBase.prototype=new a.Element.ElementBase;a.Element.PathElementBase=function(c){this.base=
|
44
|
+
a.Element.RenderedElementBase;this.base(c);this.path=function(b){null!=b&&b.beginPath();return new a.BoundingBox};this.renderChildren=function(b){this.path(b);a.Mouse.checkPath(this,b);""!=b.fillStyle&&("inherit"!=this.style("fill-rule").valueOrDefault("inherit")?b.fill(this.style("fill-rule").value):b.fill());""!=b.strokeStyle&&b.stroke();var e=this.getMarkers();if(null!=e){if(this.style("marker-start").isUrlDefinition()){var d=this.style("marker-start").getDefinition();d.render(b,e[0][0],e[0][1])}if(this.style("marker-mid").isUrlDefinition())for(var d=
|
45
|
+
this.style("marker-mid").getDefinition(),c=1;c<e.length-1;c++)d.render(b,e[c][0],e[c][1]);this.style("marker-end").isUrlDefinition()&&(d=this.style("marker-end").getDefinition(),d.render(b,e[e.length-1][0],e[e.length-1][1]))}};this.getBoundingBox=function(){return this.path()};this.getMarkers=function(){return null}};a.Element.PathElementBase.prototype=new a.Element.RenderedElementBase;a.Element.svg=function(c){this.base=a.Element.RenderedElementBase;this.base(c);this.baseClearContext=this.clearContext;
|
46
|
+
this.clearContext=function(b){this.baseClearContext(b);a.ViewPort.RemoveCurrent()};this.baseSetContext=this.setContext;this.setContext=function(b){b.strokeStyle="rgba(0,0,0,0)";b.lineCap="butt";b.lineJoin="miter";b.miterLimit=4;"undefined"!=typeof b.font&&"undefined"!=typeof window.getComputedStyle&&(b.font=window.getComputedStyle(b.canvas).getPropertyValue("font"));this.baseSetContext(b);this.attribute("x").hasValue()||(this.attribute("x",!0).value=0);this.attribute("y").hasValue()||(this.attribute("y",
|
47
|
+
!0).value=0);b.translate(this.attribute("x").toPixels("x"),this.attribute("y").toPixels("y"));var e=a.ViewPort.width(),d=a.ViewPort.height();this.attribute("width").hasValue()||(this.attribute("width",!0).value="100%");this.attribute("height").hasValue()||(this.attribute("height",!0).value="100%");if("undefined"==typeof this.root){var e=this.attribute("width").toPixels("x"),d=this.attribute("height").toPixels("y"),c=0,f=0;this.attribute("refX").hasValue()&&this.attribute("refY").hasValue()&&(c=-this.attribute("refX").toPixels("x"),
|
48
|
+
f=-this.attribute("refY").toPixels("y"));"visible"!=this.attribute("overflow").valueOrDefault("hidden")&&(b.beginPath(),b.moveTo(c,f),b.lineTo(e,f),b.lineTo(e,d),b.lineTo(c,d),b.closePath(),b.clip())}a.ViewPort.SetCurrent(e,d);if(this.attribute("viewBox").hasValue()){var c=a.ToNumberArray(this.attribute("viewBox").value),f=c[0],g=c[1],e=c[2],d=c[3];a.AspectRatio(b,this.attribute("preserveAspectRatio").value,a.ViewPort.width(),e,a.ViewPort.height(),d,f,g,this.attribute("refX").value,this.attribute("refY").value);
|
49
|
+
a.ViewPort.RemoveCurrent();a.ViewPort.SetCurrent(c[2],c[3])}}};a.Element.svg.prototype=new a.Element.RenderedElementBase;a.Element.rect=function(c){this.base=a.Element.PathElementBase;this.base(c);this.path=function(b){var e=this.attribute("x").toPixels("x"),d=this.attribute("y").toPixels("y"),c=this.attribute("width").toPixels("x"),f=this.attribute("height").toPixels("y"),g=this.attribute("rx").toPixels("x"),m=this.attribute("ry").toPixels("y");this.attribute("rx").hasValue()&&!this.attribute("ry").hasValue()&&
|
50
|
+
(m=g);this.attribute("ry").hasValue()&&!this.attribute("rx").hasValue()&&(g=m);g=Math.min(g,c/2);m=Math.min(m,f/2);null!=b&&(b.beginPath(),b.moveTo(e+g,d),b.lineTo(e+c-g,d),b.quadraticCurveTo(e+c,d,e+c,d+m),b.lineTo(e+c,d+f-m),b.quadraticCurveTo(e+c,d+f,e+c-g,d+f),b.lineTo(e+g,d+f),b.quadraticCurveTo(e,d+f,e,d+f-m),b.lineTo(e,d+m),b.quadraticCurveTo(e,d,e+g,d),b.closePath());return new a.BoundingBox(e,d,e+c,d+f)}};a.Element.rect.prototype=new a.Element.PathElementBase;a.Element.circle=function(c){this.base=
|
51
|
+
a.Element.PathElementBase;this.base(c);this.path=function(b){var e=this.attribute("cx").toPixels("x"),d=this.attribute("cy").toPixels("y"),c=this.attribute("r").toPixels();null!=b&&(b.beginPath(),b.arc(e,d,c,0,2*Math.PI,!0),b.closePath());return new a.BoundingBox(e-c,d-c,e+c,d+c)}};a.Element.circle.prototype=new a.Element.PathElementBase;a.Element.ellipse=function(c){this.base=a.Element.PathElementBase;this.base(c);this.path=function(b){var e=(Math.sqrt(2)-1)/3*4,d=this.attribute("rx").toPixels("x"),
|
52
|
+
c=this.attribute("ry").toPixels("y"),f=this.attribute("cx").toPixels("x"),g=this.attribute("cy").toPixels("y");null!=b&&(b.beginPath(),b.moveTo(f,g-c),b.bezierCurveTo(f+e*d,g-c,f+d,g-e*c,f+d,g),b.bezierCurveTo(f+d,g+e*c,f+e*d,g+c,f,g+c),b.bezierCurveTo(f-e*d,g+c,f-d,g+e*c,f-d,g),b.bezierCurveTo(f-d,g-e*c,f-e*d,g-c,f,g-c),b.closePath());return new a.BoundingBox(f-d,g-c,f+d,g+c)}};a.Element.ellipse.prototype=new a.Element.PathElementBase;a.Element.line=function(c){this.base=a.Element.PathElementBase;
|
53
|
+
this.base(c);this.getPoints=function(){return[new a.Point(this.attribute("x1").toPixels("x"),this.attribute("y1").toPixels("y")),new a.Point(this.attribute("x2").toPixels("x"),this.attribute("y2").toPixels("y"))]};this.path=function(b){var e=this.getPoints();null!=b&&(b.beginPath(),b.moveTo(e[0].x,e[0].y),b.lineTo(e[1].x,e[1].y));return new a.BoundingBox(e[0].x,e[0].y,e[1].x,e[1].y)};this.getMarkers=function(){var a=this.getPoints(),e=a[0].angleTo(a[1]);return[[a[0],e],[a[1],e]]}};a.Element.line.prototype=
|
54
|
+
new a.Element.PathElementBase;a.Element.polyline=function(c){this.base=a.Element.PathElementBase;this.base(c);this.points=a.CreatePath(this.attribute("points").value);this.path=function(b){var e=new a.BoundingBox(this.points[0].x,this.points[0].y);null!=b&&(b.beginPath(),b.moveTo(this.points[0].x,this.points[0].y));for(var d=1;d<this.points.length;d++)e.addPoint(this.points[d].x,this.points[d].y),null!=b&&b.lineTo(this.points[d].x,this.points[d].y);return e};this.getMarkers=function(){for(var a=[],
|
55
|
+
e=0;e<this.points.length-1;e++)a.push([this.points[e],this.points[e].angleTo(this.points[e+1])]);a.push([this.points[this.points.length-1],a[a.length-1][1]]);return a}};a.Element.polyline.prototype=new a.Element.PathElementBase;a.Element.polygon=function(c){this.base=a.Element.polyline;this.base(c);this.basePath=this.path;this.path=function(a){var e=this.basePath(a);null!=a&&(a.lineTo(this.points[0].x,this.points[0].y),a.closePath());return e}};a.Element.polygon.prototype=new a.Element.polyline;a.Element.path=
|
56
|
+
function(c){this.base=a.Element.PathElementBase;this.base(c);c=this.attribute("d").value;c=c.replace(/,/gm," ");for(var b=0;2>b;b++)c=c.replace(/([MmZzLlHhVvCcSsQqTtAa])([^\s])/gm,"$1 $2");c=c.replace(/([^\s])([MmZzLlHhVvCcSsQqTtAa])/gm,"$1 $2");c=c.replace(/([0-9])([+\-])/gm,"$1 $2");for(b=0;2>b;b++)c=c.replace(/(\.[0-9]*)(\.)/gm,"$1 $2");c=c.replace(/([Aa](\s+[0-9]+){3})\s+([01])\s*([01])/gm,"$1 $3 $4 ");c=a.compressSpaces(c);c=a.trim(c);this.PathParser=new function(b){this.tokens=b.split(" ");
|
57
|
+
this.reset=function(){this.i=-1;this.previousCommand=this.command="";this.start=new a.Point(0,0);this.control=new a.Point(0,0);this.current=new a.Point(0,0);this.points=[];this.angles=[]};this.isEnd=function(){return this.i>=this.tokens.length-1};this.isCommandOrEnd=function(){return this.isEnd()?!0:null!=this.tokens[this.i+1].match(/^[A-Za-z]$/)};this.isRelativeCommand=function(){switch(this.command){case "m":case "l":case "h":case "v":case "c":case "s":case "q":case "t":case "a":case "z":return!0}return!1};
|
58
|
+
this.getToken=function(){this.i++;return this.tokens[this.i]};this.getScalar=function(){return parseFloat(this.getToken())};this.nextCommand=function(){this.previousCommand=this.command;this.command=this.getToken()};this.getPoint=function(){var b=new a.Point(this.getScalar(),this.getScalar());return this.makeAbsolute(b)};this.getAsControlPoint=function(){var a=this.getPoint();return this.control=a};this.getAsCurrentPoint=function(){var a=this.getPoint();return this.current=a};this.getReflectedControlPoint=
|
59
|
+
function(){return"c"!=this.previousCommand.toLowerCase()&&"s"!=this.previousCommand.toLowerCase()&&"q"!=this.previousCommand.toLowerCase()&&"t"!=this.previousCommand.toLowerCase()?this.current:new a.Point(2*this.current.x-this.control.x,2*this.current.y-this.control.y)};this.makeAbsolute=function(a){this.isRelativeCommand()&&(a.x+=this.current.x,a.y+=this.current.y);return a};this.addMarker=function(a,b,e){null!=e&&0<this.angles.length&&null==this.angles[this.angles.length-1]&&(this.angles[this.angles.length-
|
60
|
+
1]=this.points[this.points.length-1].angleTo(e));this.addMarkerAngle(a,null==b?null:b.angleTo(a))};this.addMarkerAngle=function(a,b){this.points.push(a);this.angles.push(b)};this.getMarkerPoints=function(){return this.points};this.getMarkerAngles=function(){for(var a=0;a<this.angles.length;a++)if(null==this.angles[a])for(var b=a+1;b<this.angles.length;b++)if(null!=this.angles[b]){this.angles[a]=this.angles[b];break}return this.angles}}(c);this.path=function(b){var d=this.PathParser;d.reset();var c=
|
61
|
+
new a.BoundingBox;for(null!=b&&b.beginPath();!d.isEnd();)switch(d.nextCommand(),d.command){case "M":case "m":var f=d.getAsCurrentPoint();d.addMarker(f);c.addPoint(f.x,f.y);null!=b&&b.moveTo(f.x,f.y);for(d.start=d.current;!d.isCommandOrEnd();)f=d.getAsCurrentPoint(),d.addMarker(f,d.start),c.addPoint(f.x,f.y),null!=b&&b.lineTo(f.x,f.y);break;case "L":case "l":for(;!d.isCommandOrEnd();){var g=d.current,f=d.getAsCurrentPoint();d.addMarker(f,g);c.addPoint(f.x,f.y);null!=b&&b.lineTo(f.x,f.y)}break;case "H":case "h":for(;!d.isCommandOrEnd();)f=
|
62
|
+
new a.Point((d.isRelativeCommand()?d.current.x:0)+d.getScalar(),d.current.y),d.addMarker(f,d.current),d.current=f,c.addPoint(d.current.x,d.current.y),null!=b&&b.lineTo(d.current.x,d.current.y);break;case "V":case "v":for(;!d.isCommandOrEnd();)f=new a.Point(d.current.x,(d.isRelativeCommand()?d.current.y:0)+d.getScalar()),d.addMarker(f,d.current),d.current=f,c.addPoint(d.current.x,d.current.y),null!=b&&b.lineTo(d.current.x,d.current.y);break;case "C":case "c":for(;!d.isCommandOrEnd();){var m=d.current,
|
63
|
+
g=d.getPoint(),n=d.getAsControlPoint(),f=d.getAsCurrentPoint();d.addMarker(f,n,g);c.addBezierCurve(m.x,m.y,g.x,g.y,n.x,n.y,f.x,f.y);null!=b&&b.bezierCurveTo(g.x,g.y,n.x,n.y,f.x,f.y)}break;case "S":case "s":for(;!d.isCommandOrEnd();)m=d.current,g=d.getReflectedControlPoint(),n=d.getAsControlPoint(),f=d.getAsCurrentPoint(),d.addMarker(f,n,g),c.addBezierCurve(m.x,m.y,g.x,g.y,n.x,n.y,f.x,f.y),null!=b&&b.bezierCurveTo(g.x,g.y,n.x,n.y,f.x,f.y);break;case "Q":case "q":for(;!d.isCommandOrEnd();)m=d.current,
|
64
|
+
n=d.getAsControlPoint(),f=d.getAsCurrentPoint(),d.addMarker(f,n,n),c.addQuadraticCurve(m.x,m.y,n.x,n.y,f.x,f.y),null!=b&&b.quadraticCurveTo(n.x,n.y,f.x,f.y);break;case "T":case "t":for(;!d.isCommandOrEnd();)m=d.current,n=d.getReflectedControlPoint(),d.control=n,f=d.getAsCurrentPoint(),d.addMarker(f,n,n),c.addQuadraticCurve(m.x,m.y,n.x,n.y,f.x,f.y),null!=b&&b.quadraticCurveTo(n.x,n.y,f.x,f.y);break;case "A":case "a":for(;!d.isCommandOrEnd();){var m=d.current,r=d.getScalar(),h=d.getScalar(),g=d.getScalar()*
|
65
|
+
(Math.PI/180),p=d.getScalar(),n=d.getScalar(),f=d.getAsCurrentPoint(),l=new a.Point(Math.cos(g)*(m.x-f.x)/2+Math.sin(g)*(m.y-f.y)/2,-Math.sin(g)*(m.x-f.x)/2+Math.cos(g)*(m.y-f.y)/2),v=Math.pow(l.x,2)/Math.pow(r,2)+Math.pow(l.y,2)/Math.pow(h,2);1<v&&(r*=Math.sqrt(v),h*=Math.sqrt(v));p=(p==n?-1:1)*Math.sqrt((Math.pow(r,2)*Math.pow(h,2)-Math.pow(r,2)*Math.pow(l.y,2)-Math.pow(h,2)*Math.pow(l.x,2))/(Math.pow(r,2)*Math.pow(l.y,2)+Math.pow(h,2)*Math.pow(l.x,2)));isNaN(p)&&(p=0);var q=new a.Point(p*r*l.y/
|
66
|
+
h,p*-h*l.x/r),m=new a.Point((m.x+f.x)/2+Math.cos(g)*q.x-Math.sin(g)*q.y,(m.y+f.y)/2+Math.sin(g)*q.x+Math.cos(g)*q.y),w=function(a,b){return(a[0]*b[0]+a[1]*b[1])/(Math.sqrt(Math.pow(a[0],2)+Math.pow(a[1],2))*Math.sqrt(Math.pow(b[0],2)+Math.pow(b[1],2)))},x=function(a,b){return(a[0]*b[1]<a[1]*b[0]?-1:1)*Math.acos(w(a,b))},p=x([1,0],[(l.x-q.x)/r,(l.y-q.y)/h]),v=[(l.x-q.x)/r,(l.y-q.y)/h],q=[(-l.x-q.x)/r,(-l.y-q.y)/h],l=x(v,q);-1>=w(v,q)&&(l=Math.PI);1<=w(v,q)&&(l=0);v=1-n?1:-1;q=p+l/2*v;x=new a.Point(m.x+
|
67
|
+
r*Math.cos(q),m.y+h*Math.sin(q));d.addMarkerAngle(x,q-v*Math.PI/2);d.addMarkerAngle(f,q-v*Math.PI);c.addPoint(f.x,f.y);null!=b&&(w=r>h?r:h,f=r>h?1:r/h,r=r>h?h/r:1,b.translate(m.x,m.y),b.rotate(g),b.scale(f,r),b.arc(0,0,w,p,p+l,1-n),b.scale(1/f,1/r),b.rotate(-g),b.translate(-m.x,-m.y))}break;case "Z":case "z":null!=b&&b.closePath(),d.current=d.start}return c};this.getMarkers=function(){for(var a=this.PathParser.getMarkerPoints(),b=this.PathParser.getMarkerAngles(),c=[],f=0;f<a.length;f++)c.push([a[f],
|
68
|
+
b[f]]);return c}};a.Element.path.prototype=new a.Element.PathElementBase;a.Element.pattern=function(c){this.base=a.Element.ElementBase;this.base(c);this.createPattern=function(b,e){var d=this.attribute("width").toPixels("x",!0),c=this.attribute("height").toPixels("y",!0),f=new a.Element.svg;f.attributes.viewBox=new a.Property("viewBox",this.attribute("viewBox").value);f.attributes.width=new a.Property("width",d+"px");f.attributes.height=new a.Property("height",c+"px");f.attributes.transform=new a.Property("transform",
|
69
|
+
this.attribute("patternTransform").value);f.children=this.children;var g=document.createElement("canvas");g.width=d;g.height=c;d=g.getContext("2d");this.attribute("x").hasValue()&&this.attribute("y").hasValue()&&d.translate(this.attribute("x").toPixels("x",!0),this.attribute("y").toPixels("y",!0));for(c=-1;1>=c;c++)for(var m=-1;1>=m;m++)d.save(),f.attributes.x=new a.Property("x",c*g.width),f.attributes.y=new a.Property("y",m*g.height),f.render(d),d.restore();return b.createPattern(g,"repeat")}};a.Element.pattern.prototype=
|
70
|
+
new a.Element.ElementBase;a.Element.marker=function(c){this.base=a.Element.ElementBase;this.base(c);this.baseRender=this.render;this.render=function(b,e,d){b.translate(e.x,e.y);"auto"==this.attribute("orient").valueOrDefault("auto")&&b.rotate(d);"strokeWidth"==this.attribute("markerUnits").valueOrDefault("strokeWidth")&&b.scale(b.lineWidth,b.lineWidth);b.save();var c=new a.Element.svg;c.attributes.viewBox=new a.Property("viewBox",this.attribute("viewBox").value);c.attributes.refX=new a.Property("refX",
|
71
|
+
this.attribute("refX").value);c.attributes.refY=new a.Property("refY",this.attribute("refY").value);c.attributes.width=new a.Property("width",this.attribute("markerWidth").value);c.attributes.height=new a.Property("height",this.attribute("markerHeight").value);c.attributes.fill=new a.Property("fill",this.attribute("fill").valueOrDefault("black"));c.attributes.stroke=new a.Property("stroke",this.attribute("stroke").valueOrDefault("none"));c.children=this.children;c.render(b);b.restore();"strokeWidth"==
|
72
|
+
this.attribute("markerUnits").valueOrDefault("strokeWidth")&&b.scale(1/b.lineWidth,1/b.lineWidth);"auto"==this.attribute("orient").valueOrDefault("auto")&&b.rotate(-d);b.translate(-e.x,-e.y)}};a.Element.marker.prototype=new a.Element.ElementBase;a.Element.defs=function(c){this.base=a.Element.ElementBase;this.base(c);this.render=function(a){}};a.Element.defs.prototype=new a.Element.ElementBase;a.Element.GradientBase=function(c){this.base=a.Element.ElementBase;this.base(c);this.stops=[];for(c=0;c<this.children.length;c++){var b=
|
73
|
+
this.children[c];"stop"==b.type&&this.stops.push(b)}this.getGradient=function(){};this.gradientUnits=function(){return this.attribute("gradientUnits").valueOrDefault("objectBoundingBox")};this.attributesToInherit=["gradientUnits"];this.inheritStopContainer=function(a){for(var b=0;b<this.attributesToInherit.length;b++){var c=this.attributesToInherit[b];!this.attribute(c).hasValue()&&a.attribute(c).hasValue()&&(this.attribute(c,!0).value=a.attribute(c).value)}};this.createGradient=function(b,d,c){var f=
|
74
|
+
this;this.getHrefAttribute().hasValue()&&(f=this.getHrefAttribute().getDefinition(),this.inheritStopContainer(f));var g=function(b){return c.hasValue()?(new a.Property("color",b)).addOpacity(c).value:b};b=this.getGradient(b,d);if(null==b)return g(f.stops[f.stops.length-1].color);for(d=0;d<f.stops.length;d++)b.addColorStop(f.stops[d].offset,g(f.stops[d].color));return this.attribute("gradientTransform").hasValue()?(f=a.ViewPort.viewPorts[0],g=new a.Element.rect,g.attributes.x=new a.Property("x",-a.MAX_VIRTUAL_PIXELS/
|
75
|
+
3),g.attributes.y=new a.Property("y",-a.MAX_VIRTUAL_PIXELS/3),g.attributes.width=new a.Property("width",a.MAX_VIRTUAL_PIXELS),g.attributes.height=new a.Property("height",a.MAX_VIRTUAL_PIXELS),d=new a.Element.g,d.attributes.transform=new a.Property("transform",this.attribute("gradientTransform").value),d.children=[g],g=new a.Element.svg,g.attributes.x=new a.Property("x",0),g.attributes.y=new a.Property("y",0),g.attributes.width=new a.Property("width",f.width),g.attributes.height=new a.Property("height",
|
76
|
+
f.height),g.children=[d],d=document.createElement("canvas"),d.width=f.width,d.height=f.height,f=d.getContext("2d"),f.fillStyle=b,g.render(f),f.createPattern(d,"no-repeat")):b}};a.Element.GradientBase.prototype=new a.Element.ElementBase;a.Element.linearGradient=function(c){this.base=a.Element.GradientBase;this.base(c);this.attributesToInherit.push("x1");this.attributesToInherit.push("y1");this.attributesToInherit.push("x2");this.attributesToInherit.push("y2");this.getGradient=function(a,e){var c="objectBoundingBox"==
|
77
|
+
this.gradientUnits()?e.getBoundingBox():null;this.attribute("x1").hasValue()||this.attribute("y1").hasValue()||this.attribute("x2").hasValue()||this.attribute("y2").hasValue()||(this.attribute("x1",!0).value=0,this.attribute("y1",!0).value=0,this.attribute("x2",!0).value=1,this.attribute("y2",!0).value=0);var k="objectBoundingBox"==this.gradientUnits()?c.x()+c.width()*this.attribute("x1").numValue():this.attribute("x1").toPixels("x"),f="objectBoundingBox"==this.gradientUnits()?c.y()+c.height()*this.attribute("y1").numValue():
|
78
|
+
this.attribute("y1").toPixels("y"),g="objectBoundingBox"==this.gradientUnits()?c.x()+c.width()*this.attribute("x2").numValue():this.attribute("x2").toPixels("x"),c="objectBoundingBox"==this.gradientUnits()?c.y()+c.height()*this.attribute("y2").numValue():this.attribute("y2").toPixels("y");return k==g&&f==c?null:a.createLinearGradient(k,f,g,c)}};a.Element.linearGradient.prototype=new a.Element.GradientBase;a.Element.radialGradient=function(c){this.base=a.Element.GradientBase;this.base(c);this.attributesToInherit.push("cx");
|
79
|
+
this.attributesToInherit.push("cy");this.attributesToInherit.push("r");this.attributesToInherit.push("fx");this.attributesToInherit.push("fy");this.getGradient=function(a,c){var d=c.getBoundingBox();this.attribute("cx").hasValue()||(this.attribute("cx",!0).value="50%");this.attribute("cy").hasValue()||(this.attribute("cy",!0).value="50%");this.attribute("r").hasValue()||(this.attribute("r",!0).value="50%");var k="objectBoundingBox"==this.gradientUnits()?d.x()+d.width()*this.attribute("cx").numValue():
|
80
|
+
this.attribute("cx").toPixels("x"),f="objectBoundingBox"==this.gradientUnits()?d.y()+d.height()*this.attribute("cy").numValue():this.attribute("cy").toPixels("y"),g=k,m=f;this.attribute("fx").hasValue()&&(g="objectBoundingBox"==this.gradientUnits()?d.x()+d.width()*this.attribute("fx").numValue():this.attribute("fx").toPixels("x"));this.attribute("fy").hasValue()&&(m="objectBoundingBox"==this.gradientUnits()?d.y()+d.height()*this.attribute("fy").numValue():this.attribute("fy").toPixels("y"));d="objectBoundingBox"==
|
81
|
+
this.gradientUnits()?(d.width()+d.height())/2*this.attribute("r").numValue():this.attribute("r").toPixels();return a.createRadialGradient(g,m,0,k,f,d)}};a.Element.radialGradient.prototype=new a.Element.GradientBase;a.Element.stop=function(c){this.base=a.Element.ElementBase;this.base(c);this.offset=this.attribute("offset").numValue();0>this.offset&&(this.offset=0);1<this.offset&&(this.offset=1);c=this.style("stop-color",!0);""===c.value&&(c.value="#000");this.style("stop-opacity").hasValue()&&(c=c.addOpacity(this.style("stop-opacity")));
|
82
|
+
this.color=c.value};a.Element.stop.prototype=new a.Element.ElementBase;a.Element.AnimateBase=function(c){this.base=a.Element.ElementBase;this.base(c);a.Animations.push(this);this.duration=0;this.begin=this.attribute("begin").toMilliseconds();this.maxDuration=this.begin+this.attribute("dur").toMilliseconds();this.getProperty=function(){var a=this.attribute("attributeType").value,c=this.attribute("attributeName").value;return"CSS"==a?this.parent.style(c,!0):this.parent.attribute(c,!0)};this.initialValue=
|
83
|
+
null;this.initialUnits="";this.removed=!1;this.calcValue=function(){return""};this.update=function(a){null==this.initialValue&&(this.initialValue=this.getProperty().value,this.initialUnits=this.getProperty().getUnits());if(this.duration>this.maxDuration){if("indefinite"==this.attribute("repeatCount").value||"indefinite"==this.attribute("repeatDur").value)this.duration=0;else if("freeze"==this.attribute("fill").valueOrDefault("remove")&&!this.frozen)this.frozen=!0,this.parent.animationFrozen=!0,this.parent.animationFrozenValue=
|
84
|
+
this.getProperty().value;else if("remove"==this.attribute("fill").valueOrDefault("remove")&&!this.removed)return this.removed=!0,this.getProperty().value=this.parent.animationFrozen?this.parent.animationFrozenValue:this.initialValue,!0;return!1}this.duration+=a;a=!1;this.begin<this.duration&&(a=this.calcValue(),this.attribute("type").hasValue()&&(a=this.attribute("type").value+"("+a+")"),this.getProperty().value=a,a=!0);return a};this.from=this.attribute("from");this.to=this.attribute("to");this.values=
|
85
|
+
this.attribute("values");this.values.hasValue()&&(this.values.value=this.values.value.split(";"));this.progress=function(){var b={progress:(this.duration-this.begin)/(this.maxDuration-this.begin)};if(this.values.hasValue()){var c=b.progress*(this.values.value.length-1),d=Math.floor(c),k=Math.ceil(c);b.from=new a.Property("from",parseFloat(this.values.value[d]));b.to=new a.Property("to",parseFloat(this.values.value[k]));b.progress=(c-d)/(k-d)}else b.from=this.from,b.to=this.to;return b}};a.Element.AnimateBase.prototype=
|
86
|
+
new a.Element.ElementBase;a.Element.animate=function(c){this.base=a.Element.AnimateBase;this.base(c);this.calcValue=function(){var a=this.progress();return a.from.numValue()+(a.to.numValue()-a.from.numValue())*a.progress+this.initialUnits}};a.Element.animate.prototype=new a.Element.AnimateBase;a.Element.animateColor=function(c){this.base=a.Element.AnimateBase;this.base(c);this.calcValue=function(){var a=this.progress(),c=new x(a.from.value),d=new x(a.to.value);if(c.ok&&d.ok){var k=c.g+(d.g-c.g)*a.progress,
|
87
|
+
f=c.b+(d.b-c.b)*a.progress;return"rgb("+parseInt(c.r+(d.r-c.r)*a.progress,10)+","+parseInt(k,10)+","+parseInt(f,10)+")"}return this.attribute("from").value}};a.Element.animateColor.prototype=new a.Element.AnimateBase;a.Element.animateTransform=function(c){this.base=a.Element.AnimateBase;this.base(c);this.calcValue=function(){for(var b=this.progress(),c=a.ToNumberArray(b.from.value),d=a.ToNumberArray(b.to.value),k="",f=0;f<c.length;f++)k+=c[f]+(d[f]-c[f])*b.progress+" ";return k}};a.Element.animateTransform.prototype=
|
88
|
+
new a.Element.animate;a.Element.font=function(c){this.base=a.Element.ElementBase;this.base(c);this.horizAdvX=this.attribute("horiz-adv-x").numValue();this.isArabic=this.isRTL=!1;this.missingGlyph=this.fontFace=null;this.glyphs=[];for(c=0;c<this.children.length;c++){var b=this.children[c];"font-face"==b.type?(this.fontFace=b,b.style("font-family").hasValue()&&(a.Definitions[b.style("font-family").value]=this)):"missing-glyph"==b.type?this.missingGlyph=b:"glyph"==b.type&&(""!=b.arabicForm?(this.isArabic=
|
89
|
+
this.isRTL=!0,"undefined"==typeof this.glyphs[b.unicode]&&(this.glyphs[b.unicode]=[]),this.glyphs[b.unicode][b.arabicForm]=b):this.glyphs[b.unicode]=b)}};a.Element.font.prototype=new a.Element.ElementBase;a.Element.fontface=function(c){this.base=a.Element.ElementBase;this.base(c);this.ascent=this.attribute("ascent").value;this.descent=this.attribute("descent").value;this.unitsPerEm=this.attribute("units-per-em").numValue()};a.Element.fontface.prototype=new a.Element.ElementBase;a.Element.missingglyph=
|
90
|
+
function(c){this.base=a.Element.path;this.base(c);this.horizAdvX=0};a.Element.missingglyph.prototype=new a.Element.path;a.Element.glyph=function(c){this.base=a.Element.path;this.base(c);this.horizAdvX=this.attribute("horiz-adv-x").numValue();this.unicode=this.attribute("unicode").value;this.arabicForm=this.attribute("arabic-form").value};a.Element.glyph.prototype=new a.Element.path;a.Element.text=function(c){this.captureTextNodes=!0;this.base=a.Element.RenderedElementBase;this.base(c);this.baseSetContext=
|
91
|
+
this.setContext;this.setContext=function(a){this.baseSetContext(a);var c=this.style("dominant-baseline").toTextBaseline();null==c&&(c=this.style("alignment-baseline").toTextBaseline());null!=c&&(a.textBaseline=c)};this.getBoundingBox=function(){var b=this.attribute("x").toPixels("x"),c=this.attribute("y").toPixels("y"),d=this.parent.style("font-size").numValueOrDefault(a.Font.Parse(a.ctx.font).fontSize);return new a.BoundingBox(b,c-d,b+Math.floor(2*d/3)*this.children[0].getText().length,c)};this.renderChildren=
|
92
|
+
function(a){this.x=this.attribute("x").toPixels("x");this.y=this.attribute("y").toPixels("y");this.attribute("dx").hasValue()&&(this.x+=this.attribute("dx").toPixels("x"));this.attribute("dy").hasValue()&&(this.y+=this.attribute("dy").toPixels("y"));this.x+=this.getAnchorDelta(a,this,0);for(var c=0;c<this.children.length;c++)this.renderChild(a,this,c)};this.getAnchorDelta=function(a,c,d){var k=this.style("text-anchor").valueOrDefault("start");if("start"!=k){for(var f=0,g=d;g<c.children.length;g++){var m=
|
93
|
+
c.children[g];if(g>d&&m.attribute("x").hasValue())break;f+=m.measureTextRecursive(a)}return-1*("end"==k?f:f/2)}return 0};this.renderChild=function(a,c,d){var k=c.children[d];k.attribute("x").hasValue()?(k.x=k.attribute("x").toPixels("x")+c.getAnchorDelta(a,c,d),k.attribute("dx").hasValue()&&(k.x+=k.attribute("dx").toPixels("x"))):(k.attribute("dx").hasValue()&&(c.x+=k.attribute("dx").toPixels("x")),k.x=c.x);c.x=k.x+k.measureText(a);k.attribute("y").hasValue()?(k.y=k.attribute("y").toPixels("y"),k.attribute("dy").hasValue()&&
|
94
|
+
(k.y+=k.attribute("dy").toPixels("y"))):(k.attribute("dy").hasValue()&&(c.y+=k.attribute("dy").toPixels("y")),k.y=c.y);c.y=k.y;k.render(a);for(d=0;d<k.children.length;d++)c.renderChild(a,k,d)}};a.Element.text.prototype=new a.Element.RenderedElementBase;a.Element.TextElementBase=function(c){this.base=a.Element.RenderedElementBase;this.base(c);this.getGlyph=function(a,c,d){var k=c[d],f=null;if(a.isArabic){var g="isolated";(0==d||" "==c[d-1])&&d<c.length-2&&" "!=c[d+1]&&(g="terminal");0<d&&" "!=c[d-
|
95
|
+
1]&&d<c.length-2&&" "!=c[d+1]&&(g="medial");0<d&&" "!=c[d-1]&&(d==c.length-1||" "==c[d+1])&&(g="initial");"undefined"!=typeof a.glyphs[k]&&(f=a.glyphs[k][g],null==f&&"glyph"==a.glyphs[k].type&&(f=a.glyphs[k]))}else f=a.glyphs[k];null==f&&(f=a.missingGlyph);return f};this.renderChildren=function(b){var c=this.parent.style("font-family").getDefinition();if(null!=c){var d=this.parent.style("font-size").numValueOrDefault(a.Font.Parse(a.ctx.font).fontSize),k=this.parent.style("font-style").valueOrDefault(a.Font.Parse(a.ctx.font).fontStyle),
|
96
|
+
f=this.getText();c.isRTL&&(f=f.split("").reverse().join(""));for(var g=a.ToNumberArray(this.parent.attribute("dx").value),m=0;m<f.length;m++){var n=this.getGlyph(c,f,m),h=d/c.fontFace.unitsPerEm;b.translate(this.x,this.y);b.scale(h,-h);var l=b.lineWidth;b.lineWidth=b.lineWidth*c.fontFace.unitsPerEm/d;"italic"==k&&b.transform(1,0,.4,1,0,0);n.render(b);"italic"==k&&b.transform(1,0,-.4,1,0,0);b.lineWidth=l;b.scale(1/h,-1/h);b.translate(-this.x,-this.y);this.x+=d*(n.horizAdvX||c.horizAdvX)/c.fontFace.unitsPerEm;
|
97
|
+
"undefined"==typeof g[m]||isNaN(g[m])||(this.x+=g[m])}}else""!=b.fillStyle&&b.fillText(a.compressSpaces(this.getText()),this.x,this.y),""!=b.strokeStyle&&b.strokeText(a.compressSpaces(this.getText()),this.x,this.y)};this.getText=function(){};this.measureTextRecursive=function(a){for(var c=this.measureText(a),d=0;d<this.children.length;d++)c+=this.children[d].measureTextRecursive(a);return c};this.measureText=function(b){var c=this.parent.style("font-family").getDefinition();if(null!=c){b=this.parent.style("font-size").numValueOrDefault(a.Font.Parse(a.ctx.font).fontSize);
|
98
|
+
var d=0,k=this.getText();c.isRTL&&(k=k.split("").reverse().join(""));for(var f=a.ToNumberArray(this.parent.attribute("dx").value),g=0;g<k.length;g++){var m=this.getGlyph(c,k,g),d=d+(m.horizAdvX||c.horizAdvX)*b/c.fontFace.unitsPerEm;"undefined"==typeof f[g]||isNaN(f[g])||(d+=f[g])}return d}c=a.compressSpaces(this.getText());if(!b.measureText)return 10*c.length;b.save();this.setContext(b);c=b.measureText(c).width;b.restore();return c}};a.Element.TextElementBase.prototype=new a.Element.RenderedElementBase;
|
99
|
+
a.Element.tspan=function(c){this.captureTextNodes=!0;this.base=a.Element.TextElementBase;this.base(c);this.text=a.compressSpaces(c.value||c.text||c.textContent||"");this.getText=function(){return 0<this.children.length?"":this.text}};a.Element.tspan.prototype=new a.Element.TextElementBase;a.Element.tref=function(c){this.base=a.Element.TextElementBase;this.base(c);this.getText=function(){var a=this.getHrefAttribute().getDefinition();if(null!=a)return a.children[0].getText()}};a.Element.tref.prototype=
|
100
|
+
new a.Element.TextElementBase;a.Element.a=function(c){this.base=a.Element.TextElementBase;this.base(c);this.hasText=0<c.childNodes.length;for(var b=0;b<c.childNodes.length;b++)3!=c.childNodes[b].nodeType&&(this.hasText=!1);this.text=this.hasText?c.childNodes[0].value:"";this.getText=function(){return this.text};this.baseRenderChildren=this.renderChildren;this.renderChildren=function(b){if(this.hasText){this.baseRenderChildren(b);var c=new a.Property("fontSize",a.Font.Parse(a.ctx.font).fontSize);a.Mouse.checkBoundingBox(this,
|
101
|
+
new a.BoundingBox(this.x,this.y-c.toPixels("y"),this.x+this.measureText(b),this.y))}else 0<this.children.length&&(c=new a.Element.g,c.children=this.children,c.parent=this,c.render(b))};this.onclick=function(){window.open(this.getHrefAttribute().value)};this.onmousemove=function(){a.ctx.canvas.style.cursor="pointer"}};a.Element.a.prototype=new a.Element.TextElementBase;a.Element.image=function(c){this.base=a.Element.RenderedElementBase;this.base(c);var b=this.getHrefAttribute().value;if(""!=b){var e=
|
102
|
+
b.match(/\.svg$/);a.Images.push(this);this.loaded=!1;if(e)this.img=a.ajax(b),this.loaded=!0;else{this.img=document.createElement("img");1==a.opts.useCORS&&(this.img.crossOrigin="Anonymous");var d=this;this.img.onload=function(){d.loaded=!0};this.img.onerror=function(){a.log('ERROR: image "'+b+'" not found');d.loaded=!0};this.img.src=b}this.renderChildren=function(b){var c=this.attribute("x").toPixels("x"),d=this.attribute("y").toPixels("y"),m=this.attribute("width").toPixels("x"),n=this.attribute("height").toPixels("y");
|
103
|
+
0!=m&&0!=n&&(b.save(),e?b.drawSvg(this.img,c,d,m,n):(b.translate(c,d),a.AspectRatio(b,this.attribute("preserveAspectRatio").value,m,this.img.width,n,this.img.height,0,0),b.drawImage(this.img,0,0)),b.restore())};this.getBoundingBox=function(){var b=this.attribute("x").toPixels("x"),c=this.attribute("y").toPixels("y"),d=this.attribute("width").toPixels("x"),e=this.attribute("height").toPixels("y");return new a.BoundingBox(b,c,b+d,c+e)}}};a.Element.image.prototype=new a.Element.RenderedElementBase;a.Element.g=
|
104
|
+
function(c){this.base=a.Element.RenderedElementBase;this.base(c);this.getBoundingBox=function(){for(var b=new a.BoundingBox,c=0;c<this.children.length;c++)b.addBoundingBox(this.children[c].getBoundingBox());return b}};a.Element.g.prototype=new a.Element.RenderedElementBase;a.Element.symbol=function(c){this.base=a.Element.RenderedElementBase;this.base(c);this.render=function(a){}};a.Element.symbol.prototype=new a.Element.RenderedElementBase;a.Element.style=function(c){this.base=a.Element.ElementBase;
|
105
|
+
this.base(c);for(var b="",e=0;e<c.childNodes.length;e++)b+=c.childNodes[e].data;b=b.replace(/(\/\*([^*]|[\r\n]|(\*+([^*\/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm,"");b=a.compressSpaces(b);c=b.split("}");for(e=0;e<c.length;e++)if(""!=a.trim(c[e]))for(var d=c[e].split("{"),b=d[0].split(","),d=d[1].split(";"),k=0;k<b.length;k++){var f=a.trim(b[k]);if(""!=f){for(var g=a.Styles[f]||{},m=0;m<d.length;m++){var n=d[m].indexOf(":"),h=d[m].substr(0,n),n=d[m].substr(n+1,d[m].length-n);null!=h&&null!=n&&(g[a.trim(h)]=
|
106
|
+
new a.Property(a.trim(h),a.trim(n)))}a.Styles[f]=g;a.StylesSpecificity[f]=A(f);if("@font-face"==f)for(f=g["font-family"].value.replace(/"/g,""),g=g.src.value.split(","),m=0;m<g.length;m++)if(0<g[m].indexOf('format("svg")'))for(h=g[m].indexOf("url"),n=g[m].indexOf(")",h),h=g[m].substr(h+5,n-h-6),h=a.parseXml(a.ajax(h)).getElementsByTagName("font"),n=0;n<h.length;n++){var l=a.CreateElement(h[n]);a.Definitions[f]=l}}}};a.Element.style.prototype=new a.Element.ElementBase;a.Element.use=function(c){this.base=
|
107
|
+
a.Element.RenderedElementBase;this.base(c);this.baseSetContext=this.setContext;this.setContext=function(a){this.baseSetContext(a);this.attribute("x").hasValue()&&a.translate(this.attribute("x").toPixels("x"),0);this.attribute("y").hasValue()&&a.translate(0,this.attribute("y").toPixels("y"))};var b=this.getHrefAttribute().getDefinition();this.path=function(a){null!=b&&b.path(a)};this.getBoundingBox=function(){if(null!=b)return b.getBoundingBox()};this.renderChildren=function(c){if(null!=b){var d=b;
|
108
|
+
"symbol"==b.type&&(d=new a.Element.svg,d.type="svg",d.attributes.viewBox=new a.Property("viewBox",b.attribute("viewBox").value),d.attributes.preserveAspectRatio=new a.Property("preserveAspectRatio",b.attribute("preserveAspectRatio").value),d.attributes.overflow=new a.Property("overflow",b.attribute("overflow").value),d.children=b.children);"svg"==d.type&&(this.attribute("width").hasValue()&&(d.attributes.width=new a.Property("width",this.attribute("width").value)),this.attribute("height").hasValue()&&
|
109
|
+
(d.attributes.height=new a.Property("height",this.attribute("height").value)));var k=d.parent;d.parent=null;d.render(c);d.parent=k}}};a.Element.use.prototype=new a.Element.RenderedElementBase;a.Element.mask=function(c){this.base=a.Element.ElementBase;this.base(c);this.apply=function(b,c){var d=this.attribute("x").toPixels("x"),k=this.attribute("y").toPixels("y"),f=this.attribute("width").toPixels("x"),g=this.attribute("height").toPixels("y");if(0==f&&0==g){g=new a.BoundingBox;for(d=0;d<this.children.length;d++)g.addBoundingBox(this.children[d].getBoundingBox());
|
110
|
+
d=Math.floor(g.x1);k=Math.floor(g.y1);f=Math.floor(g.width());g=Math.floor(g.height())}var m=c.attribute("mask").value;c.attribute("mask").value="";var n=document.createElement("canvas");n.width=d+f;n.height=k+g;var h=n.getContext("2d");this.renderChildren(h);var l=document.createElement("canvas");l.width=d+f;l.height=k+g;var p=l.getContext("2d");c.render(p);p.globalCompositeOperation="destination-in";p.fillStyle=h.createPattern(n,"no-repeat");p.fillRect(0,0,d+f,k+g);b.fillStyle=p.createPattern(l,
|
111
|
+
"no-repeat");b.fillRect(0,0,d+f,k+g);c.attribute("mask").value=m};this.render=function(a){}};a.Element.mask.prototype=new a.Element.ElementBase;a.Element.clipPath=function(c){this.base=a.Element.ElementBase;this.base(c);this.apply=function(b){var c=CanvasRenderingContext2D.prototype.beginPath;CanvasRenderingContext2D.prototype.beginPath=function(){};var d=CanvasRenderingContext2D.prototype.closePath;CanvasRenderingContext2D.prototype.closePath=function(){};c.call(b);for(var k=0;k<this.children.length;k++){var f=
|
112
|
+
this.children[k];if("undefined"!=typeof f.path){var g=null;f.style("transform",!1,!0).hasValue()&&(g=new a.Transform(f.style("transform",!1,!0).value),g.apply(b));f.path(b);CanvasRenderingContext2D.prototype.closePath=d;g&&g.unapply(b)}}d.call(b);b.clip();CanvasRenderingContext2D.prototype.beginPath=c;CanvasRenderingContext2D.prototype.closePath=d};this.render=function(a){}};a.Element.clipPath.prototype=new a.Element.ElementBase;a.Element.filter=function(c){this.base=a.Element.ElementBase;this.base(c);
|
113
|
+
this.apply=function(a,c){var d=c.getBoundingBox(),k=Math.floor(d.x1),f=Math.floor(d.y1),g=Math.floor(d.width()),d=Math.floor(d.height()),m=c.style("filter").value;c.style("filter").value="";for(var h=0,l=0,u=0;u<this.children.length;u++)var p=this.children[u].extraFilterDistance||0,h=Math.max(h,p),l=Math.max(l,p);p=document.createElement("canvas");p.width=g+2*h;p.height=d+2*l;var t=p.getContext("2d");t.translate(-k+h,-f+l);c.render(t);for(u=0;u<this.children.length;u++)"function"===typeof this.children[u].apply&&
|
114
|
+
this.children[u].apply(t,0,0,g+2*h,d+2*l);a.drawImage(p,0,0,g+2*h,d+2*l,k-h,f-l,g+2*h,d+2*l);c.style("filter",!0).value=m};this.render=function(a){}};a.Element.filter.prototype=new a.Element.ElementBase;a.Element.feMorphology=function(c){this.base=a.Element.ElementBase;this.base(c);this.apply=function(a,c,d,k,f){}};a.Element.feMorphology.prototype=new a.Element.ElementBase;a.Element.feComposite=function(c){this.base=a.Element.ElementBase;this.base(c);this.apply=function(a,c,d,k,f){}};a.Element.feComposite.prototype=
|
115
|
+
new a.Element.ElementBase;a.Element.feColorMatrix=function(c){function b(a,b){var c=e[a];return c*(0>c?b-255:b)}this.base=a.Element.ElementBase;this.base(c);var e=a.ToNumberArray(this.attribute("values").value);switch(this.attribute("type").valueOrDefault("matrix")){case "saturate":c=e[0];e=[.213+.787*c,.715-.715*c,.072-.072*c,0,0,.213-.213*c,.715+.285*c,.072-.072*c,0,0,.213-.213*c,.715-.715*c,.072+.928*c,0,0,0,0,0,1,0,0,0,0,0,1];break;case "hueRotate":var d=e[0]*Math.PI/180;c=function(a,b,c){return a+
|
116
|
+
Math.cos(d)*b+Math.sin(d)*c};e=[c(.213,.787,-.213),c(.715,-.715,-.715),c(.072,-.072,.928),0,0,c(.213,-.213,.143),c(.715,.285,.14),c(.072,-.072,-.283),0,0,c(.213,-.213,-.787),c(.715,-.715,.715),c(.072,.928,.072),0,0,0,0,0,1,0,0,0,0,0,1];break;case "luminanceToAlpha":e=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,.2125,.7154,.0721,0,0,0,0,0,0,1]}this.apply=function(a,c,d,e,h){var l=a.getImageData(0,0,e,h);for(d=0;d<h;d++)for(c=0;c<e;c++){var u=l.data[d*e*4+4*c+0],p=l.data[d*e*4+4*c+1],t=l.data[d*e*4+4*c+2],v=l.data[d*
|
117
|
+
e*4+4*c+3],q=b(0,u)+b(1,p)+b(2,t)+b(3,v)+b(4,1);l.data[d*e*4+4*c+0]=q;q=b(5,u)+b(6,p)+b(7,t)+b(8,v)+b(9,1);l.data[d*e*4+4*c+1]=q;q=b(10,u)+b(11,p)+b(12,t)+b(13,v)+b(14,1);l.data[d*e*4+4*c+2]=q;u=b(15,u)+b(16,p)+b(17,t)+b(18,v)+b(19,1);l.data[d*e*4+4*c+3]=u}a.clearRect(0,0,e,h);a.putImageData(l,0,0)}};a.Element.feColorMatrix.prototype=new a.Element.ElementBase;a.Element.feGaussianBlur=function(c){this.base=a.Element.ElementBase;this.base(c);this.extraFilterDistance=this.blurRadius=Math.floor(this.attribute("stdDeviation").numValue());
|
118
|
+
this.apply=function(b,c,d,k,f){"undefined"==typeof y.canvasRGBA?a.log("ERROR: StackBlur.js must be included for blur to work"):(b.canvas.id=a.UniqueId(),b.canvas.style.display="none",document.body.appendChild(b.canvas),y.canvasRGBA(b.canvas.id,c,d,k,f,this.blurRadius),document.body.removeChild(b.canvas))}};a.Element.feGaussianBlur.prototype=new a.Element.ElementBase;a.Element.title=function(a){};a.Element.title.prototype=new a.Element.ElementBase;a.Element.desc=function(a){};a.Element.desc.prototype=
|
119
|
+
new a.Element.ElementBase;a.Element.MISSING=function(c){a.log("ERROR: Element '"+c.nodeName+"' not yet implemented.")};a.Element.MISSING.prototype=new a.Element.ElementBase;a.CreateElement=function(c){var b=c.nodeName.replace(/^[^:]+:/,""),b=b.replace(/\-/g,""),b="undefined"!=typeof a.Element[b]?new a.Element[b](c):new a.Element.MISSING(c);b.type=c.nodeName;return b};a.load=function(c,b){a.loadXml(c,a.ajax(b))};a.loadXml=function(c,b){a.loadXmlDoc(c,a.parseXml(b))};a.loadXmlDoc=function(c,b){a.init(c);
|
120
|
+
var e=function(a){for(var b=c.canvas;b;)a.x-=b.offsetLeft,a.y-=b.offsetTop,b=b.offsetParent;window.scrollX&&(a.x+=window.scrollX);window.scrollY&&(a.y+=window.scrollY);return a};1!=a.opts.ignoreMouse&&(c.canvas.onclick=function(b){b=e(new a.Point(null!=b?b.clientX:event.clientX,null!=b?b.clientY:event.clientY));a.Mouse.onclick(b.x,b.y)},c.canvas.onmousemove=function(b){b=e(new a.Point(null!=b?b.clientX:event.clientX,null!=b?b.clientY:event.clientY));a.Mouse.onmousemove(b.x,b.y)});var d=a.CreateElement(b.documentElement);
|
121
|
+
d.root=!0;d.addStylesFromStyleDefinition();var k=!0,f=function(){a.ViewPort.Clear();c.canvas.parentNode&&a.ViewPort.SetCurrent(c.canvas.parentNode.clientWidth,c.canvas.parentNode.clientHeight);1!=a.opts.ignoreDimensions&&(d.style("width").hasValue()&&(c.canvas.width=d.style("width").toPixels("x"),c.canvas.style.width=c.canvas.width+"px"),d.style("height").hasValue()&&(c.canvas.height=d.style("height").toPixels("y"),c.canvas.style.height=c.canvas.height+"px"));var e=c.canvas.clientWidth||c.canvas.width,
|
122
|
+
f=c.canvas.clientHeight||c.canvas.height;1==a.opts.ignoreDimensions&&d.style("width").hasValue()&&d.style("height").hasValue()&&(e=d.style("width").toPixels("x"),f=d.style("height").toPixels("y"));a.ViewPort.SetCurrent(e,f);null!=a.opts.offsetX&&(d.attribute("x",!0).value=a.opts.offsetX);null!=a.opts.offsetY&&(d.attribute("y",!0).value=a.opts.offsetY);if(null!=a.opts.scaleWidth||null!=a.opts.scaleHeight){var g=null,h=null,l=a.ToNumberArray(d.attribute("viewBox").value);null!=a.opts.scaleWidth&&(d.attribute("width").hasValue()?
|
123
|
+
g=d.attribute("width").toPixels("x")/a.opts.scaleWidth:isNaN(l[2])||(g=l[2]/a.opts.scaleWidth));null!=a.opts.scaleHeight&&(d.attribute("height").hasValue()?h=d.attribute("height").toPixels("y")/a.opts.scaleHeight:isNaN(l[3])||(h=l[3]/a.opts.scaleHeight));null==g&&(g=h);null==h&&(h=g);d.attribute("width",!0).value=a.opts.scaleWidth;d.attribute("height",!0).value=a.opts.scaleHeight;d.style("transform",!0,!0).value+=" scale("+1/g+","+1/h+")"}1!=a.opts.ignoreClear&&c.clearRect(0,0,e,f);d.render(c);k&&
|
124
|
+
(k=!1,"function"==typeof a.opts.renderCallback&&a.opts.renderCallback(b))},g=!0;a.ImagesLoaded()&&(g=!1,f());a.intervalID=setInterval(function(){var b=!1;g&&a.ImagesLoaded()&&(g=!1,b=!0);1!=a.opts.ignoreMouse&&(b|=a.Mouse.hasEvents());if(1!=a.opts.ignoreAnimation)for(var c=0;c<a.Animations.length;c++)b|=a.Animations[c].update(1E3/a.FRAMERATE);"function"==typeof a.opts.forceRedraw&&1==a.opts.forceRedraw()&&(b=!0);b&&(f(),a.Mouse.runEvents())},1E3/a.FRAMERATE)};a.stop=function(){a.intervalID&&clearInterval(a.intervalID)};
|
125
|
+
a.Mouse=new function(){this.events=[];this.hasEvents=function(){return 0!=this.events.length};this.onclick=function(a,b){this.events.push({type:"onclick",x:a,y:b,run:function(a){if(a.onclick)a.onclick()}})};this.onmousemove=function(a,b){this.events.push({type:"onmousemove",x:a,y:b,run:function(a){if(a.onmousemove)a.onmousemove()}})};this.eventElements=[];this.checkPath=function(a,b){for(var e=0;e<this.events.length;e++){var d=this.events[e];b.isPointInPath&&b.isPointInPath(d.x,d.y)&&(this.eventElements[e]=
|
126
|
+
a)}};this.checkBoundingBox=function(a,b){for(var e=0;e<this.events.length;e++){var d=this.events[e];b.isPointInBox(d.x,d.y)&&(this.eventElements[e]=a)}};this.runEvents=function(){a.ctx.canvas.style.cursor="";for(var c=0;c<this.events.length;c++)for(var b=this.events[c],e=this.eventElements[c];e;)b.run(e),e=e.parent;this.events=[];this.eventElements=[]}};return a}var z=function(h,a,l){if(null==h&&null==a&&null==l)for(a=document.querySelectorAll("svg"),h=0;h<a.length;h++){l=a[h];var c=document.createElement("canvas");
|
127
|
+
c.width=l.clientWidth;c.height=l.clientHeight;l.parentNode.insertBefore(c,l);l.parentNode.removeChild(l);var b=document.createElement("div");b.appendChild(l);z(c,b.innerHTML)}else{"string"==typeof h&&(h=document.getElementById(h));null!=h.svg&&h.svg.stop();l=I(l||{});if(1!=h.childNodes.length||"OBJECT"!=h.childNodes[0].nodeName)h.svg=l;h=h.getContext("2d");"undefined"!=typeof a.documentElement?l.loadXmlDoc(h,a):"<"==a.substr(0,1)?l.loadXml(h,a):l.load(h,a)}},w;if("undefined"!=typeof Element.prototype.matches)w=
|
128
|
+
function(h,a){return h.matches(a)};else if("undefined"!=typeof Element.prototype.webkitMatchesSelector)w=function(h,a){return h.webkitMatchesSelector(a)};else if("undefined"!=typeof Element.prototype.mozMatchesSelector)w=function(h,a){return h.mozMatchesSelector(a)};else if("undefined"!=typeof Element.prototype.msMatchesSelector)w=function(h,a){return h.msMatchesSelector(a)};else if("undefined"!=typeof Element.prototype.oMatchesSelector)w=function(h,a){return h.oMatchesSelector(a)};else{if("function"===
|
129
|
+
typeof jQuery||"function"===typeof Zepto)w=function(h,a){return $(h).is(a)};"undefined"===typeof w&&(w=Sizzle.matchesSelector)}var B=/(\[[^\]]+\])/g,C=/(#[^\s\+>~\.\[:]+)/g,D=/(\.[^\s\+>~\.\[:]+)/g,E=/(::[^\s\+>~\.\[:]+|:first-line|:first-letter|:before|:after)/gi,F=/(:[\w-]+\([^\)]*\))/gi,G=/(:[^\s\+>~\.\[:]+)/g,H=/([^\s\+>~\.\[:]+)/g;"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.drawSvg=function(h,a,l,c,b){z(this.canvas,h,{ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0,
|
130
|
+
ignoreClear:!0,offsetX:a,offsetY:l,scaleWidth:c,scaleHeight:b})});return z});
|
@@ -0,0 +1,3073 @@
|
|
1
|
+
/** @preserve
|
2
|
+
* canvg.js - Javascript SVG parser and renderer on Canvas
|
3
|
+
* MIT Licensed
|
4
|
+
* Gabe Lerner (gabelerner@gmail.com)
|
5
|
+
* http://code.google.com/p/canvg/
|
6
|
+
*
|
7
|
+
* Requires: rgbcolor.js - http://www.phpied.com/rgb-color-parser-in-javascript/
|
8
|
+
*/
|
9
|
+
(function ( global, factory ) {
|
10
|
+
|
11
|
+
'use strict';
|
12
|
+
|
13
|
+
// export as AMD...
|
14
|
+
if ( typeof define !== 'undefined' && define.amd ) {
|
15
|
+
define('canvgModule', [ 'vendor/assets/javascripts/highstock/lib/rgbcolor', 'stackblur' ], factory );
|
16
|
+
}
|
17
|
+
|
18
|
+
// ...or as browserify
|
19
|
+
else if ( typeof module !== 'undefined' && module.exports ) {
|
20
|
+
module.exports = factory( require( 'vendor/assets/javascripts/highstock/lib/rgbcolor' ), require( 'stackblur' ) );
|
21
|
+
}
|
22
|
+
|
23
|
+
global.canvg = factory( global.RGBColor, global.stackBlur );
|
24
|
+
|
25
|
+
}( typeof window !== 'undefined' ? window : this, function ( RGBColor, stackBlur ) {
|
26
|
+
|
27
|
+
// canvg(target, s)
|
28
|
+
// empty parameters: replace all 'svg' elements on page with 'canvas' elements
|
29
|
+
// target: canvas element or the id of a canvas element
|
30
|
+
// s: svg string, url to svg file, or xml document
|
31
|
+
// opts: optional hash of options
|
32
|
+
// ignoreMouse: true => ignore mouse events
|
33
|
+
// ignoreAnimation: true => ignore animations
|
34
|
+
// ignoreDimensions: true => does not try to resize canvas
|
35
|
+
// ignoreClear: true => does not clear canvas
|
36
|
+
// offsetX: int => draws at a x offset
|
37
|
+
// offsetY: int => draws at a y offset
|
38
|
+
// scaleWidth: int => scales horizontally to width
|
39
|
+
// scaleHeight: int => scales vertically to height
|
40
|
+
// renderCallback: function => will call the function after the first render is completed
|
41
|
+
// forceRedraw: function => will call the function on every frame, if it returns true, will redraw
|
42
|
+
var canvg = function (target, s, opts) {
|
43
|
+
// no parameters
|
44
|
+
if (target == null && s == null && opts == null) {
|
45
|
+
var svgTags = document.querySelectorAll('svg');
|
46
|
+
for (var i=0; i<svgTags.length; i++) {
|
47
|
+
var svgTag = svgTags[i];
|
48
|
+
var c = document.createElement('canvas');
|
49
|
+
c.width = svgTag.clientWidth;
|
50
|
+
c.height = svgTag.clientHeight;
|
51
|
+
svgTag.parentNode.insertBefore(c, svgTag);
|
52
|
+
svgTag.parentNode.removeChild(svgTag);
|
53
|
+
var div = document.createElement('div');
|
54
|
+
div.appendChild(svgTag);
|
55
|
+
canvg(c, div.innerHTML);
|
56
|
+
}
|
57
|
+
return;
|
58
|
+
}
|
59
|
+
|
60
|
+
if (typeof target == 'string') {
|
61
|
+
target = document.getElementById(target);
|
62
|
+
}
|
63
|
+
|
64
|
+
// store class on canvas
|
65
|
+
if (target.svg != null) target.svg.stop();
|
66
|
+
var svg = build(opts || {});
|
67
|
+
// on i.e. 8 for flash canvas, we can't assign the property so check for it
|
68
|
+
if (!(target.childNodes.length == 1 && target.childNodes[0].nodeName == 'OBJECT')) target.svg = svg;
|
69
|
+
|
70
|
+
var ctx = target.getContext('2d');
|
71
|
+
if (typeof(s.documentElement) != 'undefined') {
|
72
|
+
// load from xml doc
|
73
|
+
svg.loadXmlDoc(ctx, s);
|
74
|
+
}
|
75
|
+
else if (s.substr(0,1) == '<') {
|
76
|
+
// load from xml string
|
77
|
+
svg.loadXml(ctx, s);
|
78
|
+
}
|
79
|
+
else {
|
80
|
+
// load from url
|
81
|
+
svg.load(ctx, s);
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
// see https://developer.mozilla.org/en-US/docs/Web/API/Element.matches
|
86
|
+
var matchesSelector;
|
87
|
+
if (typeof(Element.prototype.matches) != 'undefined') {
|
88
|
+
matchesSelector = function(node, selector) {
|
89
|
+
return node.matches(selector);
|
90
|
+
};
|
91
|
+
} else if (typeof(Element.prototype.webkitMatchesSelector) != 'undefined') {
|
92
|
+
matchesSelector = function(node, selector) {
|
93
|
+
return node.webkitMatchesSelector(selector);
|
94
|
+
};
|
95
|
+
} else if (typeof(Element.prototype.mozMatchesSelector) != 'undefined') {
|
96
|
+
matchesSelector = function(node, selector) {
|
97
|
+
return node.mozMatchesSelector(selector);
|
98
|
+
};
|
99
|
+
} else if (typeof(Element.prototype.msMatchesSelector) != 'undefined') {
|
100
|
+
matchesSelector = function(node, selector) {
|
101
|
+
return node.msMatchesSelector(selector);
|
102
|
+
};
|
103
|
+
} else if (typeof(Element.prototype.oMatchesSelector) != 'undefined') {
|
104
|
+
matchesSelector = function(node, selector) {
|
105
|
+
return node.oMatchesSelector(selector);
|
106
|
+
};
|
107
|
+
} else {
|
108
|
+
// requires Sizzle: https://github.com/jquery/sizzle/wiki/Sizzle-Documentation
|
109
|
+
// or jQuery: http://jquery.com/download/
|
110
|
+
// or Zepto: http://zeptojs.com/#
|
111
|
+
// without it, this is a ReferenceError
|
112
|
+
|
113
|
+
if (typeof jQuery === 'function' || typeof Zepto === 'function') {
|
114
|
+
matchesSelector = function (node, selector) {
|
115
|
+
return $(node).is(selector);
|
116
|
+
};
|
117
|
+
}
|
118
|
+
|
119
|
+
if (typeof matchesSelector === 'undefined') {
|
120
|
+
matchesSelector = Sizzle.matchesSelector;
|
121
|
+
}
|
122
|
+
}
|
123
|
+
|
124
|
+
// slightly modified version of https://github.com/keeganstreet/specificity/blob/master/specificity.js
|
125
|
+
var attributeRegex = /(\[[^\]]+\])/g;
|
126
|
+
var idRegex = /(#[^\s\+>~\.\[:]+)/g;
|
127
|
+
var classRegex = /(\.[^\s\+>~\.\[:]+)/g;
|
128
|
+
var pseudoElementRegex = /(::[^\s\+>~\.\[:]+|:first-line|:first-letter|:before|:after)/gi;
|
129
|
+
var pseudoClassWithBracketsRegex = /(:[\w-]+\([^\)]*\))/gi;
|
130
|
+
var pseudoClassRegex = /(:[^\s\+>~\.\[:]+)/g;
|
131
|
+
var elementRegex = /([^\s\+>~\.\[:]+)/g;
|
132
|
+
function getSelectorSpecificity(selector) {
|
133
|
+
var typeCount = [0, 0, 0];
|
134
|
+
var findMatch = function(regex, type) {
|
135
|
+
var matches = selector.match(regex);
|
136
|
+
if (matches == null) {
|
137
|
+
return;
|
138
|
+
}
|
139
|
+
typeCount[type] += matches.length;
|
140
|
+
selector = selector.replace(regex, ' ');
|
141
|
+
};
|
142
|
+
|
143
|
+
selector = selector.replace(/:not\(([^\)]*)\)/g, ' $1 ');
|
144
|
+
selector = selector.replace(/{[^]*/gm, ' ');
|
145
|
+
findMatch(attributeRegex, 1);
|
146
|
+
findMatch(idRegex, 0);
|
147
|
+
findMatch(classRegex, 1);
|
148
|
+
findMatch(pseudoElementRegex, 2);
|
149
|
+
findMatch(pseudoClassWithBracketsRegex, 1);
|
150
|
+
findMatch(pseudoClassRegex, 1);
|
151
|
+
selector = selector.replace(/[\*\s\+>~]/g, ' ');
|
152
|
+
selector = selector.replace(/[#\.]/g, ' ');
|
153
|
+
findMatch(elementRegex, 2);
|
154
|
+
return typeCount.join('');
|
155
|
+
}
|
156
|
+
|
157
|
+
function build(opts) {
|
158
|
+
var svg = { opts: opts };
|
159
|
+
|
160
|
+
svg.FRAMERATE = 30;
|
161
|
+
svg.MAX_VIRTUAL_PIXELS = 30000;
|
162
|
+
|
163
|
+
svg.log = function(msg) {};
|
164
|
+
if (svg.opts['log'] == true && typeof(console) != 'undefined') {
|
165
|
+
svg.log = function(msg) { console.log(msg); };
|
166
|
+
};
|
167
|
+
|
168
|
+
// globals
|
169
|
+
svg.init = function(ctx) {
|
170
|
+
var uniqueId = 0;
|
171
|
+
svg.UniqueId = function () { uniqueId++; return 'canvg' + uniqueId; };
|
172
|
+
svg.Definitions = {};
|
173
|
+
svg.Styles = {};
|
174
|
+
svg.StylesSpecificity = {};
|
175
|
+
svg.Animations = [];
|
176
|
+
svg.Images = [];
|
177
|
+
svg.ctx = ctx;
|
178
|
+
svg.ViewPort = new (function () {
|
179
|
+
this.viewPorts = [];
|
180
|
+
this.Clear = function() { this.viewPorts = []; }
|
181
|
+
this.SetCurrent = function(width, height) { this.viewPorts.push({ width: width, height: height }); }
|
182
|
+
this.RemoveCurrent = function() { this.viewPorts.pop(); }
|
183
|
+
this.Current = function() { return this.viewPorts[this.viewPorts.length - 1]; }
|
184
|
+
this.width = function() { return this.Current().width; }
|
185
|
+
this.height = function() { return this.Current().height; }
|
186
|
+
this.ComputeSize = function(d) {
|
187
|
+
if (d != null && typeof(d) == 'number') return d;
|
188
|
+
if (d == 'x') return this.width();
|
189
|
+
if (d == 'y') return this.height();
|
190
|
+
return Math.sqrt(Math.pow(this.width(), 2) + Math.pow(this.height(), 2)) / Math.sqrt(2);
|
191
|
+
}
|
192
|
+
});
|
193
|
+
}
|
194
|
+
svg.init();
|
195
|
+
|
196
|
+
// images loaded
|
197
|
+
svg.ImagesLoaded = function() {
|
198
|
+
for (var i=0; i<svg.Images.length; i++) {
|
199
|
+
if (!svg.Images[i].loaded) return false;
|
200
|
+
}
|
201
|
+
return true;
|
202
|
+
}
|
203
|
+
|
204
|
+
// trim
|
205
|
+
svg.trim = function(s) { return s.replace(/^\s+|\s+$/g, ''); }
|
206
|
+
|
207
|
+
// compress spaces
|
208
|
+
svg.compressSpaces = function(s) { return s.replace(/[\s\r\t\n]+/gm,' '); }
|
209
|
+
|
210
|
+
// ajax
|
211
|
+
svg.ajax = function(url) {
|
212
|
+
var AJAX;
|
213
|
+
if(window.XMLHttpRequest){AJAX=new XMLHttpRequest();}
|
214
|
+
else{AJAX=new ActiveXObject('Microsoft.XMLHTTP');}
|
215
|
+
if(AJAX){
|
216
|
+
AJAX.open('GET',url,false);
|
217
|
+
AJAX.send(null);
|
218
|
+
return AJAX.responseText;
|
219
|
+
}
|
220
|
+
return null;
|
221
|
+
}
|
222
|
+
|
223
|
+
// parse xml
|
224
|
+
svg.parseXml = function(xml) {
|
225
|
+
if (typeof(Windows) != 'undefined' && typeof(Windows.Data) != 'undefined' && typeof(Windows.Data.Xml) != 'undefined') {
|
226
|
+
var xmlDoc = new Windows.Data.Xml.Dom.XmlDocument();
|
227
|
+
var settings = new Windows.Data.Xml.Dom.XmlLoadSettings();
|
228
|
+
settings.prohibitDtd = false;
|
229
|
+
xmlDoc.loadXml(xml, settings);
|
230
|
+
return xmlDoc;
|
231
|
+
}
|
232
|
+
else if (window.DOMParser)
|
233
|
+
{
|
234
|
+
var parser = new DOMParser();
|
235
|
+
return parser.parseFromString(xml, 'text/xml');
|
236
|
+
}
|
237
|
+
else
|
238
|
+
{
|
239
|
+
xml = xml.replace(/<!DOCTYPE svg[^>]*>/, '');
|
240
|
+
var xmlDoc = new ActiveXObject('Microsoft.XMLDOM');
|
241
|
+
xmlDoc.async = 'false';
|
242
|
+
xmlDoc.loadXML(xml);
|
243
|
+
return xmlDoc;
|
244
|
+
}
|
245
|
+
}
|
246
|
+
|
247
|
+
svg.Property = function(name, value) {
|
248
|
+
this.name = name;
|
249
|
+
this.value = value;
|
250
|
+
}
|
251
|
+
svg.Property.prototype.getValue = function() {
|
252
|
+
return this.value;
|
253
|
+
}
|
254
|
+
|
255
|
+
svg.Property.prototype.hasValue = function() {
|
256
|
+
return (this.value != null && this.value !== '');
|
257
|
+
}
|
258
|
+
|
259
|
+
// return the numerical value of the property
|
260
|
+
svg.Property.prototype.numValue = function() {
|
261
|
+
if (!this.hasValue()) return 0;
|
262
|
+
|
263
|
+
var n = parseFloat(this.value);
|
264
|
+
if ((this.value + '').match(/%$/)) {
|
265
|
+
n = n / 100.0;
|
266
|
+
}
|
267
|
+
return n;
|
268
|
+
}
|
269
|
+
|
270
|
+
svg.Property.prototype.valueOrDefault = function(def) {
|
271
|
+
if (this.hasValue()) return this.value;
|
272
|
+
return def;
|
273
|
+
}
|
274
|
+
|
275
|
+
svg.Property.prototype.numValueOrDefault = function(def) {
|
276
|
+
if (this.hasValue()) return this.numValue();
|
277
|
+
return def;
|
278
|
+
}
|
279
|
+
|
280
|
+
// color extensions
|
281
|
+
// augment the current color value with the opacity
|
282
|
+
svg.Property.prototype.addOpacity = function(opacityProp) {
|
283
|
+
var newValue = this.value;
|
284
|
+
if (opacityProp.value != null && opacityProp.value != '' && typeof(this.value)=='string') { // can only add opacity to colors, not patterns
|
285
|
+
var color = new RGBColor(this.value);
|
286
|
+
if (color.ok) {
|
287
|
+
newValue = 'rgba(' + color.r + ', ' + color.g + ', ' + color.b + ', ' + opacityProp.numValue() + ')';
|
288
|
+
}
|
289
|
+
}
|
290
|
+
return new svg.Property(this.name, newValue);
|
291
|
+
}
|
292
|
+
|
293
|
+
// definition extensions
|
294
|
+
// get the definition from the definitions table
|
295
|
+
svg.Property.prototype.getDefinition = function() {
|
296
|
+
var name = this.value.match(/#([^\)'"]+)/);
|
297
|
+
if (name) { name = name[1]; }
|
298
|
+
if (!name) { name = this.value; }
|
299
|
+
return svg.Definitions[name];
|
300
|
+
}
|
301
|
+
|
302
|
+
svg.Property.prototype.isUrlDefinition = function() {
|
303
|
+
return this.value.indexOf('url(') == 0
|
304
|
+
}
|
305
|
+
|
306
|
+
svg.Property.prototype.getFillStyleDefinition = function(e, opacityProp) {
|
307
|
+
var def = this.getDefinition();
|
308
|
+
|
309
|
+
// gradient
|
310
|
+
if (def != null && def.createGradient) {
|
311
|
+
return def.createGradient(svg.ctx, e, opacityProp);
|
312
|
+
}
|
313
|
+
|
314
|
+
// pattern
|
315
|
+
if (def != null && def.createPattern) {
|
316
|
+
if (def.getHrefAttribute().hasValue()) {
|
317
|
+
var pt = def.attribute('patternTransform');
|
318
|
+
def = def.getHrefAttribute().getDefinition();
|
319
|
+
if (pt.hasValue()) { def.attribute('patternTransform', true).value = pt.value; }
|
320
|
+
}
|
321
|
+
return def.createPattern(svg.ctx, e);
|
322
|
+
}
|
323
|
+
|
324
|
+
return null;
|
325
|
+
}
|
326
|
+
|
327
|
+
// length extensions
|
328
|
+
svg.Property.prototype.getDPI = function(viewPort) {
|
329
|
+
return 96.0; // TODO: compute?
|
330
|
+
}
|
331
|
+
|
332
|
+
svg.Property.prototype.getEM = function(viewPort) {
|
333
|
+
var em = 12;
|
334
|
+
|
335
|
+
var fontSize = new svg.Property('fontSize', svg.Font.Parse(svg.ctx.font).fontSize);
|
336
|
+
if (fontSize.hasValue()) em = fontSize.toPixels(viewPort);
|
337
|
+
|
338
|
+
return em;
|
339
|
+
}
|
340
|
+
|
341
|
+
svg.Property.prototype.getUnits = function() {
|
342
|
+
var s = this.value+'';
|
343
|
+
return s.replace(/[0-9\.\-]/g,'');
|
344
|
+
}
|
345
|
+
|
346
|
+
// get the length as pixels
|
347
|
+
svg.Property.prototype.toPixels = function(viewPort, processPercent) {
|
348
|
+
if (!this.hasValue()) return 0;
|
349
|
+
var s = this.value+'';
|
350
|
+
if (s.match(/em$/)) return this.numValue() * this.getEM(viewPort);
|
351
|
+
if (s.match(/ex$/)) return this.numValue() * this.getEM(viewPort) / 2.0;
|
352
|
+
if (s.match(/px$/)) return this.numValue();
|
353
|
+
if (s.match(/pt$/)) return this.numValue() * this.getDPI(viewPort) * (1.0 / 72.0);
|
354
|
+
if (s.match(/pc$/)) return this.numValue() * 15;
|
355
|
+
if (s.match(/cm$/)) return this.numValue() * this.getDPI(viewPort) / 2.54;
|
356
|
+
if (s.match(/mm$/)) return this.numValue() * this.getDPI(viewPort) / 25.4;
|
357
|
+
if (s.match(/in$/)) return this.numValue() * this.getDPI(viewPort);
|
358
|
+
if (s.match(/%$/)) return this.numValue() * svg.ViewPort.ComputeSize(viewPort);
|
359
|
+
var n = this.numValue();
|
360
|
+
if (processPercent && n < 1.0) return n * svg.ViewPort.ComputeSize(viewPort);
|
361
|
+
return n;
|
362
|
+
}
|
363
|
+
|
364
|
+
// time extensions
|
365
|
+
// get the time as milliseconds
|
366
|
+
svg.Property.prototype.toMilliseconds = function() {
|
367
|
+
if (!this.hasValue()) return 0;
|
368
|
+
var s = this.value+'';
|
369
|
+
if (s.match(/s$/)) return this.numValue() * 1000;
|
370
|
+
if (s.match(/ms$/)) return this.numValue();
|
371
|
+
return this.numValue();
|
372
|
+
}
|
373
|
+
|
374
|
+
// angle extensions
|
375
|
+
// get the angle as radians
|
376
|
+
svg.Property.prototype.toRadians = function() {
|
377
|
+
if (!this.hasValue()) return 0;
|
378
|
+
var s = this.value+'';
|
379
|
+
if (s.match(/deg$/)) return this.numValue() * (Math.PI / 180.0);
|
380
|
+
if (s.match(/grad$/)) return this.numValue() * (Math.PI / 200.0);
|
381
|
+
if (s.match(/rad$/)) return this.numValue();
|
382
|
+
return this.numValue() * (Math.PI / 180.0);
|
383
|
+
}
|
384
|
+
|
385
|
+
// text extensions
|
386
|
+
// get the text baseline
|
387
|
+
var textBaselineMapping = {
|
388
|
+
'baseline': 'alphabetic',
|
389
|
+
'before-edge': 'top',
|
390
|
+
'text-before-edge': 'top',
|
391
|
+
'middle': 'middle',
|
392
|
+
'central': 'middle',
|
393
|
+
'after-edge': 'bottom',
|
394
|
+
'text-after-edge': 'bottom',
|
395
|
+
'ideographic': 'ideographic',
|
396
|
+
'alphabetic': 'alphabetic',
|
397
|
+
'hanging': 'hanging',
|
398
|
+
'mathematical': 'alphabetic'
|
399
|
+
};
|
400
|
+
svg.Property.prototype.toTextBaseline = function () {
|
401
|
+
if (!this.hasValue()) return null;
|
402
|
+
return textBaselineMapping[this.value];
|
403
|
+
}
|
404
|
+
|
405
|
+
// fonts
|
406
|
+
svg.Font = new (function() {
|
407
|
+
this.Styles = 'normal|italic|oblique|inherit';
|
408
|
+
this.Variants = 'normal|small-caps|inherit';
|
409
|
+
this.Weights = 'normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit';
|
410
|
+
|
411
|
+
this.CreateFont = function(fontStyle, fontVariant, fontWeight, fontSize, fontFamily, inherit) {
|
412
|
+
var f = inherit != null ? this.Parse(inherit) : this.CreateFont('', '', '', '', '', svg.ctx.font);
|
413
|
+
return {
|
414
|
+
fontFamily: fontFamily || f.fontFamily,
|
415
|
+
fontSize: fontSize || f.fontSize,
|
416
|
+
fontStyle: fontStyle || f.fontStyle,
|
417
|
+
fontWeight: fontWeight || f.fontWeight,
|
418
|
+
fontVariant: fontVariant || f.fontVariant,
|
419
|
+
toString: function () { return [this.fontStyle, this.fontVariant, this.fontWeight, this.fontSize, this.fontFamily].join(' ') }
|
420
|
+
}
|
421
|
+
}
|
422
|
+
|
423
|
+
var that = this;
|
424
|
+
this.Parse = function(s) {
|
425
|
+
var f = {};
|
426
|
+
var d = svg.trim(svg.compressSpaces(s || '')).split(' ');
|
427
|
+
var set = { fontSize: false, fontStyle: false, fontWeight: false, fontVariant: false }
|
428
|
+
var ff = '';
|
429
|
+
for (var i=0; i<d.length; i++) {
|
430
|
+
if (!set.fontStyle && that.Styles.indexOf(d[i]) != -1) { if (d[i] != 'inherit') f.fontStyle = d[i]; set.fontStyle = true; }
|
431
|
+
else if (!set.fontVariant && that.Variants.indexOf(d[i]) != -1) { if (d[i] != 'inherit') f.fontVariant = d[i]; set.fontStyle = set.fontVariant = true; }
|
432
|
+
else if (!set.fontWeight && that.Weights.indexOf(d[i]) != -1) { if (d[i] != 'inherit') f.fontWeight = d[i]; set.fontStyle = set.fontVariant = set.fontWeight = true; }
|
433
|
+
else if (!set.fontSize) { if (d[i] != 'inherit') f.fontSize = d[i].split('/')[0]; set.fontStyle = set.fontVariant = set.fontWeight = set.fontSize = true; }
|
434
|
+
else { if (d[i] != 'inherit') ff += d[i]; }
|
435
|
+
} if (ff != '') f.fontFamily = ff;
|
436
|
+
return f;
|
437
|
+
}
|
438
|
+
});
|
439
|
+
|
440
|
+
// points and paths
|
441
|
+
svg.ToNumberArray = function(s) {
|
442
|
+
var a = svg.trim(svg.compressSpaces((s || '').replace(/,/g, ' '))).split(' ');
|
443
|
+
for (var i=0; i<a.length; i++) {
|
444
|
+
a[i] = parseFloat(a[i]);
|
445
|
+
}
|
446
|
+
return a;
|
447
|
+
}
|
448
|
+
svg.Point = function(x, y) {
|
449
|
+
this.x = x;
|
450
|
+
this.y = y;
|
451
|
+
}
|
452
|
+
svg.Point.prototype.angleTo = function(p) {
|
453
|
+
return Math.atan2(p.y - this.y, p.x - this.x);
|
454
|
+
}
|
455
|
+
|
456
|
+
svg.Point.prototype.applyTransform = function(v) {
|
457
|
+
var xp = this.x * v[0] + this.y * v[2] + v[4];
|
458
|
+
var yp = this.x * v[1] + this.y * v[3] + v[5];
|
459
|
+
this.x = xp;
|
460
|
+
this.y = yp;
|
461
|
+
}
|
462
|
+
|
463
|
+
svg.CreatePoint = function(s) {
|
464
|
+
var a = svg.ToNumberArray(s);
|
465
|
+
return new svg.Point(a[0], a[1]);
|
466
|
+
}
|
467
|
+
svg.CreatePath = function(s) {
|
468
|
+
var a = svg.ToNumberArray(s);
|
469
|
+
var path = [];
|
470
|
+
for (var i=0; i<a.length; i+=2) {
|
471
|
+
path.push(new svg.Point(a[i], a[i+1]));
|
472
|
+
}
|
473
|
+
return path;
|
474
|
+
}
|
475
|
+
|
476
|
+
// bounding box
|
477
|
+
svg.BoundingBox = function(x1, y1, x2, y2) { // pass in initial points if you want
|
478
|
+
this.x1 = Number.NaN;
|
479
|
+
this.y1 = Number.NaN;
|
480
|
+
this.x2 = Number.NaN;
|
481
|
+
this.y2 = Number.NaN;
|
482
|
+
|
483
|
+
this.x = function() { return this.x1; }
|
484
|
+
this.y = function() { return this.y1; }
|
485
|
+
this.width = function() { return this.x2 - this.x1; }
|
486
|
+
this.height = function() { return this.y2 - this.y1; }
|
487
|
+
|
488
|
+
this.addPoint = function(x, y) {
|
489
|
+
if (x != null) {
|
490
|
+
if (isNaN(this.x1) || isNaN(this.x2)) {
|
491
|
+
this.x1 = x;
|
492
|
+
this.x2 = x;
|
493
|
+
}
|
494
|
+
if (x < this.x1) this.x1 = x;
|
495
|
+
if (x > this.x2) this.x2 = x;
|
496
|
+
}
|
497
|
+
|
498
|
+
if (y != null) {
|
499
|
+
if (isNaN(this.y1) || isNaN(this.y2)) {
|
500
|
+
this.y1 = y;
|
501
|
+
this.y2 = y;
|
502
|
+
}
|
503
|
+
if (y < this.y1) this.y1 = y;
|
504
|
+
if (y > this.y2) this.y2 = y;
|
505
|
+
}
|
506
|
+
}
|
507
|
+
this.addX = function(x) { this.addPoint(x, null); }
|
508
|
+
this.addY = function(y) { this.addPoint(null, y); }
|
509
|
+
|
510
|
+
this.addBoundingBox = function(bb) {
|
511
|
+
this.addPoint(bb.x1, bb.y1);
|
512
|
+
this.addPoint(bb.x2, bb.y2);
|
513
|
+
}
|
514
|
+
|
515
|
+
this.addQuadraticCurve = function(p0x, p0y, p1x, p1y, p2x, p2y) {
|
516
|
+
var cp1x = p0x + 2/3 * (p1x - p0x); // CP1 = QP0 + 2/3 *(QP1-QP0)
|
517
|
+
var cp1y = p0y + 2/3 * (p1y - p0y); // CP1 = QP0 + 2/3 *(QP1-QP0)
|
518
|
+
var cp2x = cp1x + 1/3 * (p2x - p0x); // CP2 = CP1 + 1/3 *(QP2-QP0)
|
519
|
+
var cp2y = cp1y + 1/3 * (p2y - p0y); // CP2 = CP1 + 1/3 *(QP2-QP0)
|
520
|
+
this.addBezierCurve(p0x, p0y, cp1x, cp2x, cp1y, cp2y, p2x, p2y);
|
521
|
+
}
|
522
|
+
|
523
|
+
this.addBezierCurve = function(p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y) {
|
524
|
+
// from http://blog.hackers-cafe.net/2009/06/how-to-calculate-bezier-curves-bounding.html
|
525
|
+
var p0 = [p0x, p0y], p1 = [p1x, p1y], p2 = [p2x, p2y], p3 = [p3x, p3y];
|
526
|
+
this.addPoint(p0[0], p0[1]);
|
527
|
+
this.addPoint(p3[0], p3[1]);
|
528
|
+
|
529
|
+
for (i=0; i<=1; i++) {
|
530
|
+
var f = function(t) {
|
531
|
+
return Math.pow(1-t, 3) * p0[i]
|
532
|
+
+ 3 * Math.pow(1-t, 2) * t * p1[i]
|
533
|
+
+ 3 * (1-t) * Math.pow(t, 2) * p2[i]
|
534
|
+
+ Math.pow(t, 3) * p3[i];
|
535
|
+
}
|
536
|
+
|
537
|
+
var b = 6 * p0[i] - 12 * p1[i] + 6 * p2[i];
|
538
|
+
var a = -3 * p0[i] + 9 * p1[i] - 9 * p2[i] + 3 * p3[i];
|
539
|
+
var c = 3 * p1[i] - 3 * p0[i];
|
540
|
+
|
541
|
+
if (a == 0) {
|
542
|
+
if (b == 0) continue;
|
543
|
+
var t = -c / b;
|
544
|
+
if (0 < t && t < 1) {
|
545
|
+
if (i == 0) this.addX(f(t));
|
546
|
+
if (i == 1) this.addY(f(t));
|
547
|
+
}
|
548
|
+
continue;
|
549
|
+
}
|
550
|
+
|
551
|
+
var b2ac = Math.pow(b, 2) - 4 * c * a;
|
552
|
+
if (b2ac < 0) continue;
|
553
|
+
var t1 = (-b + Math.sqrt(b2ac)) / (2 * a);
|
554
|
+
if (0 < t1 && t1 < 1) {
|
555
|
+
if (i == 0) this.addX(f(t1));
|
556
|
+
if (i == 1) this.addY(f(t1));
|
557
|
+
}
|
558
|
+
var t2 = (-b - Math.sqrt(b2ac)) / (2 * a);
|
559
|
+
if (0 < t2 && t2 < 1) {
|
560
|
+
if (i == 0) this.addX(f(t2));
|
561
|
+
if (i == 1) this.addY(f(t2));
|
562
|
+
}
|
563
|
+
}
|
564
|
+
}
|
565
|
+
|
566
|
+
this.isPointInBox = function(x, y) {
|
567
|
+
return (this.x1 <= x && x <= this.x2 && this.y1 <= y && y <= this.y2);
|
568
|
+
}
|
569
|
+
|
570
|
+
this.addPoint(x1, y1);
|
571
|
+
this.addPoint(x2, y2);
|
572
|
+
}
|
573
|
+
|
574
|
+
// transforms
|
575
|
+
svg.Transform = function(v) {
|
576
|
+
var that = this;
|
577
|
+
this.Type = {}
|
578
|
+
|
579
|
+
// translate
|
580
|
+
this.Type.translate = function(s) {
|
581
|
+
this.p = svg.CreatePoint(s);
|
582
|
+
this.apply = function(ctx) {
|
583
|
+
ctx.translate(this.p.x || 0.0, this.p.y || 0.0);
|
584
|
+
}
|
585
|
+
this.unapply = function(ctx) {
|
586
|
+
ctx.translate(-1.0 * this.p.x || 0.0, -1.0 * this.p.y || 0.0);
|
587
|
+
}
|
588
|
+
this.applyToPoint = function(p) {
|
589
|
+
p.applyTransform([1, 0, 0, 1, this.p.x || 0.0, this.p.y || 0.0]);
|
590
|
+
}
|
591
|
+
}
|
592
|
+
|
593
|
+
// rotate
|
594
|
+
this.Type.rotate = function(s) {
|
595
|
+
var a = svg.ToNumberArray(s);
|
596
|
+
this.angle = new svg.Property('angle', a[0]);
|
597
|
+
this.cx = a[1] || 0;
|
598
|
+
this.cy = a[2] || 0;
|
599
|
+
this.apply = function(ctx) {
|
600
|
+
ctx.translate(this.cx, this.cy);
|
601
|
+
ctx.rotate(this.angle.toRadians());
|
602
|
+
ctx.translate(-this.cx, -this.cy);
|
603
|
+
}
|
604
|
+
this.unapply = function(ctx) {
|
605
|
+
ctx.translate(this.cx, this.cy);
|
606
|
+
ctx.rotate(-1.0 * this.angle.toRadians());
|
607
|
+
ctx.translate(-this.cx, -this.cy);
|
608
|
+
}
|
609
|
+
this.applyToPoint = function(p) {
|
610
|
+
var a = this.angle.toRadians();
|
611
|
+
p.applyTransform([1, 0, 0, 1, this.p.x || 0.0, this.p.y || 0.0]);
|
612
|
+
p.applyTransform([Math.cos(a), Math.sin(a), -Math.sin(a), Math.cos(a), 0, 0]);
|
613
|
+
p.applyTransform([1, 0, 0, 1, -this.p.x || 0.0, -this.p.y || 0.0]);
|
614
|
+
}
|
615
|
+
}
|
616
|
+
|
617
|
+
this.Type.scale = function(s) {
|
618
|
+
this.p = svg.CreatePoint(s);
|
619
|
+
this.apply = function(ctx) {
|
620
|
+
ctx.scale(this.p.x || 1.0, this.p.y || this.p.x || 1.0);
|
621
|
+
}
|
622
|
+
this.unapply = function(ctx) {
|
623
|
+
ctx.scale(1.0 / this.p.x || 1.0, 1.0 / this.p.y || this.p.x || 1.0);
|
624
|
+
}
|
625
|
+
this.applyToPoint = function(p) {
|
626
|
+
p.applyTransform([this.p.x || 0.0, 0, 0, this.p.y || 0.0, 0, 0]);
|
627
|
+
}
|
628
|
+
}
|
629
|
+
|
630
|
+
this.Type.matrix = function(s) {
|
631
|
+
this.m = svg.ToNumberArray(s);
|
632
|
+
this.apply = function(ctx) {
|
633
|
+
ctx.transform(this.m[0], this.m[1], this.m[2], this.m[3], this.m[4], this.m[5]);
|
634
|
+
}
|
635
|
+
this.unapply = function(ctx) {
|
636
|
+
var a = this.m[0];
|
637
|
+
var b = this.m[2];
|
638
|
+
var c = this.m[4];
|
639
|
+
var d = this.m[1];
|
640
|
+
var e = this.m[3];
|
641
|
+
var f = this.m[5];
|
642
|
+
var g = 0.0;
|
643
|
+
var h = 0.0;
|
644
|
+
var i = 1.0;
|
645
|
+
var det = 1 / (a*(e*i-f*h)-b*(d*i-f*g)+c*(d*h-e*g));
|
646
|
+
ctx.transform(
|
647
|
+
det*(e*i-f*h),
|
648
|
+
det*(f*g-d*i),
|
649
|
+
det*(c*h-b*i),
|
650
|
+
det*(a*i-c*g),
|
651
|
+
det*(b*f-c*e),
|
652
|
+
det*(c*d-a*f)
|
653
|
+
);
|
654
|
+
}
|
655
|
+
this.applyToPoint = function(p) {
|
656
|
+
p.applyTransform(this.m);
|
657
|
+
}
|
658
|
+
}
|
659
|
+
|
660
|
+
this.Type.SkewBase = function(s) {
|
661
|
+
this.base = that.Type.matrix;
|
662
|
+
this.base(s);
|
663
|
+
this.angle = new svg.Property('angle', s);
|
664
|
+
}
|
665
|
+
this.Type.SkewBase.prototype = new this.Type.matrix;
|
666
|
+
|
667
|
+
this.Type.skewX = function(s) {
|
668
|
+
this.base = that.Type.SkewBase;
|
669
|
+
this.base(s);
|
670
|
+
this.m = [1, 0, Math.tan(this.angle.toRadians()), 1, 0, 0];
|
671
|
+
}
|
672
|
+
this.Type.skewX.prototype = new this.Type.SkewBase;
|
673
|
+
|
674
|
+
this.Type.skewY = function(s) {
|
675
|
+
this.base = that.Type.SkewBase;
|
676
|
+
this.base(s);
|
677
|
+
this.m = [1, Math.tan(this.angle.toRadians()), 0, 1, 0, 0];
|
678
|
+
}
|
679
|
+
this.Type.skewY.prototype = new this.Type.SkewBase;
|
680
|
+
|
681
|
+
this.transforms = [];
|
682
|
+
|
683
|
+
this.apply = function(ctx) {
|
684
|
+
for (var i=0; i<this.transforms.length; i++) {
|
685
|
+
this.transforms[i].apply(ctx);
|
686
|
+
}
|
687
|
+
}
|
688
|
+
|
689
|
+
this.unapply = function(ctx) {
|
690
|
+
for (var i=this.transforms.length-1; i>=0; i--) {
|
691
|
+
this.transforms[i].unapply(ctx);
|
692
|
+
}
|
693
|
+
}
|
694
|
+
|
695
|
+
this.applyToPoint = function(p) {
|
696
|
+
for (var i=0; i<this.transforms.length; i++) {
|
697
|
+
this.transforms[i].applyToPoint(p);
|
698
|
+
}
|
699
|
+
}
|
700
|
+
|
701
|
+
var data = svg.trim(svg.compressSpaces(v)).replace(/\)([a-zA-Z])/g, ') $1').replace(/\)(\s?,\s?)/g,') ').split(/\s(?=[a-z])/);
|
702
|
+
for (var i=0; i<data.length; i++) {
|
703
|
+
var type = svg.trim(data[i].split('(')[0]);
|
704
|
+
var s = data[i].split('(')[1].replace(')','');
|
705
|
+
var transform = new this.Type[type](s);
|
706
|
+
transform.type = type;
|
707
|
+
this.transforms.push(transform);
|
708
|
+
}
|
709
|
+
}
|
710
|
+
|
711
|
+
// aspect ratio
|
712
|
+
svg.AspectRatio = function(ctx, aspectRatio, width, desiredWidth, height, desiredHeight, minX, minY, refX, refY) {
|
713
|
+
// aspect ratio - http://www.w3.org/TR/SVG/coords.html#PreserveAspectRatioAttribute
|
714
|
+
aspectRatio = svg.compressSpaces(aspectRatio);
|
715
|
+
aspectRatio = aspectRatio.replace(/^defer\s/,''); // ignore defer
|
716
|
+
var align = aspectRatio.split(' ')[0] || 'xMidYMid';
|
717
|
+
var meetOrSlice = aspectRatio.split(' ')[1] || 'meet';
|
718
|
+
|
719
|
+
// calculate scale
|
720
|
+
var scaleX = width / desiredWidth;
|
721
|
+
var scaleY = height / desiredHeight;
|
722
|
+
var scaleMin = Math.min(scaleX, scaleY);
|
723
|
+
var scaleMax = Math.max(scaleX, scaleY);
|
724
|
+
if (meetOrSlice == 'meet') { desiredWidth *= scaleMin; desiredHeight *= scaleMin; }
|
725
|
+
if (meetOrSlice == 'slice') { desiredWidth *= scaleMax; desiredHeight *= scaleMax; }
|
726
|
+
|
727
|
+
refX = new svg.Property('refX', refX);
|
728
|
+
refY = new svg.Property('refY', refY);
|
729
|
+
if (refX.hasValue() && refY.hasValue()) {
|
730
|
+
ctx.translate(-scaleMin * refX.toPixels('x'), -scaleMin * refY.toPixels('y'));
|
731
|
+
}
|
732
|
+
else {
|
733
|
+
// align
|
734
|
+
if (align.match(/^xMid/) && ((meetOrSlice == 'meet' && scaleMin == scaleY) || (meetOrSlice == 'slice' && scaleMax == scaleY))) ctx.translate(width / 2.0 - desiredWidth / 2.0, 0);
|
735
|
+
if (align.match(/YMid$/) && ((meetOrSlice == 'meet' && scaleMin == scaleX) || (meetOrSlice == 'slice' && scaleMax == scaleX))) ctx.translate(0, height / 2.0 - desiredHeight / 2.0);
|
736
|
+
if (align.match(/^xMax/) && ((meetOrSlice == 'meet' && scaleMin == scaleY) || (meetOrSlice == 'slice' && scaleMax == scaleY))) ctx.translate(width - desiredWidth, 0);
|
737
|
+
if (align.match(/YMax$/) && ((meetOrSlice == 'meet' && scaleMin == scaleX) || (meetOrSlice == 'slice' && scaleMax == scaleX))) ctx.translate(0, height - desiredHeight);
|
738
|
+
}
|
739
|
+
|
740
|
+
// scale
|
741
|
+
if (align == 'none') ctx.scale(scaleX, scaleY);
|
742
|
+
else if (meetOrSlice == 'meet') ctx.scale(scaleMin, scaleMin);
|
743
|
+
else if (meetOrSlice == 'slice') ctx.scale(scaleMax, scaleMax);
|
744
|
+
|
745
|
+
// translate
|
746
|
+
ctx.translate(minX == null ? 0 : -minX, minY == null ? 0 : -minY);
|
747
|
+
}
|
748
|
+
|
749
|
+
// elements
|
750
|
+
svg.Element = {}
|
751
|
+
|
752
|
+
svg.EmptyProperty = new svg.Property('EMPTY', '');
|
753
|
+
|
754
|
+
svg.Element.ElementBase = function(node) {
|
755
|
+
this.attributes = {};
|
756
|
+
this.styles = {};
|
757
|
+
this.stylesSpecificity = {};
|
758
|
+
this.children = [];
|
759
|
+
|
760
|
+
// get or create attribute
|
761
|
+
this.attribute = function(name, createIfNotExists) {
|
762
|
+
var a = this.attributes[name];
|
763
|
+
if (a != null) return a;
|
764
|
+
|
765
|
+
if (createIfNotExists == true) { a = new svg.Property(name, ''); this.attributes[name] = a; }
|
766
|
+
return a || svg.EmptyProperty;
|
767
|
+
}
|
768
|
+
|
769
|
+
this.getHrefAttribute = function() {
|
770
|
+
for (var a in this.attributes) {
|
771
|
+
if (a == 'href' || a.match(/:href$/)) {
|
772
|
+
return this.attributes[a];
|
773
|
+
}
|
774
|
+
}
|
775
|
+
return svg.EmptyProperty;
|
776
|
+
}
|
777
|
+
|
778
|
+
// get or create style, crawls up node tree
|
779
|
+
this.style = function(name, createIfNotExists, skipAncestors) {
|
780
|
+
var s = this.styles[name];
|
781
|
+
if (s != null) return s;
|
782
|
+
|
783
|
+
var a = this.attribute(name);
|
784
|
+
if (a != null && a.hasValue()) {
|
785
|
+
this.styles[name] = a; // move up to me to cache
|
786
|
+
return a;
|
787
|
+
}
|
788
|
+
|
789
|
+
if (skipAncestors != true) {
|
790
|
+
var p = this.parent;
|
791
|
+
if (p != null) {
|
792
|
+
var ps = p.style(name);
|
793
|
+
if (ps != null && ps.hasValue()) {
|
794
|
+
return ps;
|
795
|
+
}
|
796
|
+
}
|
797
|
+
}
|
798
|
+
|
799
|
+
if (createIfNotExists == true) { s = new svg.Property(name, ''); this.styles[name] = s; }
|
800
|
+
return s || svg.EmptyProperty;
|
801
|
+
}
|
802
|
+
|
803
|
+
// base render
|
804
|
+
this.render = function(ctx) {
|
805
|
+
// don't render display=none
|
806
|
+
if (this.style('display').value == 'none') return;
|
807
|
+
|
808
|
+
// don't render visibility=hidden
|
809
|
+
if (this.style('visibility').value == 'hidden') return;
|
810
|
+
|
811
|
+
ctx.save();
|
812
|
+
if (this.style('mask').hasValue()) { // mask
|
813
|
+
var mask = this.style('mask').getDefinition();
|
814
|
+
if (mask != null) mask.apply(ctx, this);
|
815
|
+
}
|
816
|
+
else if (this.style('filter').hasValue()) { // filter
|
817
|
+
var filter = this.style('filter').getDefinition();
|
818
|
+
if (filter != null) filter.apply(ctx, this);
|
819
|
+
}
|
820
|
+
else {
|
821
|
+
this.setContext(ctx);
|
822
|
+
this.renderChildren(ctx);
|
823
|
+
this.clearContext(ctx);
|
824
|
+
}
|
825
|
+
ctx.restore();
|
826
|
+
}
|
827
|
+
|
828
|
+
// base set context
|
829
|
+
this.setContext = function(ctx) {
|
830
|
+
// OVERRIDE ME!
|
831
|
+
}
|
832
|
+
|
833
|
+
// base clear context
|
834
|
+
this.clearContext = function(ctx) {
|
835
|
+
// OVERRIDE ME!
|
836
|
+
}
|
837
|
+
|
838
|
+
// base render children
|
839
|
+
this.renderChildren = function(ctx) {
|
840
|
+
for (var i=0; i<this.children.length; i++) {
|
841
|
+
this.children[i].render(ctx);
|
842
|
+
}
|
843
|
+
}
|
844
|
+
|
845
|
+
this.addChild = function(childNode, create) {
|
846
|
+
var child = childNode;
|
847
|
+
if (create) child = svg.CreateElement(childNode);
|
848
|
+
child.parent = this;
|
849
|
+
if (child.type != 'title') { this.children.push(child); }
|
850
|
+
}
|
851
|
+
|
852
|
+
this.addStylesFromStyleDefinition = function () {
|
853
|
+
// add styles
|
854
|
+
for (var selector in svg.Styles) {
|
855
|
+
if (selector[0] != '@' && matchesSelector(node, selector)) {
|
856
|
+
var styles = svg.Styles[selector];
|
857
|
+
var specificity = svg.StylesSpecificity[selector];
|
858
|
+
if (styles != null) {
|
859
|
+
for (var name in styles) {
|
860
|
+
var existingSpecificity = this.stylesSpecificity[name];
|
861
|
+
if (typeof(existingSpecificity) == 'undefined') {
|
862
|
+
existingSpecificity = '000';
|
863
|
+
}
|
864
|
+
if (specificity > existingSpecificity) {
|
865
|
+
this.styles[name] = styles[name];
|
866
|
+
this.stylesSpecificity[name] = specificity;
|
867
|
+
}
|
868
|
+
}
|
869
|
+
}
|
870
|
+
}
|
871
|
+
}
|
872
|
+
};
|
873
|
+
|
874
|
+
if (node != null && node.nodeType == 1) { //ELEMENT_NODE
|
875
|
+
// add attributes
|
876
|
+
for (var i=0; i<node.attributes.length; i++) {
|
877
|
+
var attribute = node.attributes[i];
|
878
|
+
this.attributes[attribute.nodeName] = new svg.Property(attribute.nodeName, attribute.value);
|
879
|
+
}
|
880
|
+
|
881
|
+
this.addStylesFromStyleDefinition();
|
882
|
+
|
883
|
+
// add inline styles
|
884
|
+
if (this.attribute('style').hasValue()) {
|
885
|
+
var styles = this.attribute('style').value.split(';');
|
886
|
+
for (var i=0; i<styles.length; i++) {
|
887
|
+
if (svg.trim(styles[i]) != '') {
|
888
|
+
var style = styles[i].split(':');
|
889
|
+
var name = svg.trim(style[0]);
|
890
|
+
var value = svg.trim(style[1]);
|
891
|
+
this.styles[name] = new svg.Property(name, value);
|
892
|
+
}
|
893
|
+
}
|
894
|
+
}
|
895
|
+
|
896
|
+
// add id
|
897
|
+
if (this.attribute('id').hasValue()) {
|
898
|
+
if (svg.Definitions[this.attribute('id').value] == null) {
|
899
|
+
svg.Definitions[this.attribute('id').value] = this;
|
900
|
+
}
|
901
|
+
}
|
902
|
+
|
903
|
+
// add children
|
904
|
+
for (var i=0; i<node.childNodes.length; i++) {
|
905
|
+
var childNode = node.childNodes[i];
|
906
|
+
if (childNode.nodeType == 1) this.addChild(childNode, true); //ELEMENT_NODE
|
907
|
+
if (this.captureTextNodes && (childNode.nodeType == 3 || childNode.nodeType == 4)) {
|
908
|
+
var text = childNode.value || childNode.text || childNode.textContent || '';
|
909
|
+
if (svg.compressSpaces(text) != '') {
|
910
|
+
this.addChild(new svg.Element.tspan(childNode), false); // TEXT_NODE
|
911
|
+
}
|
912
|
+
}
|
913
|
+
}
|
914
|
+
}
|
915
|
+
}
|
916
|
+
|
917
|
+
svg.Element.RenderedElementBase = function(node) {
|
918
|
+
this.base = svg.Element.ElementBase;
|
919
|
+
this.base(node);
|
920
|
+
|
921
|
+
this.setContext = function(ctx) {
|
922
|
+
// fill
|
923
|
+
if (this.style('fill').isUrlDefinition()) {
|
924
|
+
var fs = this.style('fill').getFillStyleDefinition(this, this.style('fill-opacity'));
|
925
|
+
if (fs != null) ctx.fillStyle = fs;
|
926
|
+
}
|
927
|
+
else if (this.style('fill').hasValue()) {
|
928
|
+
var fillStyle = this.style('fill');
|
929
|
+
if (fillStyle.value == 'currentColor') fillStyle.value = this.style('color').value;
|
930
|
+
if (fillStyle.value != 'inherit') ctx.fillStyle = (fillStyle.value == 'none' ? 'rgba(0,0,0,0)' : fillStyle.value);
|
931
|
+
}
|
932
|
+
if (this.style('fill-opacity').hasValue()) {
|
933
|
+
var fillStyle = new svg.Property('fill', ctx.fillStyle);
|
934
|
+
fillStyle = fillStyle.addOpacity(this.style('fill-opacity'));
|
935
|
+
ctx.fillStyle = fillStyle.value;
|
936
|
+
}
|
937
|
+
|
938
|
+
// stroke
|
939
|
+
if (this.style('stroke').isUrlDefinition()) {
|
940
|
+
var fs = this.style('stroke').getFillStyleDefinition(this, this.style('stroke-opacity'));
|
941
|
+
if (fs != null) ctx.strokeStyle = fs;
|
942
|
+
}
|
943
|
+
else if (this.style('stroke').hasValue()) {
|
944
|
+
var strokeStyle = this.style('stroke');
|
945
|
+
if (strokeStyle.value == 'currentColor') strokeStyle.value = this.style('color').value;
|
946
|
+
if (strokeStyle.value != 'inherit') ctx.strokeStyle = (strokeStyle.value == 'none' ? 'rgba(0,0,0,0)' : strokeStyle.value);
|
947
|
+
}
|
948
|
+
if (this.style('stroke-opacity').hasValue()) {
|
949
|
+
var strokeStyle = new svg.Property('stroke', ctx.strokeStyle);
|
950
|
+
strokeStyle = strokeStyle.addOpacity(this.style('stroke-opacity'));
|
951
|
+
ctx.strokeStyle = strokeStyle.value;
|
952
|
+
}
|
953
|
+
if (this.style('stroke-width').hasValue()) {
|
954
|
+
var newLineWidth = this.style('stroke-width').toPixels();
|
955
|
+
ctx.lineWidth = newLineWidth == 0 ? 0.001 : newLineWidth; // browsers don't respect 0
|
956
|
+
}
|
957
|
+
if (this.style('stroke-linecap').hasValue()) ctx.lineCap = this.style('stroke-linecap').value;
|
958
|
+
if (this.style('stroke-linejoin').hasValue()) ctx.lineJoin = this.style('stroke-linejoin').value;
|
959
|
+
if (this.style('stroke-miterlimit').hasValue()) ctx.miterLimit = this.style('stroke-miterlimit').value;
|
960
|
+
if (this.style('stroke-dasharray').hasValue() && this.style('stroke-dasharray').value != 'none') {
|
961
|
+
var gaps = svg.ToNumberArray(this.style('stroke-dasharray').value);
|
962
|
+
if (typeof(ctx.setLineDash) != 'undefined') { ctx.setLineDash(gaps); }
|
963
|
+
else if (typeof(ctx.webkitLineDash) != 'undefined') { ctx.webkitLineDash = gaps; }
|
964
|
+
else if (typeof(ctx.mozDash) != 'undefined' && !(gaps.length==1 && gaps[0]==0)) { ctx.mozDash = gaps; }
|
965
|
+
|
966
|
+
var offset = this.style('stroke-dashoffset').numValueOrDefault(1);
|
967
|
+
if (typeof(ctx.lineDashOffset) != 'undefined') { ctx.lineDashOffset = offset; }
|
968
|
+
else if (typeof(ctx.webkitLineDashOffset) != 'undefined') { ctx.webkitLineDashOffset = offset; }
|
969
|
+
else if (typeof(ctx.mozDashOffset) != 'undefined') { ctx.mozDashOffset = offset; }
|
970
|
+
}
|
971
|
+
|
972
|
+
// font
|
973
|
+
if (typeof(ctx.font) != 'undefined') {
|
974
|
+
ctx.font = svg.Font.CreateFont(
|
975
|
+
this.style('font-style').value,
|
976
|
+
this.style('font-variant').value,
|
977
|
+
this.style('font-weight').value,
|
978
|
+
this.style('font-size').hasValue() ? this.style('font-size').toPixels() + 'px' : '',
|
979
|
+
this.style('font-family').value).toString();
|
980
|
+
}
|
981
|
+
|
982
|
+
// transform
|
983
|
+
if (this.style('transform', false, true).hasValue()) {
|
984
|
+
var transform = new svg.Transform(this.style('transform', false, true).value);
|
985
|
+
transform.apply(ctx);
|
986
|
+
}
|
987
|
+
|
988
|
+
// clip
|
989
|
+
if (this.style('clip-path', false, true).hasValue()) {
|
990
|
+
var clip = this.style('clip-path', false, true).getDefinition();
|
991
|
+
if (clip != null) clip.apply(ctx);
|
992
|
+
}
|
993
|
+
|
994
|
+
// opacity
|
995
|
+
if (this.style('opacity').hasValue()) {
|
996
|
+
ctx.globalAlpha = this.style('opacity').numValue();
|
997
|
+
}
|
998
|
+
}
|
999
|
+
}
|
1000
|
+
svg.Element.RenderedElementBase.prototype = new svg.Element.ElementBase;
|
1001
|
+
|
1002
|
+
svg.Element.PathElementBase = function(node) {
|
1003
|
+
this.base = svg.Element.RenderedElementBase;
|
1004
|
+
this.base(node);
|
1005
|
+
|
1006
|
+
this.path = function(ctx) {
|
1007
|
+
if (ctx != null) ctx.beginPath();
|
1008
|
+
return new svg.BoundingBox();
|
1009
|
+
}
|
1010
|
+
|
1011
|
+
this.renderChildren = function(ctx) {
|
1012
|
+
this.path(ctx);
|
1013
|
+
svg.Mouse.checkPath(this, ctx);
|
1014
|
+
if (ctx.fillStyle != '') {
|
1015
|
+
if (this.style('fill-rule').valueOrDefault('inherit') != 'inherit') { ctx.fill(this.style('fill-rule').value); }
|
1016
|
+
else { ctx.fill(); }
|
1017
|
+
}
|
1018
|
+
if (ctx.strokeStyle != '') ctx.stroke();
|
1019
|
+
|
1020
|
+
var markers = this.getMarkers();
|
1021
|
+
if (markers != null) {
|
1022
|
+
if (this.style('marker-start').isUrlDefinition()) {
|
1023
|
+
var marker = this.style('marker-start').getDefinition();
|
1024
|
+
marker.render(ctx, markers[0][0], markers[0][1]);
|
1025
|
+
}
|
1026
|
+
if (this.style('marker-mid').isUrlDefinition()) {
|
1027
|
+
var marker = this.style('marker-mid').getDefinition();
|
1028
|
+
for (var i=1;i<markers.length-1;i++) {
|
1029
|
+
marker.render(ctx, markers[i][0], markers[i][1]);
|
1030
|
+
}
|
1031
|
+
}
|
1032
|
+
if (this.style('marker-end').isUrlDefinition()) {
|
1033
|
+
var marker = this.style('marker-end').getDefinition();
|
1034
|
+
marker.render(ctx, markers[markers.length-1][0], markers[markers.length-1][1]);
|
1035
|
+
}
|
1036
|
+
}
|
1037
|
+
}
|
1038
|
+
|
1039
|
+
this.getBoundingBox = function() {
|
1040
|
+
return this.path();
|
1041
|
+
}
|
1042
|
+
|
1043
|
+
this.getMarkers = function() {
|
1044
|
+
return null;
|
1045
|
+
}
|
1046
|
+
}
|
1047
|
+
svg.Element.PathElementBase.prototype = new svg.Element.RenderedElementBase;
|
1048
|
+
|
1049
|
+
// svg element
|
1050
|
+
svg.Element.svg = function(node) {
|
1051
|
+
this.base = svg.Element.RenderedElementBase;
|
1052
|
+
this.base(node);
|
1053
|
+
|
1054
|
+
this.baseClearContext = this.clearContext;
|
1055
|
+
this.clearContext = function(ctx) {
|
1056
|
+
this.baseClearContext(ctx);
|
1057
|
+
svg.ViewPort.RemoveCurrent();
|
1058
|
+
}
|
1059
|
+
|
1060
|
+
this.baseSetContext = this.setContext;
|
1061
|
+
this.setContext = function(ctx) {
|
1062
|
+
// initial values and defaults
|
1063
|
+
ctx.strokeStyle = 'rgba(0,0,0,0)';
|
1064
|
+
ctx.lineCap = 'butt';
|
1065
|
+
ctx.lineJoin = 'miter';
|
1066
|
+
ctx.miterLimit = 4;
|
1067
|
+
if (typeof(ctx.font) != 'undefined' && typeof(window.getComputedStyle) != 'undefined') {
|
1068
|
+
ctx.font = window.getComputedStyle(ctx.canvas).getPropertyValue('font');
|
1069
|
+
}
|
1070
|
+
|
1071
|
+
this.baseSetContext(ctx);
|
1072
|
+
|
1073
|
+
// create new view port
|
1074
|
+
if (!this.attribute('x').hasValue()) this.attribute('x', true).value = 0;
|
1075
|
+
if (!this.attribute('y').hasValue()) this.attribute('y', true).value = 0;
|
1076
|
+
ctx.translate(this.attribute('x').toPixels('x'), this.attribute('y').toPixels('y'));
|
1077
|
+
|
1078
|
+
var width = svg.ViewPort.width();
|
1079
|
+
var height = svg.ViewPort.height();
|
1080
|
+
|
1081
|
+
if (!this.attribute('width').hasValue()) this.attribute('width', true).value = '100%';
|
1082
|
+
if (!this.attribute('height').hasValue()) this.attribute('height', true).value = '100%';
|
1083
|
+
if (typeof(this.root) == 'undefined') {
|
1084
|
+
width = this.attribute('width').toPixels('x');
|
1085
|
+
height = this.attribute('height').toPixels('y');
|
1086
|
+
|
1087
|
+
var x = 0;
|
1088
|
+
var y = 0;
|
1089
|
+
if (this.attribute('refX').hasValue() && this.attribute('refY').hasValue()) {
|
1090
|
+
x = -this.attribute('refX').toPixels('x');
|
1091
|
+
y = -this.attribute('refY').toPixels('y');
|
1092
|
+
}
|
1093
|
+
|
1094
|
+
if (this.attribute('overflow').valueOrDefault('hidden') != 'visible') {
|
1095
|
+
ctx.beginPath();
|
1096
|
+
ctx.moveTo(x, y);
|
1097
|
+
ctx.lineTo(width, y);
|
1098
|
+
ctx.lineTo(width, height);
|
1099
|
+
ctx.lineTo(x, height);
|
1100
|
+
ctx.closePath();
|
1101
|
+
ctx.clip();
|
1102
|
+
}
|
1103
|
+
}
|
1104
|
+
svg.ViewPort.SetCurrent(width, height);
|
1105
|
+
|
1106
|
+
// viewbox
|
1107
|
+
if (this.attribute('viewBox').hasValue()) {
|
1108
|
+
var viewBox = svg.ToNumberArray(this.attribute('viewBox').value);
|
1109
|
+
var minX = viewBox[0];
|
1110
|
+
var minY = viewBox[1];
|
1111
|
+
width = viewBox[2];
|
1112
|
+
height = viewBox[3];
|
1113
|
+
|
1114
|
+
svg.AspectRatio(ctx,
|
1115
|
+
this.attribute('preserveAspectRatio').value,
|
1116
|
+
svg.ViewPort.width(),
|
1117
|
+
width,
|
1118
|
+
svg.ViewPort.height(),
|
1119
|
+
height,
|
1120
|
+
minX,
|
1121
|
+
minY,
|
1122
|
+
this.attribute('refX').value,
|
1123
|
+
this.attribute('refY').value);
|
1124
|
+
|
1125
|
+
svg.ViewPort.RemoveCurrent();
|
1126
|
+
svg.ViewPort.SetCurrent(viewBox[2], viewBox[3]);
|
1127
|
+
}
|
1128
|
+
}
|
1129
|
+
}
|
1130
|
+
svg.Element.svg.prototype = new svg.Element.RenderedElementBase;
|
1131
|
+
|
1132
|
+
// rect element
|
1133
|
+
svg.Element.rect = function(node) {
|
1134
|
+
this.base = svg.Element.PathElementBase;
|
1135
|
+
this.base(node);
|
1136
|
+
|
1137
|
+
this.path = function(ctx) {
|
1138
|
+
var x = this.attribute('x').toPixels('x');
|
1139
|
+
var y = this.attribute('y').toPixels('y');
|
1140
|
+
var width = this.attribute('width').toPixels('x');
|
1141
|
+
var height = this.attribute('height').toPixels('y');
|
1142
|
+
var rx = this.attribute('rx').toPixels('x');
|
1143
|
+
var ry = this.attribute('ry').toPixels('y');
|
1144
|
+
if (this.attribute('rx').hasValue() && !this.attribute('ry').hasValue()) ry = rx;
|
1145
|
+
if (this.attribute('ry').hasValue() && !this.attribute('rx').hasValue()) rx = ry;
|
1146
|
+
rx = Math.min(rx, width / 2.0);
|
1147
|
+
ry = Math.min(ry, height / 2.0);
|
1148
|
+
if (ctx != null) {
|
1149
|
+
ctx.beginPath();
|
1150
|
+
ctx.moveTo(x + rx, y);
|
1151
|
+
ctx.lineTo(x + width - rx, y);
|
1152
|
+
ctx.quadraticCurveTo(x + width, y, x + width, y + ry)
|
1153
|
+
ctx.lineTo(x + width, y + height - ry);
|
1154
|
+
ctx.quadraticCurveTo(x + width, y + height, x + width - rx, y + height)
|
1155
|
+
ctx.lineTo(x + rx, y + height);
|
1156
|
+
ctx.quadraticCurveTo(x, y + height, x, y + height - ry)
|
1157
|
+
ctx.lineTo(x, y + ry);
|
1158
|
+
ctx.quadraticCurveTo(x, y, x + rx, y)
|
1159
|
+
ctx.closePath();
|
1160
|
+
}
|
1161
|
+
|
1162
|
+
return new svg.BoundingBox(x, y, x + width, y + height);
|
1163
|
+
}
|
1164
|
+
}
|
1165
|
+
svg.Element.rect.prototype = new svg.Element.PathElementBase;
|
1166
|
+
|
1167
|
+
// circle element
|
1168
|
+
svg.Element.circle = function(node) {
|
1169
|
+
this.base = svg.Element.PathElementBase;
|
1170
|
+
this.base(node);
|
1171
|
+
|
1172
|
+
this.path = function(ctx) {
|
1173
|
+
var cx = this.attribute('cx').toPixels('x');
|
1174
|
+
var cy = this.attribute('cy').toPixels('y');
|
1175
|
+
var r = this.attribute('r').toPixels();
|
1176
|
+
|
1177
|
+
if (ctx != null) {
|
1178
|
+
ctx.beginPath();
|
1179
|
+
ctx.arc(cx, cy, r, 0, Math.PI * 2, true);
|
1180
|
+
ctx.closePath();
|
1181
|
+
}
|
1182
|
+
|
1183
|
+
return new svg.BoundingBox(cx - r, cy - r, cx + r, cy + r);
|
1184
|
+
}
|
1185
|
+
}
|
1186
|
+
svg.Element.circle.prototype = new svg.Element.PathElementBase;
|
1187
|
+
|
1188
|
+
// ellipse element
|
1189
|
+
svg.Element.ellipse = function(node) {
|
1190
|
+
this.base = svg.Element.PathElementBase;
|
1191
|
+
this.base(node);
|
1192
|
+
|
1193
|
+
this.path = function(ctx) {
|
1194
|
+
var KAPPA = 4 * ((Math.sqrt(2) - 1) / 3);
|
1195
|
+
var rx = this.attribute('rx').toPixels('x');
|
1196
|
+
var ry = this.attribute('ry').toPixels('y');
|
1197
|
+
var cx = this.attribute('cx').toPixels('x');
|
1198
|
+
var cy = this.attribute('cy').toPixels('y');
|
1199
|
+
|
1200
|
+
if (ctx != null) {
|
1201
|
+
ctx.beginPath();
|
1202
|
+
ctx.moveTo(cx, cy - ry);
|
1203
|
+
ctx.bezierCurveTo(cx + (KAPPA * rx), cy - ry, cx + rx, cy - (KAPPA * ry), cx + rx, cy);
|
1204
|
+
ctx.bezierCurveTo(cx + rx, cy + (KAPPA * ry), cx + (KAPPA * rx), cy + ry, cx, cy + ry);
|
1205
|
+
ctx.bezierCurveTo(cx - (KAPPA * rx), cy + ry, cx - rx, cy + (KAPPA * ry), cx - rx, cy);
|
1206
|
+
ctx.bezierCurveTo(cx - rx, cy - (KAPPA * ry), cx - (KAPPA * rx), cy - ry, cx, cy - ry);
|
1207
|
+
ctx.closePath();
|
1208
|
+
}
|
1209
|
+
|
1210
|
+
return new svg.BoundingBox(cx - rx, cy - ry, cx + rx, cy + ry);
|
1211
|
+
}
|
1212
|
+
}
|
1213
|
+
svg.Element.ellipse.prototype = new svg.Element.PathElementBase;
|
1214
|
+
|
1215
|
+
// line element
|
1216
|
+
svg.Element.line = function(node) {
|
1217
|
+
this.base = svg.Element.PathElementBase;
|
1218
|
+
this.base(node);
|
1219
|
+
|
1220
|
+
this.getPoints = function() {
|
1221
|
+
return [
|
1222
|
+
new svg.Point(this.attribute('x1').toPixels('x'), this.attribute('y1').toPixels('y')),
|
1223
|
+
new svg.Point(this.attribute('x2').toPixels('x'), this.attribute('y2').toPixels('y'))];
|
1224
|
+
}
|
1225
|
+
|
1226
|
+
this.path = function(ctx) {
|
1227
|
+
var points = this.getPoints();
|
1228
|
+
|
1229
|
+
if (ctx != null) {
|
1230
|
+
ctx.beginPath();
|
1231
|
+
ctx.moveTo(points[0].x, points[0].y);
|
1232
|
+
ctx.lineTo(points[1].x, points[1].y);
|
1233
|
+
}
|
1234
|
+
|
1235
|
+
return new svg.BoundingBox(points[0].x, points[0].y, points[1].x, points[1].y);
|
1236
|
+
}
|
1237
|
+
|
1238
|
+
this.getMarkers = function() {
|
1239
|
+
var points = this.getPoints();
|
1240
|
+
var a = points[0].angleTo(points[1]);
|
1241
|
+
return [[points[0], a], [points[1], a]];
|
1242
|
+
}
|
1243
|
+
}
|
1244
|
+
svg.Element.line.prototype = new svg.Element.PathElementBase;
|
1245
|
+
|
1246
|
+
// polyline element
|
1247
|
+
svg.Element.polyline = function(node) {
|
1248
|
+
this.base = svg.Element.PathElementBase;
|
1249
|
+
this.base(node);
|
1250
|
+
|
1251
|
+
this.points = svg.CreatePath(this.attribute('points').value);
|
1252
|
+
this.path = function(ctx) {
|
1253
|
+
var bb = new svg.BoundingBox(this.points[0].x, this.points[0].y);
|
1254
|
+
if (ctx != null) {
|
1255
|
+
ctx.beginPath();
|
1256
|
+
ctx.moveTo(this.points[0].x, this.points[0].y);
|
1257
|
+
}
|
1258
|
+
for (var i=1; i<this.points.length; i++) {
|
1259
|
+
bb.addPoint(this.points[i].x, this.points[i].y);
|
1260
|
+
if (ctx != null) ctx.lineTo(this.points[i].x, this.points[i].y);
|
1261
|
+
}
|
1262
|
+
return bb;
|
1263
|
+
}
|
1264
|
+
|
1265
|
+
this.getMarkers = function() {
|
1266
|
+
var markers = [];
|
1267
|
+
for (var i=0; i<this.points.length - 1; i++) {
|
1268
|
+
markers.push([this.points[i], this.points[i].angleTo(this.points[i+1])]);
|
1269
|
+
}
|
1270
|
+
markers.push([this.points[this.points.length-1], markers[markers.length-1][1]]);
|
1271
|
+
return markers;
|
1272
|
+
}
|
1273
|
+
}
|
1274
|
+
svg.Element.polyline.prototype = new svg.Element.PathElementBase;
|
1275
|
+
|
1276
|
+
// polygon element
|
1277
|
+
svg.Element.polygon = function(node) {
|
1278
|
+
this.base = svg.Element.polyline;
|
1279
|
+
this.base(node);
|
1280
|
+
|
1281
|
+
this.basePath = this.path;
|
1282
|
+
this.path = function(ctx) {
|
1283
|
+
var bb = this.basePath(ctx);
|
1284
|
+
if (ctx != null) {
|
1285
|
+
ctx.lineTo(this.points[0].x, this.points[0].y);
|
1286
|
+
ctx.closePath();
|
1287
|
+
}
|
1288
|
+
return bb;
|
1289
|
+
}
|
1290
|
+
}
|
1291
|
+
svg.Element.polygon.prototype = new svg.Element.polyline;
|
1292
|
+
|
1293
|
+
// path element
|
1294
|
+
svg.Element.path = function(node) {
|
1295
|
+
this.base = svg.Element.PathElementBase;
|
1296
|
+
this.base(node);
|
1297
|
+
|
1298
|
+
var d = this.attribute('d').value;
|
1299
|
+
// TODO: convert to real lexer based on http://www.w3.org/TR/SVG11/paths.html#PathDataBNF
|
1300
|
+
d = d.replace(/,/gm,' '); // get rid of all commas
|
1301
|
+
// As the end of a match can also be the start of the next match, we need to run this replace twice.
|
1302
|
+
for(var i=0; i<2; i++)
|
1303
|
+
d = d.replace(/([MmZzLlHhVvCcSsQqTtAa])([^\s])/gm,'$1 $2'); // suffix commands with spaces
|
1304
|
+
d = d.replace(/([^\s])([MmZzLlHhVvCcSsQqTtAa])/gm,'$1 $2'); // prefix commands with spaces
|
1305
|
+
d = d.replace(/([0-9])([+\-])/gm,'$1 $2'); // separate digits on +- signs
|
1306
|
+
// Again, we need to run this twice to find all occurances
|
1307
|
+
for(var i=0; i<2; i++)
|
1308
|
+
d = d.replace(/(\.[0-9]*)(\.)/gm,'$1 $2'); // separate digits when they start with a comma
|
1309
|
+
d = d.replace(/([Aa](\s+[0-9]+){3})\s+([01])\s*([01])/gm,'$1 $3 $4 '); // shorthand elliptical arc path syntax
|
1310
|
+
d = svg.compressSpaces(d); // compress multiple spaces
|
1311
|
+
d = svg.trim(d);
|
1312
|
+
this.PathParser = new (function(d) {
|
1313
|
+
this.tokens = d.split(' ');
|
1314
|
+
|
1315
|
+
this.reset = function() {
|
1316
|
+
this.i = -1;
|
1317
|
+
this.command = '';
|
1318
|
+
this.previousCommand = '';
|
1319
|
+
this.start = new svg.Point(0, 0);
|
1320
|
+
this.control = new svg.Point(0, 0);
|
1321
|
+
this.current = new svg.Point(0, 0);
|
1322
|
+
this.points = [];
|
1323
|
+
this.angles = [];
|
1324
|
+
}
|
1325
|
+
|
1326
|
+
this.isEnd = function() {
|
1327
|
+
return this.i >= this.tokens.length - 1;
|
1328
|
+
}
|
1329
|
+
|
1330
|
+
this.isCommandOrEnd = function() {
|
1331
|
+
if (this.isEnd()) return true;
|
1332
|
+
return this.tokens[this.i + 1].match(/^[A-Za-z]$/) != null;
|
1333
|
+
}
|
1334
|
+
|
1335
|
+
this.isRelativeCommand = function() {
|
1336
|
+
switch(this.command)
|
1337
|
+
{
|
1338
|
+
case 'm':
|
1339
|
+
case 'l':
|
1340
|
+
case 'h':
|
1341
|
+
case 'v':
|
1342
|
+
case 'c':
|
1343
|
+
case 's':
|
1344
|
+
case 'q':
|
1345
|
+
case 't':
|
1346
|
+
case 'a':
|
1347
|
+
case 'z':
|
1348
|
+
return true;
|
1349
|
+
break;
|
1350
|
+
}
|
1351
|
+
return false;
|
1352
|
+
}
|
1353
|
+
|
1354
|
+
this.getToken = function() {
|
1355
|
+
this.i++;
|
1356
|
+
return this.tokens[this.i];
|
1357
|
+
}
|
1358
|
+
|
1359
|
+
this.getScalar = function() {
|
1360
|
+
return parseFloat(this.getToken());
|
1361
|
+
}
|
1362
|
+
|
1363
|
+
this.nextCommand = function() {
|
1364
|
+
this.previousCommand = this.command;
|
1365
|
+
this.command = this.getToken();
|
1366
|
+
}
|
1367
|
+
|
1368
|
+
this.getPoint = function() {
|
1369
|
+
var p = new svg.Point(this.getScalar(), this.getScalar());
|
1370
|
+
return this.makeAbsolute(p);
|
1371
|
+
}
|
1372
|
+
|
1373
|
+
this.getAsControlPoint = function() {
|
1374
|
+
var p = this.getPoint();
|
1375
|
+
this.control = p;
|
1376
|
+
return p;
|
1377
|
+
}
|
1378
|
+
|
1379
|
+
this.getAsCurrentPoint = function() {
|
1380
|
+
var p = this.getPoint();
|
1381
|
+
this.current = p;
|
1382
|
+
return p;
|
1383
|
+
}
|
1384
|
+
|
1385
|
+
this.getReflectedControlPoint = function() {
|
1386
|
+
if (this.previousCommand.toLowerCase() != 'c' &&
|
1387
|
+
this.previousCommand.toLowerCase() != 's' &&
|
1388
|
+
this.previousCommand.toLowerCase() != 'q' &&
|
1389
|
+
this.previousCommand.toLowerCase() != 't' ){
|
1390
|
+
return this.current;
|
1391
|
+
}
|
1392
|
+
|
1393
|
+
// reflect point
|
1394
|
+
var p = new svg.Point(2 * this.current.x - this.control.x, 2 * this.current.y - this.control.y);
|
1395
|
+
return p;
|
1396
|
+
}
|
1397
|
+
|
1398
|
+
this.makeAbsolute = function(p) {
|
1399
|
+
if (this.isRelativeCommand()) {
|
1400
|
+
p.x += this.current.x;
|
1401
|
+
p.y += this.current.y;
|
1402
|
+
}
|
1403
|
+
return p;
|
1404
|
+
}
|
1405
|
+
|
1406
|
+
this.addMarker = function(p, from, priorTo) {
|
1407
|
+
// if the last angle isn't filled in because we didn't have this point yet ...
|
1408
|
+
if (priorTo != null && this.angles.length > 0 && this.angles[this.angles.length-1] == null) {
|
1409
|
+
this.angles[this.angles.length-1] = this.points[this.points.length-1].angleTo(priorTo);
|
1410
|
+
}
|
1411
|
+
this.addMarkerAngle(p, from == null ? null : from.angleTo(p));
|
1412
|
+
}
|
1413
|
+
|
1414
|
+
this.addMarkerAngle = function(p, a) {
|
1415
|
+
this.points.push(p);
|
1416
|
+
this.angles.push(a);
|
1417
|
+
}
|
1418
|
+
|
1419
|
+
this.getMarkerPoints = function() { return this.points; }
|
1420
|
+
this.getMarkerAngles = function() {
|
1421
|
+
for (var i=0; i<this.angles.length; i++) {
|
1422
|
+
if (this.angles[i] == null) {
|
1423
|
+
for (var j=i+1; j<this.angles.length; j++) {
|
1424
|
+
if (this.angles[j] != null) {
|
1425
|
+
this.angles[i] = this.angles[j];
|
1426
|
+
break;
|
1427
|
+
}
|
1428
|
+
}
|
1429
|
+
}
|
1430
|
+
}
|
1431
|
+
return this.angles;
|
1432
|
+
}
|
1433
|
+
})(d);
|
1434
|
+
|
1435
|
+
this.path = function(ctx) {
|
1436
|
+
var pp = this.PathParser;
|
1437
|
+
pp.reset();
|
1438
|
+
|
1439
|
+
var bb = new svg.BoundingBox();
|
1440
|
+
if (ctx != null) ctx.beginPath();
|
1441
|
+
while (!pp.isEnd()) {
|
1442
|
+
pp.nextCommand();
|
1443
|
+
switch (pp.command) {
|
1444
|
+
case 'M':
|
1445
|
+
case 'm':
|
1446
|
+
var p = pp.getAsCurrentPoint();
|
1447
|
+
pp.addMarker(p);
|
1448
|
+
bb.addPoint(p.x, p.y);
|
1449
|
+
if (ctx != null) ctx.moveTo(p.x, p.y);
|
1450
|
+
pp.start = pp.current;
|
1451
|
+
while (!pp.isCommandOrEnd()) {
|
1452
|
+
var p = pp.getAsCurrentPoint();
|
1453
|
+
pp.addMarker(p, pp.start);
|
1454
|
+
bb.addPoint(p.x, p.y);
|
1455
|
+
if (ctx != null) ctx.lineTo(p.x, p.y);
|
1456
|
+
}
|
1457
|
+
break;
|
1458
|
+
case 'L':
|
1459
|
+
case 'l':
|
1460
|
+
while (!pp.isCommandOrEnd()) {
|
1461
|
+
var c = pp.current;
|
1462
|
+
var p = pp.getAsCurrentPoint();
|
1463
|
+
pp.addMarker(p, c);
|
1464
|
+
bb.addPoint(p.x, p.y);
|
1465
|
+
if (ctx != null) ctx.lineTo(p.x, p.y);
|
1466
|
+
}
|
1467
|
+
break;
|
1468
|
+
case 'H':
|
1469
|
+
case 'h':
|
1470
|
+
while (!pp.isCommandOrEnd()) {
|
1471
|
+
var newP = new svg.Point((pp.isRelativeCommand() ? pp.current.x : 0) + pp.getScalar(), pp.current.y);
|
1472
|
+
pp.addMarker(newP, pp.current);
|
1473
|
+
pp.current = newP;
|
1474
|
+
bb.addPoint(pp.current.x, pp.current.y);
|
1475
|
+
if (ctx != null) ctx.lineTo(pp.current.x, pp.current.y);
|
1476
|
+
}
|
1477
|
+
break;
|
1478
|
+
case 'V':
|
1479
|
+
case 'v':
|
1480
|
+
while (!pp.isCommandOrEnd()) {
|
1481
|
+
var newP = new svg.Point(pp.current.x, (pp.isRelativeCommand() ? pp.current.y : 0) + pp.getScalar());
|
1482
|
+
pp.addMarker(newP, pp.current);
|
1483
|
+
pp.current = newP;
|
1484
|
+
bb.addPoint(pp.current.x, pp.current.y);
|
1485
|
+
if (ctx != null) ctx.lineTo(pp.current.x, pp.current.y);
|
1486
|
+
}
|
1487
|
+
break;
|
1488
|
+
case 'C':
|
1489
|
+
case 'c':
|
1490
|
+
while (!pp.isCommandOrEnd()) {
|
1491
|
+
var curr = pp.current;
|
1492
|
+
var p1 = pp.getPoint();
|
1493
|
+
var cntrl = pp.getAsControlPoint();
|
1494
|
+
var cp = pp.getAsCurrentPoint();
|
1495
|
+
pp.addMarker(cp, cntrl, p1);
|
1496
|
+
bb.addBezierCurve(curr.x, curr.y, p1.x, p1.y, cntrl.x, cntrl.y, cp.x, cp.y);
|
1497
|
+
if (ctx != null) ctx.bezierCurveTo(p1.x, p1.y, cntrl.x, cntrl.y, cp.x, cp.y);
|
1498
|
+
}
|
1499
|
+
break;
|
1500
|
+
case 'S':
|
1501
|
+
case 's':
|
1502
|
+
while (!pp.isCommandOrEnd()) {
|
1503
|
+
var curr = pp.current;
|
1504
|
+
var p1 = pp.getReflectedControlPoint();
|
1505
|
+
var cntrl = pp.getAsControlPoint();
|
1506
|
+
var cp = pp.getAsCurrentPoint();
|
1507
|
+
pp.addMarker(cp, cntrl, p1);
|
1508
|
+
bb.addBezierCurve(curr.x, curr.y, p1.x, p1.y, cntrl.x, cntrl.y, cp.x, cp.y);
|
1509
|
+
if (ctx != null) ctx.bezierCurveTo(p1.x, p1.y, cntrl.x, cntrl.y, cp.x, cp.y);
|
1510
|
+
}
|
1511
|
+
break;
|
1512
|
+
case 'Q':
|
1513
|
+
case 'q':
|
1514
|
+
while (!pp.isCommandOrEnd()) {
|
1515
|
+
var curr = pp.current;
|
1516
|
+
var cntrl = pp.getAsControlPoint();
|
1517
|
+
var cp = pp.getAsCurrentPoint();
|
1518
|
+
pp.addMarker(cp, cntrl, cntrl);
|
1519
|
+
bb.addQuadraticCurve(curr.x, curr.y, cntrl.x, cntrl.y, cp.x, cp.y);
|
1520
|
+
if (ctx != null) ctx.quadraticCurveTo(cntrl.x, cntrl.y, cp.x, cp.y);
|
1521
|
+
}
|
1522
|
+
break;
|
1523
|
+
case 'T':
|
1524
|
+
case 't':
|
1525
|
+
while (!pp.isCommandOrEnd()) {
|
1526
|
+
var curr = pp.current;
|
1527
|
+
var cntrl = pp.getReflectedControlPoint();
|
1528
|
+
pp.control = cntrl;
|
1529
|
+
var cp = pp.getAsCurrentPoint();
|
1530
|
+
pp.addMarker(cp, cntrl, cntrl);
|
1531
|
+
bb.addQuadraticCurve(curr.x, curr.y, cntrl.x, cntrl.y, cp.x, cp.y);
|
1532
|
+
if (ctx != null) ctx.quadraticCurveTo(cntrl.x, cntrl.y, cp.x, cp.y);
|
1533
|
+
}
|
1534
|
+
break;
|
1535
|
+
case 'A':
|
1536
|
+
case 'a':
|
1537
|
+
while (!pp.isCommandOrEnd()) {
|
1538
|
+
var curr = pp.current;
|
1539
|
+
var rx = pp.getScalar();
|
1540
|
+
var ry = pp.getScalar();
|
1541
|
+
var xAxisRotation = pp.getScalar() * (Math.PI / 180.0);
|
1542
|
+
var largeArcFlag = pp.getScalar();
|
1543
|
+
var sweepFlag = pp.getScalar();
|
1544
|
+
var cp = pp.getAsCurrentPoint();
|
1545
|
+
|
1546
|
+
// Conversion from endpoint to center parameterization
|
1547
|
+
// http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
|
1548
|
+
// x1', y1'
|
1549
|
+
var currp = new svg.Point(
|
1550
|
+
Math.cos(xAxisRotation) * (curr.x - cp.x) / 2.0 + Math.sin(xAxisRotation) * (curr.y - cp.y) / 2.0,
|
1551
|
+
-Math.sin(xAxisRotation) * (curr.x - cp.x) / 2.0 + Math.cos(xAxisRotation) * (curr.y - cp.y) / 2.0
|
1552
|
+
);
|
1553
|
+
// adjust radii
|
1554
|
+
var l = Math.pow(currp.x,2)/Math.pow(rx,2)+Math.pow(currp.y,2)/Math.pow(ry,2);
|
1555
|
+
if (l > 1) {
|
1556
|
+
rx *= Math.sqrt(l);
|
1557
|
+
ry *= Math.sqrt(l);
|
1558
|
+
}
|
1559
|
+
// cx', cy'
|
1560
|
+
var s = (largeArcFlag == sweepFlag ? -1 : 1) * Math.sqrt(
|
1561
|
+
((Math.pow(rx,2)*Math.pow(ry,2))-(Math.pow(rx,2)*Math.pow(currp.y,2))-(Math.pow(ry,2)*Math.pow(currp.x,2))) /
|
1562
|
+
(Math.pow(rx,2)*Math.pow(currp.y,2)+Math.pow(ry,2)*Math.pow(currp.x,2))
|
1563
|
+
);
|
1564
|
+
if (isNaN(s)) s = 0;
|
1565
|
+
var cpp = new svg.Point(s * rx * currp.y / ry, s * -ry * currp.x / rx);
|
1566
|
+
// cx, cy
|
1567
|
+
var centp = new svg.Point(
|
1568
|
+
(curr.x + cp.x) / 2.0 + Math.cos(xAxisRotation) * cpp.x - Math.sin(xAxisRotation) * cpp.y,
|
1569
|
+
(curr.y + cp.y) / 2.0 + Math.sin(xAxisRotation) * cpp.x + Math.cos(xAxisRotation) * cpp.y
|
1570
|
+
);
|
1571
|
+
// vector magnitude
|
1572
|
+
var m = function(v) { return Math.sqrt(Math.pow(v[0],2) + Math.pow(v[1],2)); }
|
1573
|
+
// ratio between two vectors
|
1574
|
+
var r = function(u, v) { return (u[0]*v[0]+u[1]*v[1]) / (m(u)*m(v)) }
|
1575
|
+
// angle between two vectors
|
1576
|
+
var a = function(u, v) { return (u[0]*v[1] < u[1]*v[0] ? -1 : 1) * Math.acos(r(u,v)); }
|
1577
|
+
// initial angle
|
1578
|
+
var a1 = a([1,0], [(currp.x-cpp.x)/rx,(currp.y-cpp.y)/ry]);
|
1579
|
+
// angle delta
|
1580
|
+
var u = [(currp.x-cpp.x)/rx,(currp.y-cpp.y)/ry];
|
1581
|
+
var v = [(-currp.x-cpp.x)/rx,(-currp.y-cpp.y)/ry];
|
1582
|
+
var ad = a(u, v);
|
1583
|
+
if (r(u,v) <= -1) ad = Math.PI;
|
1584
|
+
if (r(u,v) >= 1) ad = 0;
|
1585
|
+
|
1586
|
+
// for markers
|
1587
|
+
var dir = 1 - sweepFlag ? 1.0 : -1.0;
|
1588
|
+
var ah = a1 + dir * (ad / 2.0);
|
1589
|
+
var halfWay = new svg.Point(
|
1590
|
+
centp.x + rx * Math.cos(ah),
|
1591
|
+
centp.y + ry * Math.sin(ah)
|
1592
|
+
);
|
1593
|
+
pp.addMarkerAngle(halfWay, ah - dir * Math.PI / 2);
|
1594
|
+
pp.addMarkerAngle(cp, ah - dir * Math.PI);
|
1595
|
+
|
1596
|
+
bb.addPoint(cp.x, cp.y); // TODO: this is too naive, make it better
|
1597
|
+
if (ctx != null) {
|
1598
|
+
var r = rx > ry ? rx : ry;
|
1599
|
+
var sx = rx > ry ? 1 : rx / ry;
|
1600
|
+
var sy = rx > ry ? ry / rx : 1;
|
1601
|
+
|
1602
|
+
ctx.translate(centp.x, centp.y);
|
1603
|
+
ctx.rotate(xAxisRotation);
|
1604
|
+
ctx.scale(sx, sy);
|
1605
|
+
ctx.arc(0, 0, r, a1, a1 + ad, 1 - sweepFlag);
|
1606
|
+
ctx.scale(1/sx, 1/sy);
|
1607
|
+
ctx.rotate(-xAxisRotation);
|
1608
|
+
ctx.translate(-centp.x, -centp.y);
|
1609
|
+
}
|
1610
|
+
}
|
1611
|
+
break;
|
1612
|
+
case 'Z':
|
1613
|
+
case 'z':
|
1614
|
+
if (ctx != null) ctx.closePath();
|
1615
|
+
pp.current = pp.start;
|
1616
|
+
}
|
1617
|
+
}
|
1618
|
+
|
1619
|
+
return bb;
|
1620
|
+
}
|
1621
|
+
|
1622
|
+
this.getMarkers = function() {
|
1623
|
+
var points = this.PathParser.getMarkerPoints();
|
1624
|
+
var angles = this.PathParser.getMarkerAngles();
|
1625
|
+
|
1626
|
+
var markers = [];
|
1627
|
+
for (var i=0; i<points.length; i++) {
|
1628
|
+
markers.push([points[i], angles[i]]);
|
1629
|
+
}
|
1630
|
+
return markers;
|
1631
|
+
}
|
1632
|
+
}
|
1633
|
+
svg.Element.path.prototype = new svg.Element.PathElementBase;
|
1634
|
+
|
1635
|
+
// pattern element
|
1636
|
+
svg.Element.pattern = function(node) {
|
1637
|
+
this.base = svg.Element.ElementBase;
|
1638
|
+
this.base(node);
|
1639
|
+
|
1640
|
+
this.createPattern = function(ctx, element) {
|
1641
|
+
var width = this.attribute('width').toPixels('x', true);
|
1642
|
+
var height = this.attribute('height').toPixels('y', true);
|
1643
|
+
|
1644
|
+
// render me using a temporary svg element
|
1645
|
+
var tempSvg = new svg.Element.svg();
|
1646
|
+
tempSvg.attributes['viewBox'] = new svg.Property('viewBox', this.attribute('viewBox').value);
|
1647
|
+
tempSvg.attributes['width'] = new svg.Property('width', width + 'px');
|
1648
|
+
tempSvg.attributes['height'] = new svg.Property('height', height + 'px');
|
1649
|
+
tempSvg.attributes['transform'] = new svg.Property('transform', this.attribute('patternTransform').value);
|
1650
|
+
tempSvg.children = this.children;
|
1651
|
+
|
1652
|
+
var c = document.createElement('canvas');
|
1653
|
+
c.width = width;
|
1654
|
+
c.height = height;
|
1655
|
+
var cctx = c.getContext('2d');
|
1656
|
+
if (this.attribute('x').hasValue() && this.attribute('y').hasValue()) {
|
1657
|
+
cctx.translate(this.attribute('x').toPixels('x', true), this.attribute('y').toPixels('y', true));
|
1658
|
+
}
|
1659
|
+
// render 3x3 grid so when we transform there's no white space on edges
|
1660
|
+
for (var x=-1; x<=1; x++) {
|
1661
|
+
for (var y=-1; y<=1; y++) {
|
1662
|
+
cctx.save();
|
1663
|
+
tempSvg.attributes['x'] = new svg.Property('x', x * c.width);
|
1664
|
+
tempSvg.attributes['y'] = new svg.Property('y', y * c.height);
|
1665
|
+
tempSvg.render(cctx);
|
1666
|
+
cctx.restore();
|
1667
|
+
}
|
1668
|
+
}
|
1669
|
+
var pattern = ctx.createPattern(c, 'repeat');
|
1670
|
+
return pattern;
|
1671
|
+
}
|
1672
|
+
}
|
1673
|
+
svg.Element.pattern.prototype = new svg.Element.ElementBase;
|
1674
|
+
|
1675
|
+
// marker element
|
1676
|
+
svg.Element.marker = function(node) {
|
1677
|
+
this.base = svg.Element.ElementBase;
|
1678
|
+
this.base(node);
|
1679
|
+
|
1680
|
+
this.baseRender = this.render;
|
1681
|
+
this.render = function(ctx, point, angle) {
|
1682
|
+
ctx.translate(point.x, point.y);
|
1683
|
+
if (this.attribute('orient').valueOrDefault('auto') == 'auto') ctx.rotate(angle);
|
1684
|
+
if (this.attribute('markerUnits').valueOrDefault('strokeWidth') == 'strokeWidth') ctx.scale(ctx.lineWidth, ctx.lineWidth);
|
1685
|
+
ctx.save();
|
1686
|
+
|
1687
|
+
// render me using a temporary svg element
|
1688
|
+
var tempSvg = new svg.Element.svg();
|
1689
|
+
tempSvg.attributes['viewBox'] = new svg.Property('viewBox', this.attribute('viewBox').value);
|
1690
|
+
tempSvg.attributes['refX'] = new svg.Property('refX', this.attribute('refX').value);
|
1691
|
+
tempSvg.attributes['refY'] = new svg.Property('refY', this.attribute('refY').value);
|
1692
|
+
tempSvg.attributes['width'] = new svg.Property('width', this.attribute('markerWidth').value);
|
1693
|
+
tempSvg.attributes['height'] = new svg.Property('height', this.attribute('markerHeight').value);
|
1694
|
+
tempSvg.attributes['fill'] = new svg.Property('fill', this.attribute('fill').valueOrDefault('black'));
|
1695
|
+
tempSvg.attributes['stroke'] = new svg.Property('stroke', this.attribute('stroke').valueOrDefault('none'));
|
1696
|
+
tempSvg.children = this.children;
|
1697
|
+
tempSvg.render(ctx);
|
1698
|
+
|
1699
|
+
ctx.restore();
|
1700
|
+
if (this.attribute('markerUnits').valueOrDefault('strokeWidth') == 'strokeWidth') ctx.scale(1/ctx.lineWidth, 1/ctx.lineWidth);
|
1701
|
+
if (this.attribute('orient').valueOrDefault('auto') == 'auto') ctx.rotate(-angle);
|
1702
|
+
ctx.translate(-point.x, -point.y);
|
1703
|
+
}
|
1704
|
+
}
|
1705
|
+
svg.Element.marker.prototype = new svg.Element.ElementBase;
|
1706
|
+
|
1707
|
+
// definitions element
|
1708
|
+
svg.Element.defs = function(node) {
|
1709
|
+
this.base = svg.Element.ElementBase;
|
1710
|
+
this.base(node);
|
1711
|
+
|
1712
|
+
this.render = function(ctx) {
|
1713
|
+
// NOOP
|
1714
|
+
}
|
1715
|
+
}
|
1716
|
+
svg.Element.defs.prototype = new svg.Element.ElementBase;
|
1717
|
+
|
1718
|
+
// base for gradients
|
1719
|
+
svg.Element.GradientBase = function(node) {
|
1720
|
+
this.base = svg.Element.ElementBase;
|
1721
|
+
this.base(node);
|
1722
|
+
|
1723
|
+
this.stops = [];
|
1724
|
+
for (var i=0; i<this.children.length; i++) {
|
1725
|
+
var child = this.children[i];
|
1726
|
+
if (child.type == 'stop') this.stops.push(child);
|
1727
|
+
}
|
1728
|
+
|
1729
|
+
this.getGradient = function() {
|
1730
|
+
// OVERRIDE ME!
|
1731
|
+
}
|
1732
|
+
|
1733
|
+
this.gradientUnits = function () {
|
1734
|
+
return this.attribute('gradientUnits').valueOrDefault('objectBoundingBox');
|
1735
|
+
}
|
1736
|
+
|
1737
|
+
this.attributesToInherit = ['gradientUnits'];
|
1738
|
+
|
1739
|
+
this.inheritStopContainer = function (stopsContainer) {
|
1740
|
+
for (var i=0; i<this.attributesToInherit.length; i++) {
|
1741
|
+
var attributeToInherit = this.attributesToInherit[i];
|
1742
|
+
if (!this.attribute(attributeToInherit).hasValue() && stopsContainer.attribute(attributeToInherit).hasValue()) {
|
1743
|
+
this.attribute(attributeToInherit, true).value = stopsContainer.attribute(attributeToInherit).value;
|
1744
|
+
}
|
1745
|
+
}
|
1746
|
+
}
|
1747
|
+
|
1748
|
+
this.createGradient = function(ctx, element, parentOpacityProp) {
|
1749
|
+
var stopsContainer = this;
|
1750
|
+
if (this.getHrefAttribute().hasValue()) {
|
1751
|
+
stopsContainer = this.getHrefAttribute().getDefinition();
|
1752
|
+
this.inheritStopContainer(stopsContainer);
|
1753
|
+
}
|
1754
|
+
|
1755
|
+
var addParentOpacity = function (color) {
|
1756
|
+
if (parentOpacityProp.hasValue()) {
|
1757
|
+
var p = new svg.Property('color', color);
|
1758
|
+
return p.addOpacity(parentOpacityProp).value;
|
1759
|
+
}
|
1760
|
+
return color;
|
1761
|
+
};
|
1762
|
+
|
1763
|
+
var g = this.getGradient(ctx, element);
|
1764
|
+
if (g == null) return addParentOpacity(stopsContainer.stops[stopsContainer.stops.length - 1].color);
|
1765
|
+
for (var i=0; i<stopsContainer.stops.length; i++) {
|
1766
|
+
g.addColorStop(stopsContainer.stops[i].offset, addParentOpacity(stopsContainer.stops[i].color));
|
1767
|
+
}
|
1768
|
+
|
1769
|
+
if (this.attribute('gradientTransform').hasValue()) {
|
1770
|
+
// render as transformed pattern on temporary canvas
|
1771
|
+
var rootView = svg.ViewPort.viewPorts[0];
|
1772
|
+
|
1773
|
+
var rect = new svg.Element.rect();
|
1774
|
+
rect.attributes['x'] = new svg.Property('x', -svg.MAX_VIRTUAL_PIXELS/3.0);
|
1775
|
+
rect.attributes['y'] = new svg.Property('y', -svg.MAX_VIRTUAL_PIXELS/3.0);
|
1776
|
+
rect.attributes['width'] = new svg.Property('width', svg.MAX_VIRTUAL_PIXELS);
|
1777
|
+
rect.attributes['height'] = new svg.Property('height', svg.MAX_VIRTUAL_PIXELS);
|
1778
|
+
|
1779
|
+
var group = new svg.Element.g();
|
1780
|
+
group.attributes['transform'] = new svg.Property('transform', this.attribute('gradientTransform').value);
|
1781
|
+
group.children = [ rect ];
|
1782
|
+
|
1783
|
+
var tempSvg = new svg.Element.svg();
|
1784
|
+
tempSvg.attributes['x'] = new svg.Property('x', 0);
|
1785
|
+
tempSvg.attributes['y'] = new svg.Property('y', 0);
|
1786
|
+
tempSvg.attributes['width'] = new svg.Property('width', rootView.width);
|
1787
|
+
tempSvg.attributes['height'] = new svg.Property('height', rootView.height);
|
1788
|
+
tempSvg.children = [ group ];
|
1789
|
+
|
1790
|
+
var c = document.createElement('canvas');
|
1791
|
+
c.width = rootView.width;
|
1792
|
+
c.height = rootView.height;
|
1793
|
+
var tempCtx = c.getContext('2d');
|
1794
|
+
tempCtx.fillStyle = g;
|
1795
|
+
tempSvg.render(tempCtx);
|
1796
|
+
return tempCtx.createPattern(c, 'no-repeat');
|
1797
|
+
}
|
1798
|
+
|
1799
|
+
return g;
|
1800
|
+
}
|
1801
|
+
}
|
1802
|
+
svg.Element.GradientBase.prototype = new svg.Element.ElementBase;
|
1803
|
+
|
1804
|
+
// linear gradient element
|
1805
|
+
svg.Element.linearGradient = function(node) {
|
1806
|
+
this.base = svg.Element.GradientBase;
|
1807
|
+
this.base(node);
|
1808
|
+
|
1809
|
+
this.attributesToInherit.push('x1');
|
1810
|
+
this.attributesToInherit.push('y1');
|
1811
|
+
this.attributesToInherit.push('x2');
|
1812
|
+
this.attributesToInherit.push('y2');
|
1813
|
+
|
1814
|
+
this.getGradient = function(ctx, element) {
|
1815
|
+
var bb = this.gradientUnits() == 'objectBoundingBox' ? element.getBoundingBox() : null;
|
1816
|
+
|
1817
|
+
if (!this.attribute('x1').hasValue()
|
1818
|
+
&& !this.attribute('y1').hasValue()
|
1819
|
+
&& !this.attribute('x2').hasValue()
|
1820
|
+
&& !this.attribute('y2').hasValue()) {
|
1821
|
+
this.attribute('x1', true).value = 0;
|
1822
|
+
this.attribute('y1', true).value = 0;
|
1823
|
+
this.attribute('x2', true).value = 1;
|
1824
|
+
this.attribute('y2', true).value = 0;
|
1825
|
+
}
|
1826
|
+
|
1827
|
+
var x1 = (this.gradientUnits() == 'objectBoundingBox'
|
1828
|
+
? bb.x() + bb.width() * this.attribute('x1').numValue()
|
1829
|
+
: this.attribute('x1').toPixels('x'));
|
1830
|
+
var y1 = (this.gradientUnits() == 'objectBoundingBox'
|
1831
|
+
? bb.y() + bb.height() * this.attribute('y1').numValue()
|
1832
|
+
: this.attribute('y1').toPixels('y'));
|
1833
|
+
var x2 = (this.gradientUnits() == 'objectBoundingBox'
|
1834
|
+
? bb.x() + bb.width() * this.attribute('x2').numValue()
|
1835
|
+
: this.attribute('x2').toPixels('x'));
|
1836
|
+
var y2 = (this.gradientUnits() == 'objectBoundingBox'
|
1837
|
+
? bb.y() + bb.height() * this.attribute('y2').numValue()
|
1838
|
+
: this.attribute('y2').toPixels('y'));
|
1839
|
+
|
1840
|
+
if (x1 == x2 && y1 == y2) return null;
|
1841
|
+
return ctx.createLinearGradient(x1, y1, x2, y2);
|
1842
|
+
}
|
1843
|
+
}
|
1844
|
+
svg.Element.linearGradient.prototype = new svg.Element.GradientBase;
|
1845
|
+
|
1846
|
+
// radial gradient element
|
1847
|
+
svg.Element.radialGradient = function(node) {
|
1848
|
+
this.base = svg.Element.GradientBase;
|
1849
|
+
this.base(node);
|
1850
|
+
|
1851
|
+
this.attributesToInherit.push('cx');
|
1852
|
+
this.attributesToInherit.push('cy');
|
1853
|
+
this.attributesToInherit.push('r');
|
1854
|
+
this.attributesToInherit.push('fx');
|
1855
|
+
this.attributesToInherit.push('fy');
|
1856
|
+
|
1857
|
+
this.getGradient = function(ctx, element) {
|
1858
|
+
var bb = element.getBoundingBox();
|
1859
|
+
|
1860
|
+
if (!this.attribute('cx').hasValue()) this.attribute('cx', true).value = '50%';
|
1861
|
+
if (!this.attribute('cy').hasValue()) this.attribute('cy', true).value = '50%';
|
1862
|
+
if (!this.attribute('r').hasValue()) this.attribute('r', true).value = '50%';
|
1863
|
+
|
1864
|
+
var cx = (this.gradientUnits() == 'objectBoundingBox'
|
1865
|
+
? bb.x() + bb.width() * this.attribute('cx').numValue()
|
1866
|
+
: this.attribute('cx').toPixels('x'));
|
1867
|
+
var cy = (this.gradientUnits() == 'objectBoundingBox'
|
1868
|
+
? bb.y() + bb.height() * this.attribute('cy').numValue()
|
1869
|
+
: this.attribute('cy').toPixels('y'));
|
1870
|
+
|
1871
|
+
var fx = cx;
|
1872
|
+
var fy = cy;
|
1873
|
+
if (this.attribute('fx').hasValue()) {
|
1874
|
+
fx = (this.gradientUnits() == 'objectBoundingBox'
|
1875
|
+
? bb.x() + bb.width() * this.attribute('fx').numValue()
|
1876
|
+
: this.attribute('fx').toPixels('x'));
|
1877
|
+
}
|
1878
|
+
if (this.attribute('fy').hasValue()) {
|
1879
|
+
fy = (this.gradientUnits() == 'objectBoundingBox'
|
1880
|
+
? bb.y() + bb.height() * this.attribute('fy').numValue()
|
1881
|
+
: this.attribute('fy').toPixels('y'));
|
1882
|
+
}
|
1883
|
+
|
1884
|
+
var r = (this.gradientUnits() == 'objectBoundingBox'
|
1885
|
+
? (bb.width() + bb.height()) / 2.0 * this.attribute('r').numValue()
|
1886
|
+
: this.attribute('r').toPixels());
|
1887
|
+
|
1888
|
+
return ctx.createRadialGradient(fx, fy, 0, cx, cy, r);
|
1889
|
+
}
|
1890
|
+
}
|
1891
|
+
svg.Element.radialGradient.prototype = new svg.Element.GradientBase;
|
1892
|
+
|
1893
|
+
// gradient stop element
|
1894
|
+
svg.Element.stop = function(node) {
|
1895
|
+
this.base = svg.Element.ElementBase;
|
1896
|
+
this.base(node);
|
1897
|
+
|
1898
|
+
this.offset = this.attribute('offset').numValue();
|
1899
|
+
if (this.offset < 0) this.offset = 0;
|
1900
|
+
if (this.offset > 1) this.offset = 1;
|
1901
|
+
|
1902
|
+
var stopColor = this.style('stop-color', true);
|
1903
|
+
if (stopColor.value === '') stopColor.value = '#000';
|
1904
|
+
if (this.style('stop-opacity').hasValue()) stopColor = stopColor.addOpacity(this.style('stop-opacity'));
|
1905
|
+
this.color = stopColor.value;
|
1906
|
+
}
|
1907
|
+
svg.Element.stop.prototype = new svg.Element.ElementBase;
|
1908
|
+
|
1909
|
+
// animation base element
|
1910
|
+
svg.Element.AnimateBase = function(node) {
|
1911
|
+
this.base = svg.Element.ElementBase;
|
1912
|
+
this.base(node);
|
1913
|
+
|
1914
|
+
svg.Animations.push(this);
|
1915
|
+
|
1916
|
+
this.duration = 0.0;
|
1917
|
+
this.begin = this.attribute('begin').toMilliseconds();
|
1918
|
+
this.maxDuration = this.begin + this.attribute('dur').toMilliseconds();
|
1919
|
+
|
1920
|
+
this.getProperty = function() {
|
1921
|
+
var attributeType = this.attribute('attributeType').value;
|
1922
|
+
var attributeName = this.attribute('attributeName').value;
|
1923
|
+
|
1924
|
+
if (attributeType == 'CSS') {
|
1925
|
+
return this.parent.style(attributeName, true);
|
1926
|
+
}
|
1927
|
+
return this.parent.attribute(attributeName, true);
|
1928
|
+
};
|
1929
|
+
|
1930
|
+
this.initialValue = null;
|
1931
|
+
this.initialUnits = '';
|
1932
|
+
this.removed = false;
|
1933
|
+
|
1934
|
+
this.calcValue = function() {
|
1935
|
+
// OVERRIDE ME!
|
1936
|
+
return '';
|
1937
|
+
}
|
1938
|
+
|
1939
|
+
this.update = function(delta) {
|
1940
|
+
// set initial value
|
1941
|
+
if (this.initialValue == null) {
|
1942
|
+
this.initialValue = this.getProperty().value;
|
1943
|
+
this.initialUnits = this.getProperty().getUnits();
|
1944
|
+
}
|
1945
|
+
|
1946
|
+
// if we're past the end time
|
1947
|
+
if (this.duration > this.maxDuration) {
|
1948
|
+
// loop for indefinitely repeating animations
|
1949
|
+
if (this.attribute('repeatCount').value == 'indefinite'
|
1950
|
+
|| this.attribute('repeatDur').value == 'indefinite') {
|
1951
|
+
this.duration = 0.0
|
1952
|
+
}
|
1953
|
+
else if (this.attribute('fill').valueOrDefault('remove') == 'freeze' && !this.frozen) {
|
1954
|
+
this.frozen = true;
|
1955
|
+
this.parent.animationFrozen = true;
|
1956
|
+
this.parent.animationFrozenValue = this.getProperty().value;
|
1957
|
+
}
|
1958
|
+
else if (this.attribute('fill').valueOrDefault('remove') == 'remove' && !this.removed) {
|
1959
|
+
this.removed = true;
|
1960
|
+
this.getProperty().value = this.parent.animationFrozen ? this.parent.animationFrozenValue : this.initialValue;
|
1961
|
+
return true;
|
1962
|
+
}
|
1963
|
+
return false;
|
1964
|
+
}
|
1965
|
+
this.duration = this.duration + delta;
|
1966
|
+
|
1967
|
+
// if we're past the begin time
|
1968
|
+
var updated = false;
|
1969
|
+
if (this.begin < this.duration) {
|
1970
|
+
var newValue = this.calcValue(); // tween
|
1971
|
+
|
1972
|
+
if (this.attribute('type').hasValue()) {
|
1973
|
+
// for transform, etc.
|
1974
|
+
var type = this.attribute('type').value;
|
1975
|
+
newValue = type + '(' + newValue + ')';
|
1976
|
+
}
|
1977
|
+
|
1978
|
+
this.getProperty().value = newValue;
|
1979
|
+
updated = true;
|
1980
|
+
}
|
1981
|
+
|
1982
|
+
return updated;
|
1983
|
+
}
|
1984
|
+
|
1985
|
+
this.from = this.attribute('from');
|
1986
|
+
this.to = this.attribute('to');
|
1987
|
+
this.values = this.attribute('values');
|
1988
|
+
if (this.values.hasValue()) this.values.value = this.values.value.split(';');
|
1989
|
+
|
1990
|
+
// fraction of duration we've covered
|
1991
|
+
this.progress = function() {
|
1992
|
+
var ret = { progress: (this.duration - this.begin) / (this.maxDuration - this.begin) };
|
1993
|
+
if (this.values.hasValue()) {
|
1994
|
+
var p = ret.progress * (this.values.value.length - 1);
|
1995
|
+
var lb = Math.floor(p), ub = Math.ceil(p);
|
1996
|
+
ret.from = new svg.Property('from', parseFloat(this.values.value[lb]));
|
1997
|
+
ret.to = new svg.Property('to', parseFloat(this.values.value[ub]));
|
1998
|
+
ret.progress = (p - lb) / (ub - lb);
|
1999
|
+
}
|
2000
|
+
else {
|
2001
|
+
ret.from = this.from;
|
2002
|
+
ret.to = this.to;
|
2003
|
+
}
|
2004
|
+
return ret;
|
2005
|
+
}
|
2006
|
+
}
|
2007
|
+
svg.Element.AnimateBase.prototype = new svg.Element.ElementBase;
|
2008
|
+
|
2009
|
+
// animate element
|
2010
|
+
svg.Element.animate = function(node) {
|
2011
|
+
this.base = svg.Element.AnimateBase;
|
2012
|
+
this.base(node);
|
2013
|
+
|
2014
|
+
this.calcValue = function() {
|
2015
|
+
var p = this.progress();
|
2016
|
+
|
2017
|
+
// tween value linearly
|
2018
|
+
var newValue = p.from.numValue() + (p.to.numValue() - p.from.numValue()) * p.progress;
|
2019
|
+
return newValue + this.initialUnits;
|
2020
|
+
};
|
2021
|
+
}
|
2022
|
+
svg.Element.animate.prototype = new svg.Element.AnimateBase;
|
2023
|
+
|
2024
|
+
// animate color element
|
2025
|
+
svg.Element.animateColor = function(node) {
|
2026
|
+
this.base = svg.Element.AnimateBase;
|
2027
|
+
this.base(node);
|
2028
|
+
|
2029
|
+
this.calcValue = function() {
|
2030
|
+
var p = this.progress();
|
2031
|
+
var from = new RGBColor(p.from.value);
|
2032
|
+
var to = new RGBColor(p.to.value);
|
2033
|
+
|
2034
|
+
if (from.ok && to.ok) {
|
2035
|
+
// tween color linearly
|
2036
|
+
var r = from.r + (to.r - from.r) * p.progress;
|
2037
|
+
var g = from.g + (to.g - from.g) * p.progress;
|
2038
|
+
var b = from.b + (to.b - from.b) * p.progress;
|
2039
|
+
return 'rgb('+parseInt(r,10)+','+parseInt(g,10)+','+parseInt(b,10)+')';
|
2040
|
+
}
|
2041
|
+
return this.attribute('from').value;
|
2042
|
+
};
|
2043
|
+
}
|
2044
|
+
svg.Element.animateColor.prototype = new svg.Element.AnimateBase;
|
2045
|
+
|
2046
|
+
// animate transform element
|
2047
|
+
svg.Element.animateTransform = function(node) {
|
2048
|
+
this.base = svg.Element.AnimateBase;
|
2049
|
+
this.base(node);
|
2050
|
+
|
2051
|
+
this.calcValue = function() {
|
2052
|
+
var p = this.progress();
|
2053
|
+
|
2054
|
+
// tween value linearly
|
2055
|
+
var from = svg.ToNumberArray(p.from.value);
|
2056
|
+
var to = svg.ToNumberArray(p.to.value);
|
2057
|
+
var newValue = '';
|
2058
|
+
for (var i=0; i<from.length; i++) {
|
2059
|
+
newValue += from[i] + (to[i] - from[i]) * p.progress + ' ';
|
2060
|
+
}
|
2061
|
+
return newValue;
|
2062
|
+
};
|
2063
|
+
}
|
2064
|
+
svg.Element.animateTransform.prototype = new svg.Element.animate;
|
2065
|
+
|
2066
|
+
// font element
|
2067
|
+
svg.Element.font = function(node) {
|
2068
|
+
this.base = svg.Element.ElementBase;
|
2069
|
+
this.base(node);
|
2070
|
+
|
2071
|
+
this.horizAdvX = this.attribute('horiz-adv-x').numValue();
|
2072
|
+
|
2073
|
+
this.isRTL = false;
|
2074
|
+
this.isArabic = false;
|
2075
|
+
this.fontFace = null;
|
2076
|
+
this.missingGlyph = null;
|
2077
|
+
this.glyphs = [];
|
2078
|
+
for (var i=0; i<this.children.length; i++) {
|
2079
|
+
var child = this.children[i];
|
2080
|
+
if (child.type == 'font-face') {
|
2081
|
+
this.fontFace = child;
|
2082
|
+
if (child.style('font-family').hasValue()) {
|
2083
|
+
svg.Definitions[child.style('font-family').value] = this;
|
2084
|
+
}
|
2085
|
+
}
|
2086
|
+
else if (child.type == 'missing-glyph') this.missingGlyph = child;
|
2087
|
+
else if (child.type == 'glyph') {
|
2088
|
+
if (child.arabicForm != '') {
|
2089
|
+
this.isRTL = true;
|
2090
|
+
this.isArabic = true;
|
2091
|
+
if (typeof(this.glyphs[child.unicode]) == 'undefined') this.glyphs[child.unicode] = [];
|
2092
|
+
this.glyphs[child.unicode][child.arabicForm] = child;
|
2093
|
+
}
|
2094
|
+
else {
|
2095
|
+
this.glyphs[child.unicode] = child;
|
2096
|
+
}
|
2097
|
+
}
|
2098
|
+
}
|
2099
|
+
}
|
2100
|
+
svg.Element.font.prototype = new svg.Element.ElementBase;
|
2101
|
+
|
2102
|
+
// font-face element
|
2103
|
+
svg.Element.fontface = function(node) {
|
2104
|
+
this.base = svg.Element.ElementBase;
|
2105
|
+
this.base(node);
|
2106
|
+
|
2107
|
+
this.ascent = this.attribute('ascent').value;
|
2108
|
+
this.descent = this.attribute('descent').value;
|
2109
|
+
this.unitsPerEm = this.attribute('units-per-em').numValue();
|
2110
|
+
}
|
2111
|
+
svg.Element.fontface.prototype = new svg.Element.ElementBase;
|
2112
|
+
|
2113
|
+
// missing-glyph element
|
2114
|
+
svg.Element.missingglyph = function(node) {
|
2115
|
+
this.base = svg.Element.path;
|
2116
|
+
this.base(node);
|
2117
|
+
|
2118
|
+
this.horizAdvX = 0;
|
2119
|
+
}
|
2120
|
+
svg.Element.missingglyph.prototype = new svg.Element.path;
|
2121
|
+
|
2122
|
+
// glyph element
|
2123
|
+
svg.Element.glyph = function(node) {
|
2124
|
+
this.base = svg.Element.path;
|
2125
|
+
this.base(node);
|
2126
|
+
|
2127
|
+
this.horizAdvX = this.attribute('horiz-adv-x').numValue();
|
2128
|
+
this.unicode = this.attribute('unicode').value;
|
2129
|
+
this.arabicForm = this.attribute('arabic-form').value;
|
2130
|
+
}
|
2131
|
+
svg.Element.glyph.prototype = new svg.Element.path;
|
2132
|
+
|
2133
|
+
// text element
|
2134
|
+
svg.Element.text = function(node) {
|
2135
|
+
this.captureTextNodes = true;
|
2136
|
+
this.base = svg.Element.RenderedElementBase;
|
2137
|
+
this.base(node);
|
2138
|
+
|
2139
|
+
this.baseSetContext = this.setContext;
|
2140
|
+
this.setContext = function(ctx) {
|
2141
|
+
this.baseSetContext(ctx);
|
2142
|
+
|
2143
|
+
var textBaseline = this.style('dominant-baseline').toTextBaseline();
|
2144
|
+
if (textBaseline == null) textBaseline = this.style('alignment-baseline').toTextBaseline();
|
2145
|
+
if (textBaseline != null) ctx.textBaseline = textBaseline;
|
2146
|
+
}
|
2147
|
+
|
2148
|
+
this.getBoundingBox = function () {
|
2149
|
+
var x = this.attribute('x').toPixels('x');
|
2150
|
+
var y = this.attribute('y').toPixels('y');
|
2151
|
+
var fontSize = this.parent.style('font-size').numValueOrDefault(svg.Font.Parse(svg.ctx.font).fontSize);
|
2152
|
+
return new svg.BoundingBox(x, y - fontSize, x + Math.floor(fontSize * 2.0 / 3.0) * this.children[0].getText().length, y);
|
2153
|
+
}
|
2154
|
+
|
2155
|
+
this.renderChildren = function(ctx) {
|
2156
|
+
this.x = this.attribute('x').toPixels('x');
|
2157
|
+
this.y = this.attribute('y').toPixels('y');
|
2158
|
+
if (this.attribute('dx').hasValue()) this.x += this.attribute('dx').toPixels('x');
|
2159
|
+
if (this.attribute('dy').hasValue()) this.y += this.attribute('dy').toPixels('y');
|
2160
|
+
this.x += this.getAnchorDelta(ctx, this, 0);
|
2161
|
+
for (var i=0; i<this.children.length; i++) {
|
2162
|
+
this.renderChild(ctx, this, i);
|
2163
|
+
}
|
2164
|
+
}
|
2165
|
+
|
2166
|
+
this.getAnchorDelta = function (ctx, parent, startI) {
|
2167
|
+
var textAnchor = this.style('text-anchor').valueOrDefault('start');
|
2168
|
+
if (textAnchor != 'start') {
|
2169
|
+
var width = 0;
|
2170
|
+
for (var i=startI; i<parent.children.length; i++) {
|
2171
|
+
var child = parent.children[i];
|
2172
|
+
if (i > startI && child.attribute('x').hasValue()) break; // new group
|
2173
|
+
width += child.measureTextRecursive(ctx);
|
2174
|
+
}
|
2175
|
+
return -1 * (textAnchor == 'end' ? width : width / 2.0);
|
2176
|
+
}
|
2177
|
+
return 0;
|
2178
|
+
}
|
2179
|
+
|
2180
|
+
this.renderChild = function(ctx, parent, i) {
|
2181
|
+
var child = parent.children[i];
|
2182
|
+
if (child.attribute('x').hasValue()) {
|
2183
|
+
child.x = child.attribute('x').toPixels('x') + parent.getAnchorDelta(ctx, parent, i);
|
2184
|
+
if (child.attribute('dx').hasValue()) child.x += child.attribute('dx').toPixels('x');
|
2185
|
+
}
|
2186
|
+
else {
|
2187
|
+
if (child.attribute('dx').hasValue()) parent.x += child.attribute('dx').toPixels('x');
|
2188
|
+
child.x = parent.x;
|
2189
|
+
}
|
2190
|
+
parent.x = child.x + child.measureText(ctx);
|
2191
|
+
|
2192
|
+
if (child.attribute('y').hasValue()) {
|
2193
|
+
child.y = child.attribute('y').toPixels('y');
|
2194
|
+
if (child.attribute('dy').hasValue()) child.y += child.attribute('dy').toPixels('y');
|
2195
|
+
}
|
2196
|
+
else {
|
2197
|
+
if (child.attribute('dy').hasValue()) parent.y += child.attribute('dy').toPixels('y');
|
2198
|
+
child.y = parent.y;
|
2199
|
+
}
|
2200
|
+
parent.y = child.y;
|
2201
|
+
|
2202
|
+
child.render(ctx);
|
2203
|
+
|
2204
|
+
for (var i=0; i<child.children.length; i++) {
|
2205
|
+
parent.renderChild(ctx, child, i);
|
2206
|
+
}
|
2207
|
+
}
|
2208
|
+
}
|
2209
|
+
svg.Element.text.prototype = new svg.Element.RenderedElementBase;
|
2210
|
+
|
2211
|
+
// text base
|
2212
|
+
svg.Element.TextElementBase = function(node) {
|
2213
|
+
this.base = svg.Element.RenderedElementBase;
|
2214
|
+
this.base(node);
|
2215
|
+
|
2216
|
+
this.getGlyph = function(font, text, i) {
|
2217
|
+
var c = text[i];
|
2218
|
+
var glyph = null;
|
2219
|
+
if (font.isArabic) {
|
2220
|
+
var arabicForm = 'isolated';
|
2221
|
+
if ((i==0 || text[i-1]==' ') && i<text.length-2 && text[i+1]!=' ') arabicForm = 'terminal';
|
2222
|
+
if (i>0 && text[i-1]!=' ' && i<text.length-2 && text[i+1]!=' ') arabicForm = 'medial';
|
2223
|
+
if (i>0 && text[i-1]!=' ' && (i == text.length-1 || text[i+1]==' ')) arabicForm = 'initial';
|
2224
|
+
if (typeof(font.glyphs[c]) != 'undefined') {
|
2225
|
+
glyph = font.glyphs[c][arabicForm];
|
2226
|
+
if (glyph == null && font.glyphs[c].type == 'glyph') glyph = font.glyphs[c];
|
2227
|
+
}
|
2228
|
+
}
|
2229
|
+
else {
|
2230
|
+
glyph = font.glyphs[c];
|
2231
|
+
}
|
2232
|
+
if (glyph == null) glyph = font.missingGlyph;
|
2233
|
+
return glyph;
|
2234
|
+
}
|
2235
|
+
|
2236
|
+
this.renderChildren = function(ctx) {
|
2237
|
+
var customFont = this.parent.style('font-family').getDefinition();
|
2238
|
+
if (customFont != null) {
|
2239
|
+
var fontSize = this.parent.style('font-size').numValueOrDefault(svg.Font.Parse(svg.ctx.font).fontSize);
|
2240
|
+
var fontStyle = this.parent.style('font-style').valueOrDefault(svg.Font.Parse(svg.ctx.font).fontStyle);
|
2241
|
+
var text = this.getText();
|
2242
|
+
if (customFont.isRTL) text = text.split("").reverse().join("");
|
2243
|
+
|
2244
|
+
var dx = svg.ToNumberArray(this.parent.attribute('dx').value);
|
2245
|
+
for (var i=0; i<text.length; i++) {
|
2246
|
+
var glyph = this.getGlyph(customFont, text, i);
|
2247
|
+
var scale = fontSize / customFont.fontFace.unitsPerEm;
|
2248
|
+
ctx.translate(this.x, this.y);
|
2249
|
+
ctx.scale(scale, -scale);
|
2250
|
+
var lw = ctx.lineWidth;
|
2251
|
+
ctx.lineWidth = ctx.lineWidth * customFont.fontFace.unitsPerEm / fontSize;
|
2252
|
+
if (fontStyle == 'italic') ctx.transform(1, 0, .4, 1, 0, 0);
|
2253
|
+
glyph.render(ctx);
|
2254
|
+
if (fontStyle == 'italic') ctx.transform(1, 0, -.4, 1, 0, 0);
|
2255
|
+
ctx.lineWidth = lw;
|
2256
|
+
ctx.scale(1/scale, -1/scale);
|
2257
|
+
ctx.translate(-this.x, -this.y);
|
2258
|
+
|
2259
|
+
this.x += fontSize * (glyph.horizAdvX || customFont.horizAdvX) / customFont.fontFace.unitsPerEm;
|
2260
|
+
if (typeof(dx[i]) != 'undefined' && !isNaN(dx[i])) {
|
2261
|
+
this.x += dx[i];
|
2262
|
+
}
|
2263
|
+
}
|
2264
|
+
return;
|
2265
|
+
}
|
2266
|
+
|
2267
|
+
if (ctx.fillStyle != '') ctx.fillText(svg.compressSpaces(this.getText()), this.x, this.y);
|
2268
|
+
if (ctx.strokeStyle != '') ctx.strokeText(svg.compressSpaces(this.getText()), this.x, this.y);
|
2269
|
+
}
|
2270
|
+
|
2271
|
+
this.getText = function() {
|
2272
|
+
// OVERRIDE ME
|
2273
|
+
}
|
2274
|
+
|
2275
|
+
this.measureTextRecursive = function(ctx) {
|
2276
|
+
var width = this.measureText(ctx);
|
2277
|
+
for (var i=0; i<this.children.length; i++) {
|
2278
|
+
width += this.children[i].measureTextRecursive(ctx);
|
2279
|
+
}
|
2280
|
+
return width;
|
2281
|
+
}
|
2282
|
+
|
2283
|
+
this.measureText = function(ctx) {
|
2284
|
+
var customFont = this.parent.style('font-family').getDefinition();
|
2285
|
+
if (customFont != null) {
|
2286
|
+
var fontSize = this.parent.style('font-size').numValueOrDefault(svg.Font.Parse(svg.ctx.font).fontSize);
|
2287
|
+
var measure = 0;
|
2288
|
+
var text = this.getText();
|
2289
|
+
if (customFont.isRTL) text = text.split("").reverse().join("");
|
2290
|
+
var dx = svg.ToNumberArray(this.parent.attribute('dx').value);
|
2291
|
+
for (var i=0; i<text.length; i++) {
|
2292
|
+
var glyph = this.getGlyph(customFont, text, i);
|
2293
|
+
measure += (glyph.horizAdvX || customFont.horizAdvX) * fontSize / customFont.fontFace.unitsPerEm;
|
2294
|
+
if (typeof(dx[i]) != 'undefined' && !isNaN(dx[i])) {
|
2295
|
+
measure += dx[i];
|
2296
|
+
}
|
2297
|
+
}
|
2298
|
+
return measure;
|
2299
|
+
}
|
2300
|
+
|
2301
|
+
var textToMeasure = svg.compressSpaces(this.getText());
|
2302
|
+
if (!ctx.measureText) return textToMeasure.length * 10;
|
2303
|
+
|
2304
|
+
ctx.save();
|
2305
|
+
this.setContext(ctx);
|
2306
|
+
var width = ctx.measureText(textToMeasure).width;
|
2307
|
+
ctx.restore();
|
2308
|
+
return width;
|
2309
|
+
}
|
2310
|
+
}
|
2311
|
+
svg.Element.TextElementBase.prototype = new svg.Element.RenderedElementBase;
|
2312
|
+
|
2313
|
+
// tspan
|
2314
|
+
svg.Element.tspan = function(node) {
|
2315
|
+
this.captureTextNodes = true;
|
2316
|
+
this.base = svg.Element.TextElementBase;
|
2317
|
+
this.base(node);
|
2318
|
+
|
2319
|
+
this.text = svg.compressSpaces(node.value || node.text || node.textContent || '');
|
2320
|
+
this.getText = function() {
|
2321
|
+
// if this node has children, then they own the text
|
2322
|
+
if (this.children.length > 0) { return ''; }
|
2323
|
+
return this.text;
|
2324
|
+
}
|
2325
|
+
}
|
2326
|
+
svg.Element.tspan.prototype = new svg.Element.TextElementBase;
|
2327
|
+
|
2328
|
+
// tref
|
2329
|
+
svg.Element.tref = function(node) {
|
2330
|
+
this.base = svg.Element.TextElementBase;
|
2331
|
+
this.base(node);
|
2332
|
+
|
2333
|
+
this.getText = function() {
|
2334
|
+
var element = this.getHrefAttribute().getDefinition();
|
2335
|
+
if (element != null) return element.children[0].getText();
|
2336
|
+
}
|
2337
|
+
}
|
2338
|
+
svg.Element.tref.prototype = new svg.Element.TextElementBase;
|
2339
|
+
|
2340
|
+
// a element
|
2341
|
+
svg.Element.a = function(node) {
|
2342
|
+
this.base = svg.Element.TextElementBase;
|
2343
|
+
this.base(node);
|
2344
|
+
|
2345
|
+
this.hasText = node.childNodes.length > 0;
|
2346
|
+
for (var i=0; i<node.childNodes.length; i++) {
|
2347
|
+
if (node.childNodes[i].nodeType != 3) this.hasText = false;
|
2348
|
+
}
|
2349
|
+
|
2350
|
+
// this might contain text
|
2351
|
+
this.text = this.hasText ? node.childNodes[0].value : '';
|
2352
|
+
this.getText = function() {
|
2353
|
+
return this.text;
|
2354
|
+
}
|
2355
|
+
|
2356
|
+
this.baseRenderChildren = this.renderChildren;
|
2357
|
+
this.renderChildren = function(ctx) {
|
2358
|
+
if (this.hasText) {
|
2359
|
+
// render as text element
|
2360
|
+
this.baseRenderChildren(ctx);
|
2361
|
+
var fontSize = new svg.Property('fontSize', svg.Font.Parse(svg.ctx.font).fontSize);
|
2362
|
+
svg.Mouse.checkBoundingBox(this, new svg.BoundingBox(this.x, this.y - fontSize.toPixels('y'), this.x + this.measureText(ctx), this.y));
|
2363
|
+
}
|
2364
|
+
else if (this.children.length > 0) {
|
2365
|
+
// render as temporary group
|
2366
|
+
var g = new svg.Element.g();
|
2367
|
+
g.children = this.children;
|
2368
|
+
g.parent = this;
|
2369
|
+
g.render(ctx);
|
2370
|
+
}
|
2371
|
+
}
|
2372
|
+
|
2373
|
+
this.onclick = function() {
|
2374
|
+
window.open(this.getHrefAttribute().value);
|
2375
|
+
}
|
2376
|
+
|
2377
|
+
this.onmousemove = function() {
|
2378
|
+
svg.ctx.canvas.style.cursor = 'pointer';
|
2379
|
+
}
|
2380
|
+
}
|
2381
|
+
svg.Element.a.prototype = new svg.Element.TextElementBase;
|
2382
|
+
|
2383
|
+
// image element
|
2384
|
+
svg.Element.image = function(node) {
|
2385
|
+
this.base = svg.Element.RenderedElementBase;
|
2386
|
+
this.base(node);
|
2387
|
+
|
2388
|
+
var href = this.getHrefAttribute().value;
|
2389
|
+
if (href == '') { return; }
|
2390
|
+
var isSvg = href.match(/\.svg$/)
|
2391
|
+
|
2392
|
+
svg.Images.push(this);
|
2393
|
+
this.loaded = false;
|
2394
|
+
if (!isSvg) {
|
2395
|
+
this.img = document.createElement('img');
|
2396
|
+
if (svg.opts['useCORS'] == true) { this.img.crossOrigin = 'Anonymous'; }
|
2397
|
+
var self = this;
|
2398
|
+
this.img.onload = function() { self.loaded = true; }
|
2399
|
+
this.img.onerror = function() { svg.log('ERROR: image "' + href + '" not found'); self.loaded = true; }
|
2400
|
+
this.img.src = href;
|
2401
|
+
}
|
2402
|
+
else {
|
2403
|
+
this.img = svg.ajax(href);
|
2404
|
+
this.loaded = true;
|
2405
|
+
}
|
2406
|
+
|
2407
|
+
this.renderChildren = function(ctx) {
|
2408
|
+
var x = this.attribute('x').toPixels('x');
|
2409
|
+
var y = this.attribute('y').toPixels('y');
|
2410
|
+
|
2411
|
+
var width = this.attribute('width').toPixels('x');
|
2412
|
+
var height = this.attribute('height').toPixels('y');
|
2413
|
+
if (width == 0 || height == 0) return;
|
2414
|
+
|
2415
|
+
ctx.save();
|
2416
|
+
if (isSvg) {
|
2417
|
+
ctx.drawSvg(this.img, x, y, width, height);
|
2418
|
+
}
|
2419
|
+
else {
|
2420
|
+
ctx.translate(x, y);
|
2421
|
+
svg.AspectRatio(ctx,
|
2422
|
+
this.attribute('preserveAspectRatio').value,
|
2423
|
+
width,
|
2424
|
+
this.img.width,
|
2425
|
+
height,
|
2426
|
+
this.img.height,
|
2427
|
+
0,
|
2428
|
+
0);
|
2429
|
+
ctx.drawImage(this.img, 0, 0);
|
2430
|
+
}
|
2431
|
+
ctx.restore();
|
2432
|
+
}
|
2433
|
+
|
2434
|
+
this.getBoundingBox = function() {
|
2435
|
+
var x = this.attribute('x').toPixels('x');
|
2436
|
+
var y = this.attribute('y').toPixels('y');
|
2437
|
+
var width = this.attribute('width').toPixels('x');
|
2438
|
+
var height = this.attribute('height').toPixels('y');
|
2439
|
+
return new svg.BoundingBox(x, y, x + width, y + height);
|
2440
|
+
}
|
2441
|
+
}
|
2442
|
+
svg.Element.image.prototype = new svg.Element.RenderedElementBase;
|
2443
|
+
|
2444
|
+
// group element
|
2445
|
+
svg.Element.g = function(node) {
|
2446
|
+
this.base = svg.Element.RenderedElementBase;
|
2447
|
+
this.base(node);
|
2448
|
+
|
2449
|
+
this.getBoundingBox = function() {
|
2450
|
+
var bb = new svg.BoundingBox();
|
2451
|
+
for (var i=0; i<this.children.length; i++) {
|
2452
|
+
bb.addBoundingBox(this.children[i].getBoundingBox());
|
2453
|
+
}
|
2454
|
+
return bb;
|
2455
|
+
};
|
2456
|
+
}
|
2457
|
+
svg.Element.g.prototype = new svg.Element.RenderedElementBase;
|
2458
|
+
|
2459
|
+
// symbol element
|
2460
|
+
svg.Element.symbol = function(node) {
|
2461
|
+
this.base = svg.Element.RenderedElementBase;
|
2462
|
+
this.base(node);
|
2463
|
+
|
2464
|
+
this.render = function(ctx) {
|
2465
|
+
// NO RENDER
|
2466
|
+
};
|
2467
|
+
}
|
2468
|
+
svg.Element.symbol.prototype = new svg.Element.RenderedElementBase;
|
2469
|
+
|
2470
|
+
// style element
|
2471
|
+
svg.Element.style = function(node) {
|
2472
|
+
this.base = svg.Element.ElementBase;
|
2473
|
+
this.base(node);
|
2474
|
+
|
2475
|
+
// text, or spaces then CDATA
|
2476
|
+
var css = ''
|
2477
|
+
for (var i=0; i<node.childNodes.length; i++) {
|
2478
|
+
css += node.childNodes[i].data;
|
2479
|
+
}
|
2480
|
+
css = css.replace(/(\/\*([^*]|[\r\n]|(\*+([^*\/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm, ''); // remove comments
|
2481
|
+
css = svg.compressSpaces(css); // replace whitespace
|
2482
|
+
var cssDefs = css.split('}');
|
2483
|
+
for (var i=0; i<cssDefs.length; i++) {
|
2484
|
+
if (svg.trim(cssDefs[i]) != '') {
|
2485
|
+
var cssDef = cssDefs[i].split('{');
|
2486
|
+
var cssClasses = cssDef[0].split(',');
|
2487
|
+
var cssProps = cssDef[1].split(';');
|
2488
|
+
for (var j=0; j<cssClasses.length; j++) {
|
2489
|
+
var cssClass = svg.trim(cssClasses[j]);
|
2490
|
+
if (cssClass != '') {
|
2491
|
+
var props = svg.Styles[cssClass] || {};
|
2492
|
+
for (var k=0; k<cssProps.length; k++) {
|
2493
|
+
var prop = cssProps[k].indexOf(':');
|
2494
|
+
var name = cssProps[k].substr(0, prop);
|
2495
|
+
var value = cssProps[k].substr(prop + 1, cssProps[k].length - prop);
|
2496
|
+
if (name != null && value != null) {
|
2497
|
+
props[svg.trim(name)] = new svg.Property(svg.trim(name), svg.trim(value));
|
2498
|
+
}
|
2499
|
+
}
|
2500
|
+
svg.Styles[cssClass] = props;
|
2501
|
+
svg.StylesSpecificity[cssClass] = getSelectorSpecificity(cssClass);
|
2502
|
+
if (cssClass == '@font-face') {
|
2503
|
+
var fontFamily = props['font-family'].value.replace(/"/g,'');
|
2504
|
+
var srcs = props['src'].value.split(',');
|
2505
|
+
for (var s=0; s<srcs.length; s++) {
|
2506
|
+
if (srcs[s].indexOf('format("svg")') > 0) {
|
2507
|
+
var urlStart = srcs[s].indexOf('url');
|
2508
|
+
var urlEnd = srcs[s].indexOf(')', urlStart);
|
2509
|
+
var url = srcs[s].substr(urlStart + 5, urlEnd - urlStart - 6);
|
2510
|
+
var doc = svg.parseXml(svg.ajax(url));
|
2511
|
+
var fonts = doc.getElementsByTagName('font');
|
2512
|
+
for (var f=0; f<fonts.length; f++) {
|
2513
|
+
var font = svg.CreateElement(fonts[f]);
|
2514
|
+
svg.Definitions[fontFamily] = font;
|
2515
|
+
}
|
2516
|
+
}
|
2517
|
+
}
|
2518
|
+
}
|
2519
|
+
}
|
2520
|
+
}
|
2521
|
+
}
|
2522
|
+
}
|
2523
|
+
}
|
2524
|
+
svg.Element.style.prototype = new svg.Element.ElementBase;
|
2525
|
+
|
2526
|
+
// use element
|
2527
|
+
svg.Element.use = function(node) {
|
2528
|
+
this.base = svg.Element.RenderedElementBase;
|
2529
|
+
this.base(node);
|
2530
|
+
|
2531
|
+
this.baseSetContext = this.setContext;
|
2532
|
+
this.setContext = function(ctx) {
|
2533
|
+
this.baseSetContext(ctx);
|
2534
|
+
if (this.attribute('x').hasValue()) ctx.translate(this.attribute('x').toPixels('x'), 0);
|
2535
|
+
if (this.attribute('y').hasValue()) ctx.translate(0, this.attribute('y').toPixels('y'));
|
2536
|
+
}
|
2537
|
+
|
2538
|
+
var element = this.getHrefAttribute().getDefinition();
|
2539
|
+
|
2540
|
+
this.path = function(ctx) {
|
2541
|
+
if (element != null) element.path(ctx);
|
2542
|
+
}
|
2543
|
+
|
2544
|
+
this.getBoundingBox = function() {
|
2545
|
+
if (element != null) return element.getBoundingBox();
|
2546
|
+
}
|
2547
|
+
|
2548
|
+
this.renderChildren = function(ctx) {
|
2549
|
+
if (element != null) {
|
2550
|
+
var tempSvg = element;
|
2551
|
+
if (element.type == 'symbol') {
|
2552
|
+
// render me using a temporary svg element in symbol cases (http://www.w3.org/TR/SVG/struct.html#UseElement)
|
2553
|
+
tempSvg = new svg.Element.svg();
|
2554
|
+
tempSvg.type = 'svg';
|
2555
|
+
tempSvg.attributes['viewBox'] = new svg.Property('viewBox', element.attribute('viewBox').value);
|
2556
|
+
tempSvg.attributes['preserveAspectRatio'] = new svg.Property('preserveAspectRatio', element.attribute('preserveAspectRatio').value);
|
2557
|
+
tempSvg.attributes['overflow'] = new svg.Property('overflow', element.attribute('overflow').value);
|
2558
|
+
tempSvg.children = element.children;
|
2559
|
+
}
|
2560
|
+
if (tempSvg.type == 'svg') {
|
2561
|
+
// if symbol or svg, inherit width/height from me
|
2562
|
+
if (this.attribute('width').hasValue()) tempSvg.attributes['width'] = new svg.Property('width', this.attribute('width').value);
|
2563
|
+
if (this.attribute('height').hasValue()) tempSvg.attributes['height'] = new svg.Property('height', this.attribute('height').value);
|
2564
|
+
}
|
2565
|
+
var oldParent = tempSvg.parent;
|
2566
|
+
tempSvg.parent = null;
|
2567
|
+
tempSvg.render(ctx);
|
2568
|
+
tempSvg.parent = oldParent;
|
2569
|
+
}
|
2570
|
+
}
|
2571
|
+
}
|
2572
|
+
svg.Element.use.prototype = new svg.Element.RenderedElementBase;
|
2573
|
+
|
2574
|
+
// mask element
|
2575
|
+
svg.Element.mask = function(node) {
|
2576
|
+
this.base = svg.Element.ElementBase;
|
2577
|
+
this.base(node);
|
2578
|
+
|
2579
|
+
this.apply = function(ctx, element) {
|
2580
|
+
// render as temp svg
|
2581
|
+
var x = this.attribute('x').toPixels('x');
|
2582
|
+
var y = this.attribute('y').toPixels('y');
|
2583
|
+
var width = this.attribute('width').toPixels('x');
|
2584
|
+
var height = this.attribute('height').toPixels('y');
|
2585
|
+
|
2586
|
+
if (width == 0 && height == 0) {
|
2587
|
+
var bb = new svg.BoundingBox();
|
2588
|
+
for (var i=0; i<this.children.length; i++) {
|
2589
|
+
bb.addBoundingBox(this.children[i].getBoundingBox());
|
2590
|
+
}
|
2591
|
+
var x = Math.floor(bb.x1);
|
2592
|
+
var y = Math.floor(bb.y1);
|
2593
|
+
var width = Math.floor(bb.width());
|
2594
|
+
var height = Math.floor(bb.height());
|
2595
|
+
}
|
2596
|
+
|
2597
|
+
// temporarily remove mask to avoid recursion
|
2598
|
+
var mask = element.attribute('mask').value;
|
2599
|
+
element.attribute('mask').value = '';
|
2600
|
+
|
2601
|
+
var cMask = document.createElement('canvas');
|
2602
|
+
cMask.width = x + width;
|
2603
|
+
cMask.height = y + height;
|
2604
|
+
var maskCtx = cMask.getContext('2d');
|
2605
|
+
this.renderChildren(maskCtx);
|
2606
|
+
|
2607
|
+
var c = document.createElement('canvas');
|
2608
|
+
c.width = x + width;
|
2609
|
+
c.height = y + height;
|
2610
|
+
var tempCtx = c.getContext('2d');
|
2611
|
+
element.render(tempCtx);
|
2612
|
+
tempCtx.globalCompositeOperation = 'destination-in';
|
2613
|
+
tempCtx.fillStyle = maskCtx.createPattern(cMask, 'no-repeat');
|
2614
|
+
tempCtx.fillRect(0, 0, x + width, y + height);
|
2615
|
+
|
2616
|
+
ctx.fillStyle = tempCtx.createPattern(c, 'no-repeat');
|
2617
|
+
ctx.fillRect(0, 0, x + width, y + height);
|
2618
|
+
|
2619
|
+
// reassign mask
|
2620
|
+
element.attribute('mask').value = mask;
|
2621
|
+
}
|
2622
|
+
|
2623
|
+
this.render = function(ctx) {
|
2624
|
+
// NO RENDER
|
2625
|
+
}
|
2626
|
+
}
|
2627
|
+
svg.Element.mask.prototype = new svg.Element.ElementBase;
|
2628
|
+
|
2629
|
+
// clip element
|
2630
|
+
svg.Element.clipPath = function(node) {
|
2631
|
+
this.base = svg.Element.ElementBase;
|
2632
|
+
this.base(node);
|
2633
|
+
|
2634
|
+
this.apply = function(ctx) {
|
2635
|
+
var oldBeginPath = CanvasRenderingContext2D.prototype.beginPath;
|
2636
|
+
CanvasRenderingContext2D.prototype.beginPath = function () { };
|
2637
|
+
|
2638
|
+
var oldClosePath = CanvasRenderingContext2D.prototype.closePath;
|
2639
|
+
CanvasRenderingContext2D.prototype.closePath = function () { };
|
2640
|
+
|
2641
|
+
oldBeginPath.call(ctx);
|
2642
|
+
for (var i=0; i<this.children.length; i++) {
|
2643
|
+
var child = this.children[i];
|
2644
|
+
if (typeof(child.path) != 'undefined') {
|
2645
|
+
var transform = null;
|
2646
|
+
if (child.style('transform', false, true).hasValue()) {
|
2647
|
+
transform = new svg.Transform(child.style('transform', false, true).value);
|
2648
|
+
transform.apply(ctx);
|
2649
|
+
}
|
2650
|
+
child.path(ctx);
|
2651
|
+
CanvasRenderingContext2D.prototype.closePath = oldClosePath;
|
2652
|
+
if (transform) { transform.unapply(ctx); }
|
2653
|
+
}
|
2654
|
+
}
|
2655
|
+
oldClosePath.call(ctx);
|
2656
|
+
ctx.clip();
|
2657
|
+
|
2658
|
+
CanvasRenderingContext2D.prototype.beginPath = oldBeginPath;
|
2659
|
+
CanvasRenderingContext2D.prototype.closePath = oldClosePath;
|
2660
|
+
}
|
2661
|
+
|
2662
|
+
this.render = function(ctx) {
|
2663
|
+
// NO RENDER
|
2664
|
+
}
|
2665
|
+
}
|
2666
|
+
svg.Element.clipPath.prototype = new svg.Element.ElementBase;
|
2667
|
+
|
2668
|
+
// filters
|
2669
|
+
svg.Element.filter = function(node) {
|
2670
|
+
this.base = svg.Element.ElementBase;
|
2671
|
+
this.base(node);
|
2672
|
+
|
2673
|
+
this.apply = function(ctx, element) {
|
2674
|
+
// render as temp svg
|
2675
|
+
var bb = element.getBoundingBox();
|
2676
|
+
var x = Math.floor(bb.x1);
|
2677
|
+
var y = Math.floor(bb.y1);
|
2678
|
+
var width = Math.floor(bb.width());
|
2679
|
+
var height = Math.floor(bb.height());
|
2680
|
+
|
2681
|
+
// temporarily remove filter to avoid recursion
|
2682
|
+
var filter = element.style('filter').value;
|
2683
|
+
element.style('filter').value = '';
|
2684
|
+
|
2685
|
+
var px = 0, py = 0;
|
2686
|
+
for (var i=0; i<this.children.length; i++) {
|
2687
|
+
var efd = this.children[i].extraFilterDistance || 0;
|
2688
|
+
px = Math.max(px, efd);
|
2689
|
+
py = Math.max(py, efd);
|
2690
|
+
}
|
2691
|
+
|
2692
|
+
var c = document.createElement('canvas');
|
2693
|
+
c.width = width + 2*px;
|
2694
|
+
c.height = height + 2*py;
|
2695
|
+
var tempCtx = c.getContext('2d');
|
2696
|
+
tempCtx.translate(-x + px, -y + py);
|
2697
|
+
element.render(tempCtx);
|
2698
|
+
|
2699
|
+
// apply filters
|
2700
|
+
for (var i=0; i<this.children.length; i++) {
|
2701
|
+
if (typeof(this.children[i].apply) === 'function') {
|
2702
|
+
this.children[i].apply(tempCtx, 0, 0, width + 2*px, height + 2*py);
|
2703
|
+
}
|
2704
|
+
}
|
2705
|
+
|
2706
|
+
// render on me
|
2707
|
+
ctx.drawImage(c, 0, 0, width + 2*px, height + 2*py, x - px, y - py, width + 2*px, height + 2*py);
|
2708
|
+
|
2709
|
+
// reassign filter
|
2710
|
+
element.style('filter', true).value = filter;
|
2711
|
+
}
|
2712
|
+
|
2713
|
+
this.render = function(ctx) {
|
2714
|
+
// NO RENDER
|
2715
|
+
}
|
2716
|
+
}
|
2717
|
+
svg.Element.filter.prototype = new svg.Element.ElementBase;
|
2718
|
+
|
2719
|
+
svg.Element.feMorphology = function(node) {
|
2720
|
+
this.base = svg.Element.ElementBase;
|
2721
|
+
this.base(node);
|
2722
|
+
|
2723
|
+
this.apply = function(ctx, x, y, width, height) {
|
2724
|
+
// TODO: implement
|
2725
|
+
}
|
2726
|
+
}
|
2727
|
+
svg.Element.feMorphology.prototype = new svg.Element.ElementBase;
|
2728
|
+
|
2729
|
+
svg.Element.feComposite = function(node) {
|
2730
|
+
this.base = svg.Element.ElementBase;
|
2731
|
+
this.base(node);
|
2732
|
+
|
2733
|
+
this.apply = function(ctx, x, y, width, height) {
|
2734
|
+
// TODO: implement
|
2735
|
+
}
|
2736
|
+
}
|
2737
|
+
svg.Element.feComposite.prototype = new svg.Element.ElementBase;
|
2738
|
+
|
2739
|
+
svg.Element.feColorMatrix = function(node) {
|
2740
|
+
this.base = svg.Element.ElementBase;
|
2741
|
+
this.base(node);
|
2742
|
+
|
2743
|
+
var matrix = svg.ToNumberArray(this.attribute('values').value);
|
2744
|
+
switch (this.attribute('type').valueOrDefault('matrix')) { // http://www.w3.org/TR/SVG/filters.html#feColorMatrixElement
|
2745
|
+
case 'saturate':
|
2746
|
+
var s = matrix[0];
|
2747
|
+
matrix = [0.213+0.787*s,0.715-0.715*s,0.072-0.072*s,0,0,
|
2748
|
+
0.213-0.213*s,0.715+0.285*s,0.072-0.072*s,0,0,
|
2749
|
+
0.213-0.213*s,0.715-0.715*s,0.072+0.928*s,0,0,
|
2750
|
+
0,0,0,1,0,
|
2751
|
+
0,0,0,0,1];
|
2752
|
+
break;
|
2753
|
+
case 'hueRotate':
|
2754
|
+
var a = matrix[0] * Math.PI / 180.0;
|
2755
|
+
var c = function (m1,m2,m3) { return m1 + Math.cos(a)*m2 + Math.sin(a)*m3; };
|
2756
|
+
matrix = [c(0.213,0.787,-0.213),c(0.715,-0.715,-0.715),c(0.072,-0.072,0.928),0,0,
|
2757
|
+
c(0.213,-0.213,0.143),c(0.715,0.285,0.140),c(0.072,-0.072,-0.283),0,0,
|
2758
|
+
c(0.213,-0.213,-0.787),c(0.715,-0.715,0.715),c(0.072,0.928,0.072),0,0,
|
2759
|
+
0,0,0,1,0,
|
2760
|
+
0,0,0,0,1];
|
2761
|
+
break;
|
2762
|
+
case 'luminanceToAlpha':
|
2763
|
+
matrix = [0,0,0,0,0,
|
2764
|
+
0,0,0,0,0,
|
2765
|
+
0,0,0,0,0,
|
2766
|
+
0.2125,0.7154,0.0721,0,0,
|
2767
|
+
0,0,0,0,1];
|
2768
|
+
break;
|
2769
|
+
}
|
2770
|
+
|
2771
|
+
function imGet(img, x, y, width, height, rgba) {
|
2772
|
+
return img[y*width*4 + x*4 + rgba];
|
2773
|
+
}
|
2774
|
+
|
2775
|
+
function imSet(img, x, y, width, height, rgba, val) {
|
2776
|
+
img[y*width*4 + x*4 + rgba] = val;
|
2777
|
+
}
|
2778
|
+
|
2779
|
+
function m(i, v) {
|
2780
|
+
var mi = matrix[i];
|
2781
|
+
return mi * (mi < 0 ? v - 255 : v);
|
2782
|
+
}
|
2783
|
+
|
2784
|
+
this.apply = function(ctx, x, y, width, height) {
|
2785
|
+
// assuming x==0 && y==0 for now
|
2786
|
+
var srcData = ctx.getImageData(0, 0, width, height);
|
2787
|
+
for (var y = 0; y < height; y++) {
|
2788
|
+
for (var x = 0; x < width; x++) {
|
2789
|
+
var r = imGet(srcData.data, x, y, width, height, 0);
|
2790
|
+
var g = imGet(srcData.data, x, y, width, height, 1);
|
2791
|
+
var b = imGet(srcData.data, x, y, width, height, 2);
|
2792
|
+
var a = imGet(srcData.data, x, y, width, height, 3);
|
2793
|
+
imSet(srcData.data, x, y, width, height, 0, m(0,r)+m(1,g)+m(2,b)+m(3,a)+m(4,1));
|
2794
|
+
imSet(srcData.data, x, y, width, height, 1, m(5,r)+m(6,g)+m(7,b)+m(8,a)+m(9,1));
|
2795
|
+
imSet(srcData.data, x, y, width, height, 2, m(10,r)+m(11,g)+m(12,b)+m(13,a)+m(14,1));
|
2796
|
+
imSet(srcData.data, x, y, width, height, 3, m(15,r)+m(16,g)+m(17,b)+m(18,a)+m(19,1));
|
2797
|
+
}
|
2798
|
+
}
|
2799
|
+
ctx.clearRect(0, 0, width, height);
|
2800
|
+
ctx.putImageData(srcData, 0, 0);
|
2801
|
+
}
|
2802
|
+
}
|
2803
|
+
svg.Element.feColorMatrix.prototype = new svg.Element.ElementBase;
|
2804
|
+
|
2805
|
+
svg.Element.feGaussianBlur = function(node) {
|
2806
|
+
this.base = svg.Element.ElementBase;
|
2807
|
+
this.base(node);
|
2808
|
+
|
2809
|
+
this.blurRadius = Math.floor(this.attribute('stdDeviation').numValue());
|
2810
|
+
this.extraFilterDistance = this.blurRadius;
|
2811
|
+
|
2812
|
+
this.apply = function(ctx, x, y, width, height) {
|
2813
|
+
if (typeof(stackBlur.canvasRGBA) == 'undefined') {
|
2814
|
+
svg.log('ERROR: StackBlur.js must be included for blur to work');
|
2815
|
+
return;
|
2816
|
+
}
|
2817
|
+
|
2818
|
+
// StackBlur requires canvas be on document
|
2819
|
+
ctx.canvas.id = svg.UniqueId();
|
2820
|
+
ctx.canvas.style.display = 'none';
|
2821
|
+
document.body.appendChild(ctx.canvas);
|
2822
|
+
stackBlur.canvasRGBA(ctx.canvas.id, x, y, width, height, this.blurRadius);
|
2823
|
+
document.body.removeChild(ctx.canvas);
|
2824
|
+
}
|
2825
|
+
}
|
2826
|
+
svg.Element.feGaussianBlur.prototype = new svg.Element.ElementBase;
|
2827
|
+
|
2828
|
+
// title element, do nothing
|
2829
|
+
svg.Element.title = function(node) {
|
2830
|
+
}
|
2831
|
+
svg.Element.title.prototype = new svg.Element.ElementBase;
|
2832
|
+
|
2833
|
+
// desc element, do nothing
|
2834
|
+
svg.Element.desc = function(node) {
|
2835
|
+
}
|
2836
|
+
svg.Element.desc.prototype = new svg.Element.ElementBase;
|
2837
|
+
|
2838
|
+
svg.Element.MISSING = function(node) {
|
2839
|
+
svg.log('ERROR: Element \'' + node.nodeName + '\' not yet implemented.');
|
2840
|
+
}
|
2841
|
+
svg.Element.MISSING.prototype = new svg.Element.ElementBase;
|
2842
|
+
|
2843
|
+
// element factory
|
2844
|
+
svg.CreateElement = function(node) {
|
2845
|
+
var className = node.nodeName.replace(/^[^:]+:/,''); // remove namespace
|
2846
|
+
className = className.replace(/\-/g,''); // remove dashes
|
2847
|
+
var e = null;
|
2848
|
+
if (typeof(svg.Element[className]) != 'undefined') {
|
2849
|
+
e = new svg.Element[className](node);
|
2850
|
+
}
|
2851
|
+
else {
|
2852
|
+
e = new svg.Element.MISSING(node);
|
2853
|
+
}
|
2854
|
+
|
2855
|
+
e.type = node.nodeName;
|
2856
|
+
return e;
|
2857
|
+
}
|
2858
|
+
|
2859
|
+
// load from url
|
2860
|
+
svg.load = function(ctx, url) {
|
2861
|
+
svg.loadXml(ctx, svg.ajax(url));
|
2862
|
+
}
|
2863
|
+
|
2864
|
+
// load from xml
|
2865
|
+
svg.loadXml = function(ctx, xml) {
|
2866
|
+
svg.loadXmlDoc(ctx, svg.parseXml(xml));
|
2867
|
+
}
|
2868
|
+
|
2869
|
+
svg.loadXmlDoc = function(ctx, dom) {
|
2870
|
+
svg.init(ctx);
|
2871
|
+
|
2872
|
+
var mapXY = function(p) {
|
2873
|
+
var e = ctx.canvas;
|
2874
|
+
while (e) {
|
2875
|
+
p.x -= e.offsetLeft;
|
2876
|
+
p.y -= e.offsetTop;
|
2877
|
+
e = e.offsetParent;
|
2878
|
+
}
|
2879
|
+
if (window.scrollX) p.x += window.scrollX;
|
2880
|
+
if (window.scrollY) p.y += window.scrollY;
|
2881
|
+
return p;
|
2882
|
+
}
|
2883
|
+
|
2884
|
+
// bind mouse
|
2885
|
+
if (svg.opts['ignoreMouse'] != true) {
|
2886
|
+
ctx.canvas.onclick = function(e) {
|
2887
|
+
var p = mapXY(new svg.Point(e != null ? e.clientX : event.clientX, e != null ? e.clientY : event.clientY));
|
2888
|
+
svg.Mouse.onclick(p.x, p.y);
|
2889
|
+
};
|
2890
|
+
ctx.canvas.onmousemove = function(e) {
|
2891
|
+
var p = mapXY(new svg.Point(e != null ? e.clientX : event.clientX, e != null ? e.clientY : event.clientY));
|
2892
|
+
svg.Mouse.onmousemove(p.x, p.y);
|
2893
|
+
};
|
2894
|
+
}
|
2895
|
+
|
2896
|
+
var e = svg.CreateElement(dom.documentElement);
|
2897
|
+
e.root = true;
|
2898
|
+
e.addStylesFromStyleDefinition();
|
2899
|
+
|
2900
|
+
// render loop
|
2901
|
+
var isFirstRender = true;
|
2902
|
+
var draw = function() {
|
2903
|
+
svg.ViewPort.Clear();
|
2904
|
+
if (ctx.canvas.parentNode) svg.ViewPort.SetCurrent(ctx.canvas.parentNode.clientWidth, ctx.canvas.parentNode.clientHeight);
|
2905
|
+
|
2906
|
+
if (svg.opts['ignoreDimensions'] != true) {
|
2907
|
+
// set canvas size
|
2908
|
+
if (e.style('width').hasValue()) {
|
2909
|
+
ctx.canvas.width = e.style('width').toPixels('x');
|
2910
|
+
ctx.canvas.style.width = ctx.canvas.width + 'px';
|
2911
|
+
}
|
2912
|
+
if (e.style('height').hasValue()) {
|
2913
|
+
ctx.canvas.height = e.style('height').toPixels('y');
|
2914
|
+
ctx.canvas.style.height = ctx.canvas.height + 'px';
|
2915
|
+
}
|
2916
|
+
}
|
2917
|
+
var cWidth = ctx.canvas.clientWidth || ctx.canvas.width;
|
2918
|
+
var cHeight = ctx.canvas.clientHeight || ctx.canvas.height;
|
2919
|
+
if (svg.opts['ignoreDimensions'] == true && e.style('width').hasValue() && e.style('height').hasValue()) {
|
2920
|
+
cWidth = e.style('width').toPixels('x');
|
2921
|
+
cHeight = e.style('height').toPixels('y');
|
2922
|
+
}
|
2923
|
+
svg.ViewPort.SetCurrent(cWidth, cHeight);
|
2924
|
+
|
2925
|
+
if (svg.opts['offsetX'] != null) e.attribute('x', true).value = svg.opts['offsetX'];
|
2926
|
+
if (svg.opts['offsetY'] != null) e.attribute('y', true).value = svg.opts['offsetY'];
|
2927
|
+
if (svg.opts['scaleWidth'] != null || svg.opts['scaleHeight'] != null) {
|
2928
|
+
var xRatio = null, yRatio = null, viewBox = svg.ToNumberArray(e.attribute('viewBox').value);
|
2929
|
+
|
2930
|
+
if (svg.opts['scaleWidth'] != null) {
|
2931
|
+
if (e.attribute('width').hasValue()) xRatio = e.attribute('width').toPixels('x') / svg.opts['scaleWidth'];
|
2932
|
+
else if (!isNaN(viewBox[2])) xRatio = viewBox[2] / svg.opts['scaleWidth'];
|
2933
|
+
}
|
2934
|
+
|
2935
|
+
if (svg.opts['scaleHeight'] != null) {
|
2936
|
+
if (e.attribute('height').hasValue()) yRatio = e.attribute('height').toPixels('y') / svg.opts['scaleHeight'];
|
2937
|
+
else if (!isNaN(viewBox[3])) yRatio = viewBox[3] / svg.opts['scaleHeight'];
|
2938
|
+
}
|
2939
|
+
|
2940
|
+
if (xRatio == null) { xRatio = yRatio; }
|
2941
|
+
if (yRatio == null) { yRatio = xRatio; }
|
2942
|
+
|
2943
|
+
e.attribute('width', true).value = svg.opts['scaleWidth'];
|
2944
|
+
e.attribute('height', true).value = svg.opts['scaleHeight'];
|
2945
|
+
e.style('transform', true, true).value += ' scale('+(1.0/xRatio)+','+(1.0/yRatio)+')';
|
2946
|
+
}
|
2947
|
+
|
2948
|
+
// clear and render
|
2949
|
+
if (svg.opts['ignoreClear'] != true) {
|
2950
|
+
ctx.clearRect(0, 0, cWidth, cHeight);
|
2951
|
+
}
|
2952
|
+
e.render(ctx);
|
2953
|
+
if (isFirstRender) {
|
2954
|
+
isFirstRender = false;
|
2955
|
+
if (typeof(svg.opts['renderCallback']) == 'function') svg.opts['renderCallback'](dom);
|
2956
|
+
}
|
2957
|
+
}
|
2958
|
+
|
2959
|
+
var waitingForImages = true;
|
2960
|
+
if (svg.ImagesLoaded()) {
|
2961
|
+
waitingForImages = false;
|
2962
|
+
draw();
|
2963
|
+
}
|
2964
|
+
svg.intervalID = setInterval(function() {
|
2965
|
+
var needUpdate = false;
|
2966
|
+
|
2967
|
+
if (waitingForImages && svg.ImagesLoaded()) {
|
2968
|
+
waitingForImages = false;
|
2969
|
+
needUpdate = true;
|
2970
|
+
}
|
2971
|
+
|
2972
|
+
// need update from mouse events?
|
2973
|
+
if (svg.opts['ignoreMouse'] != true) {
|
2974
|
+
needUpdate = needUpdate | svg.Mouse.hasEvents();
|
2975
|
+
}
|
2976
|
+
|
2977
|
+
// need update from animations?
|
2978
|
+
if (svg.opts['ignoreAnimation'] != true) {
|
2979
|
+
for (var i=0; i<svg.Animations.length; i++) {
|
2980
|
+
needUpdate = needUpdate | svg.Animations[i].update(1000 / svg.FRAMERATE);
|
2981
|
+
}
|
2982
|
+
}
|
2983
|
+
|
2984
|
+
// need update from redraw?
|
2985
|
+
if (typeof(svg.opts['forceRedraw']) == 'function') {
|
2986
|
+
if (svg.opts['forceRedraw']() == true) needUpdate = true;
|
2987
|
+
}
|
2988
|
+
|
2989
|
+
// render if needed
|
2990
|
+
if (needUpdate) {
|
2991
|
+
draw();
|
2992
|
+
svg.Mouse.runEvents(); // run and clear our events
|
2993
|
+
}
|
2994
|
+
}, 1000 / svg.FRAMERATE);
|
2995
|
+
}
|
2996
|
+
|
2997
|
+
svg.stop = function() {
|
2998
|
+
if (svg.intervalID) {
|
2999
|
+
clearInterval(svg.intervalID);
|
3000
|
+
}
|
3001
|
+
}
|
3002
|
+
|
3003
|
+
svg.Mouse = new (function() {
|
3004
|
+
this.events = [];
|
3005
|
+
this.hasEvents = function() { return this.events.length != 0; }
|
3006
|
+
|
3007
|
+
this.onclick = function(x, y) {
|
3008
|
+
this.events.push({ type: 'onclick', x: x, y: y,
|
3009
|
+
run: function(e) { if (e.onclick) e.onclick(); }
|
3010
|
+
});
|
3011
|
+
}
|
3012
|
+
|
3013
|
+
this.onmousemove = function(x, y) {
|
3014
|
+
this.events.push({ type: 'onmousemove', x: x, y: y,
|
3015
|
+
run: function(e) { if (e.onmousemove) e.onmousemove(); }
|
3016
|
+
});
|
3017
|
+
}
|
3018
|
+
|
3019
|
+
this.eventElements = [];
|
3020
|
+
|
3021
|
+
this.checkPath = function(element, ctx) {
|
3022
|
+
for (var i=0; i<this.events.length; i++) {
|
3023
|
+
var e = this.events[i];
|
3024
|
+
if (ctx.isPointInPath && ctx.isPointInPath(e.x, e.y)) this.eventElements[i] = element;
|
3025
|
+
}
|
3026
|
+
}
|
3027
|
+
|
3028
|
+
this.checkBoundingBox = function(element, bb) {
|
3029
|
+
for (var i=0; i<this.events.length; i++) {
|
3030
|
+
var e = this.events[i];
|
3031
|
+
if (bb.isPointInBox(e.x, e.y)) this.eventElements[i] = element;
|
3032
|
+
}
|
3033
|
+
}
|
3034
|
+
|
3035
|
+
this.runEvents = function() {
|
3036
|
+
svg.ctx.canvas.style.cursor = '';
|
3037
|
+
|
3038
|
+
for (var i=0; i<this.events.length; i++) {
|
3039
|
+
var e = this.events[i];
|
3040
|
+
var element = this.eventElements[i];
|
3041
|
+
while (element) {
|
3042
|
+
e.run(element);
|
3043
|
+
element = element.parent;
|
3044
|
+
}
|
3045
|
+
}
|
3046
|
+
|
3047
|
+
// done running, clear
|
3048
|
+
this.events = [];
|
3049
|
+
this.eventElements = [];
|
3050
|
+
}
|
3051
|
+
});
|
3052
|
+
|
3053
|
+
return svg;
|
3054
|
+
};
|
3055
|
+
|
3056
|
+
if (typeof(CanvasRenderingContext2D) != 'undefined') {
|
3057
|
+
CanvasRenderingContext2D.prototype.drawSvg = function(s, dx, dy, dw, dh) {
|
3058
|
+
canvg(this.canvas, s, {
|
3059
|
+
ignoreMouse: true,
|
3060
|
+
ignoreAnimation: true,
|
3061
|
+
ignoreDimensions: true,
|
3062
|
+
ignoreClear: true,
|
3063
|
+
offsetX: dx,
|
3064
|
+
offsetY: dy,
|
3065
|
+
scaleWidth: dw,
|
3066
|
+
scaleHeight: dh
|
3067
|
+
});
|
3068
|
+
}
|
3069
|
+
}
|
3070
|
+
|
3071
|
+
return canvg;
|
3072
|
+
|
3073
|
+
}));
|