Source
xxxxxxxxxx
* @param {mixed} type Type of SVG element or array of objects containing type, attribute and content fields.
/*
** Zabbix
** Copyright (C) 2001-2022 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
/**
* SVGCanvas class.
*
* Implements basic functionality needed to render SVG from JS.
*
* @param {object} options Canvas options.
* @param {number} options.width Canvas width (width attribute of a SVG image).
* @param {number} options.height Canvas height (height attribute of a SVG image).
* @param {boolean} options.mask Masking option for textarea elements (@see SVGCanvas.prototype.createTextarea)
* @param {boolean} shadowBuffer Shadow buffer (double buffering) support. If set to true, additional hidden
* group element is created within SVG.
*/
function SVGCanvas(options, shadowBuffer) {
this.options = options;
this.id = 0;
this.elements = [];
this.textPadding = 5;
this.maskColor = '#3d3d3d';
this.mask = false;
if (typeof options.mask !== 'undefined') {
this.mask = (options.mask === true);
}
if (typeof options.useViewBox !== 'boolean') {
options.useViewBox = false;
}
this.buffer = null;
var svg_options = options.useViewBox
? {
'viewBox': '0 0 ' + options.width + ' ' + options.height,
'style': 'max-width: ' + options.width + 'px; max-height: ' + options.height + 'px;',
'preserveAspectRatio': 'xMinYMin meet'
}
: {
'width': options.width,
'height': options.height
};
this.root = this.createElement('svg', svg_options, null);
if (shadowBuffer === true) {
this.buffer = this.root.add('g', {