From c437e7a3973c2d00aee21b901c6743b9a052635c Mon Sep 17 00:00:00 2001 From: codecalm Date: Thu, 5 Mar 2020 23:48:52 +0100 Subject: news, refresh, sticker, archive, stroke icons --- gulpfile.js | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) (limited to 'gulpfile.js') diff --git a/gulpfile.js b/gulpfile.js index a0d8a9f..a60efe6 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -51,7 +51,47 @@ gulp.task('icons-sprite', function (cb) { }); }); -gulp.task('optimize', function(cb){ +gulp.task('icons-stroke', function (cb) { + + const icon = "disabled", + strokes = ['.5', '1', '1.5', '2', '2.75'], + svgFileContent = fs.readFileSync(`_site/icons/tabler-${icon}.svg`).toString(), + padding = 32, + paddingOuter = 32, + iconSize = 128, + width = (strokes.length * (iconSize + padding) - padding) + paddingOuter * 2, + height = iconSize + paddingOuter * 2; + + let svgContentSymbols = '', + svgContentIcons = '', + x = paddingOuter; + + console.log('width', width); + + strokes.forEach(function (stroke) { + console.log('stroke', stroke); + + let svgFileContentStroked = svgFileContent + .replace('', '') + .replace(/\n\s+/g, ''); + + svgContentSymbols += `\t${svgFileContentStroked}\n`; + svgContentIcons += `\t\n`; + + x += padding + iconSize; + }); + + const svgContent = `\n${svgContentSymbols}\n${svgContentIcons}\n`; + + fs.writeFileSync('icons-stroke.svg', svgContent); + + cb(); +}); + +gulp.task('optimize', function (cb) { glob("_icons/*.svg", {}, function (er, files) { files.forEach(function (file, i) { @@ -66,7 +106,7 @@ gulp.task('optimize', function(cb){ .replace(/polyline points="([0-9.]+)\s([0-9.]+)\s([0-9.]+)\s([0-9.]+)"/g, 'line x1="$1" y1="$2" x2="$3" y2="$4"') .replace(/\s+"/g, '"') .replace(/\n\n+/g, "\n"); - + console.log('file', file); fs.writeFileSync(file, svgFileContent); -- cgit v1.2.1