Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/component/favicon
Dynamic favicon library via data uris (canvas.toDataURL() etc)
https://github.com/component/favicon
Last synced: 12 days ago
JSON representation
Dynamic favicon library via data uris (canvas.toDataURL() etc)
- Host: GitHub
- URL: https://github.com/component/favicon
- Owner: component
- Created: 2012-08-28T05:16:30.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-08-23T12:01:03.000Z (over 11 years ago)
- Last Synced: 2024-05-08T17:12:29.720Z (8 months ago)
- Language: JavaScript
- Size: 68.4 KB
- Stars: 16
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
Awesome Lists containing this project
README
# Favicon
Dynamically change a favicon using a data uri string, typically
from `canvas.toDataURL()`.## Installation
```
$ component install component/favicon
```## Example
Count from 0 through 9:
```js
var icon = require('favicon');
var canvas = document.createElement('canvas');
canvas.width = canvas.height = 16;
var ctx = canvas.getContext('2d');
ctx.font = '16px Helvetica, Arial, sans-serif';var nums = [0,1,2,3,4,5,6,7,8,9];
var i = 0;setInterval(function(){
ctx.clearRect(0, 0, 16, 16);
var n = nums[i++ % 10];
ctx.fillText(n, 0, 15);
icon(canvas.toDataURL());
}, 300);
```## API
### icon(string)
Set the favicon to the given data uri `string`.
### icon.reset()
Reset to the original favicon.
## License
MIT