๐Ÿ“ฆ hapticdata / connect-favicon-canvas

connect middleware for generating server-side images and icons with node-canvas.

โ˜… 2 stars โ‘‚ 2 forks ๐Ÿ‘ 2 watching โš–๏ธ MIT License
๐Ÿ“ฅ Clone https://github.com/hapticdata/connect-favicon-canvas.git
HTTPS git clone https://github.com/hapticdata/connect-favicon-canvas.git
SSH git clone git@github.com:hapticdata/connect-favicon-canvas.git
CLI gh repo clone hapticdata/connect-favicon-canvas
Kyle Phillips Kyle Phillips added license, and npmignore, updated readme 361dc68 12 years ago ๐Ÿ“ History
๐Ÿ“‚ master View all commits โ†’
๐Ÿ“ test
๐Ÿ“„ .gitignore
๐Ÿ“„ .npmignore
๐Ÿ“„ favicon-canvas.js
๐Ÿ“„ LICENSE
๐Ÿ“„ Makefile
๐Ÿ“„ package.json
๐Ÿ“„ README.md
๐Ÿ“„ README.md

connect-favicon-canvas

connect middleware for generating server-side images and icons with node-canvas.

Install:

npm install connect-favicon-canvas

Example:

var connect = require('connect'),
        faviconCanvas = require('connect-favicon-canvas'),
        generator,
        rand,
        app;

    rand = function( arr ){
        return arr[ ~~(Math.random()*arr.length) ];
    };
    //draw an image using the canvas2d API    
    generator = function( canvas, next ){
        var ctx = canvas.getContext('2d');
        ctx.fillStyle = rand(['aquamarine','teal','red','yellow','lime']);
        var border = 8,
            sqSize = canvas.width - (border*2);
        ctx.fillRect( border, border, sqSize, sqSize );
        next();
    };
	//start a connect server that servers the generative /favicon.ico
    app = connect()
        .use(faviconCanvas( generator ))
        .use(faviconCanvas( generator, {
            route: '/apple-touch-icon-precomposed.png',
            size: 152
        }))
        .use(function( req, res ){
            res.end('Look at the tab! generative favicon!\n');
        })
        .listen(5000);

Released under MIT License, created by Kyle Phillips