Resizing of the SVG in the preload

One of the main qualities of SVG images, is its scalability, not being able to use this, is to reduce it to be a bit more image. An SVG file has an XML format, so it can be modified with the DOM.
In order to collaborate, I have put the option to modify the parameters of the SVG and in this way make it adaptable.
The modification gives the option of being able to choose the size in the preload to which you want to have the image before rasterizing it; And so avoid the subsequent scaling that will not have the same quality.
You can see the example here: 
https://www.youtube.com/watch?v=Kd7pNjY-FLk
tested in version 3.11 It does not interfere with the original code.
This commit is contained in:
YsraelJMM 2018-08-17 12:37:35 -05:00 committed by GitHub
parent f46bd2cacd
commit 1816e529e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -83,7 +83,23 @@ var SVGFile = new Class({
{
this.state = CONST.FILE_PROCESSING;
var svg = [ this.xhrLoader.responseText ];
var rText = this.xhrLoader.responseText,
svg = [rText],
configWidth = this.xhrSettings.width,
configHeight = this.xhrSettings.height;
if (configWidth && configHeight) {
var xD = null,
parser = new DOMParser();
xD = parser.parseFromString(rText, "text/xml");
var svgXML = xD.getElementsByTagName("svg")[0];
gA = (a) => svgXML.getAttribute(a);
sA = (a, b) => svgXML.setAttribute(a, b);
gA('viewBox') ? '' : sA('viewBox', '0 0 ' + gA('width') + ' ' + gA('height'));
sA('width', configWidth);
sA('height', configHeight);
svg = [(new XMLSerializer()).serializeToString(svgXML)];
}
try
{