lib/generator.js
function generateLetterIcon(letter, cb) {
    // Derive SVG from base letter SVG
    var letterSVG = baseSVG;
    
    // Get a random Material Design color
    var color = getRandomLetterColor();
    
    // Substitude placeholders for color and letter
    letterSVG = letterSVG.replace('{c}', color);
    letterSVG = letterSVG.replace('{x}', letter);
    
    // Get filesystem-friendly file name for letter
    var fileName = getIconFilename(letter);
    
    // Define SVG/PNG output path
    var outputSVGPath = rootDir + config.dist.path + config.dist.svg.outputPath + fileName + '.svg';
    var outputPNGPath = rootDir + config.dist.path + config.dist.png.outputPath + fileName + '.png';
    
    // Export the letter as an SVG file
    fs.writeFileSync(outputSVGPath, letterSVG);
    
    // Convert the SVG file into a PNG file using svg2png
    svg2png(new Buffer(letterSVG), config.dist.png.dimensions)
    .then(function (buffer) {
        // Write to disk
        fs.writeFileSync(outputPNGPath, buffer);

        // Success
        cb();
    }).catch(function (err) {
        // Report error
        return cb(err);
    });
}
function generateLetterIcon(letter, cb) {
    // Derive SVG from base letter SVG
    var letterSVG = baseSVG;
    
    // Get a random Material Design color
    var color = getRandomLetterColor();
    
    // Substitude placeholders for color and letter
    letterSVG = letterSVG.replace('{c}', color);
    letterSVG = letterSVG.replace('{x}', letter);
    
    // Get filesystem-friendly file name for letter
    var fileName = getIconFilename(letter);
    
    // Define SVG/PNG output path
    var outputSVGPath = rootDir + config.dist.path + config.dist.svg.outputPath + fileName + '.svg';
    var outputPNGPath = rootDir + config.dist.path + config.dist.png.outputPath + fileName + '.png';
    
    // Export the letter as an SVG file
    fs.writeFileSync(outputSVGPath, letterSVG);
    
    // Convert the SVG file into a PNG file using svg2png
    svg2png(new Buffer(letterSVG), config.dist.png.dimensions)
    .then(function (buffer) {
        // Write to disk
        fs.writeFileSync(outputPNGPath, buffer);

        // Success
        cb();
    }).catch(function (err) {
        // Report error
        return cb(err);
    });
}
function generateLetterIcon ( letter , cb ) { // Derive SVG from base letter SVG var letterSVG = baseSVG ; // Get a random Material Design color var color = getRandomLetterColor ( ) ; // Substitude placeholders for color and letter letterSVG = letterSVG . replace ( '{c}' , color ) ; letterSVG = letterSVG . replace ( '{x}' , letter ) ; // Get filesystem-friendly file name for letter var fileName = getIconFilename ( letter ) ; // Define SVG/PNG output path var outputSVGPath = rootDir + config . dist . path + config . dist . svg . outputPath + fileName + '.svg' ; var outputPNGPath = rootDir + config . dist . path + config . dist . png . outputPath + fileName + '.png' ; // Export the letter as an SVG file fs . writeFileSync ( outputSVGPath , letterSVG ) ; // Convert the SVG file into a PNG file using svg2png svg2png ( new Buffer ( letterSVG ) , config . dist . png . dimensions ) . then ( function ( buffer ) { // Write to disk fs . writeFileSync ( outputPNGPath , buffer ) ; // Success cb ( ) ; } ) . catch ( function ( err ) { // Report error return cb ( err ) ; } ) ; }
Generates icons for a single letter
Generates icons for a single letter