Server IP : 108.163.255.210 / Your IP : 18.191.54.190 Web Server : Apache System : Linux blossom.urlnameserver.com 3.10.0-1160.80.1.el7.x86_64 #1 SMP Tue Nov 8 15:48:59 UTC 2022 x86_64 User : ( 1172) PHP Version : 7.2.34 Disable Function : eval,escapeshellarg,proc_close,proc_get_status,proc_nice,proc_open,symlink,system,pcntl_exec,getrusage,chown,chgp,closelog,openlog,syslog,define_syslog_variables,php_ini_loaded_file,getservbyname,getservbyport,posix_getgid,posix_getgrgid,proc_terminate,pfsockopen,apache_child_terminate,posix_mkfifo,posix_setpgid,posix_setuid,hypot,pg_host,pos,posix_access,posix_getcwd,posix_getservbyname,myshellexec,getpid,posix_getsid,posix_isatty,posix_kill,posix_mknod,posix_setgid,posix_setsid,posix_setuid,posix_times,posix_uname,ps_fill,posix_getpwuid,global,ini_restore,zip_open,zip_read,rar_open,bzopen,bzread,bzwrite,apache_get_modules,apache_get_version,phpversionphpinfo,php_ini_scanned_files,get_current_user,disk_total_space,diskfreespace,leak,imap_list,hypo,filedump,safe_mode,getmygid,apache_getenv,apache_setenv,bzread,bzwrite,bzopen,phpini,higlight_file,dos_conv,get_cwd,er_log,cmd,e_name,vdir,get_dir,only_read,ftok,ftpexec,posix_getpwnam,mysql_list_dbs,disk_free_space,session_save_path,confirm_phpdoc_compiled,zip_entry_rea,php_u,psockopen,crack_opendict,crack_getlastmessage,crack_closedict,crack_check,fpassthru,posix_get_last_error,posix_getlogin,posix_getgroups,posix_strerror,posix_getrlimit,posix_getpgrp,posix_getgrnam,pos,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/unilinki/public_html/indijourneys.com/node_modules/svgo/plugins/ |
Upload File : |
'use strict'; exports.type = 'perItem'; exports.active = false; exports.description = 'removes elements that are drawn outside of the viewbox (disabled by default)'; var SVGO = require('../lib/svgo.js'), _path = require('./_path.js'), intersects = _path.intersects, path2js = _path.path2js, viewBox, viewBoxJS; /** * Remove elements that are drawn outside of the viewbox. * * @param {Object} item current iteration item * @return {Boolean} if false, item will be filtered out * * @author JoshyPHP */ exports.fn = function(item) { if (item.isElem('path') && item.hasAttr('d') && typeof viewBox !== 'undefined') { // Consider that any item with a transform attribute or a M instruction // within the viewBox is visible if (hasTransform(item) || pathMovesWithinViewBox(item.attr('d').value)) { return true; } var pathJS = path2js(item); if (pathJS.length === 2) { // Use a closed clone of the path if it's too short for intersects() pathJS = JSON.parse(JSON.stringify(pathJS)); pathJS.push({ instruction: 'z' }); } return intersects(viewBoxJS, pathJS); } if (item.isElem('svg')) { parseViewBox(item); } return true; }; /** * Test whether given item or any of its ancestors has a transform attribute. * * @param {String} path * @return {Boolean} */ function hasTransform(item) { return item.hasAttr('transform') || (item.parentNode && hasTransform(item.parentNode)); } /** * Parse the viewBox coordinates and compute the JS representation of its path. * * @param {Object} svg svg element item */ function parseViewBox(svg) { var viewBoxData = ''; if (svg.hasAttr('viewBox')) { // Remove commas and plus signs, normalize and trim whitespace viewBoxData = svg.attr('viewBox').value; } else if (svg.hasAttr('height') && svg.hasAttr('width')) { viewBoxData = '0 0 ' + svg.attr('width').value + ' ' + svg.attr('height').value; } // Remove commas and plus signs, normalize and trim whitespace viewBoxData = viewBoxData.replace(/[,+]|px/g, ' ').replace(/\s+/g, ' ').replace(/^\s*|\s*$/g, ''); // Ensure that the dimensions are 4 values separated by space var m = /^(-?\d*\.?\d+) (-?\d*\.?\d+) (\d*\.?\d+) (\d*\.?\d+)$/.exec(viewBoxData); if (!m) { return; } // Store the viewBox boundaries viewBox = { left: parseFloat(m[1]), top: parseFloat(m[2]), right: parseFloat(m[1]) + parseFloat(m[3]), bottom: parseFloat(m[2]) + parseFloat(m[4]) }; var path = new SVGO().createContentItem({ elem: 'path', prefix: '', local: 'path' }); path.addAttr({ name: 'd', prefix: '', local: 'd', value: 'M' + m[1] + ' ' + m[2] + 'h' + m[3] + 'v' + m[4] + 'H' + m[1] + 'z' }); viewBoxJS = path2js(path); } /** * Test whether given path has a M instruction with coordinates within the viewBox. * * @param {String} path * @return {Boolean} */ function pathMovesWithinViewBox(path) { var regexp = /M\s*(-?\d*\.?\d+)(?!\d)\s*(-?\d*\.?\d+)/g, m; while (null !== (m = regexp.exec(path))) { if (m[1] >= viewBox.left && m[1] <= viewBox.right && m[2] >= viewBox.top && m[2] <= viewBox.bottom) { return true; } } return false; }