Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Forbes Lindesay committed Nov 10, 2012
1 parent eee600d commit b8c2052
Showing 1 changed file with 15 additions and 20 deletions.
35 changes: 15 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
[![Build Status](https://secure.travis-ci.org/microjs/histogram.png?branch=master)](https://travis-ci.org/microjs/histogram)
Histogram
=========

Provides a histogram data structure from PNG, JPEG or GIF files using canvas.
This library works in nodejs and in any canvas supporting browser using <a href="https://raw.github.com/Munter/node-histogram/master/histogram.min.js">histogram.min.js</a>.
In the browser histogram will be available in `window.histogram`
You can also use require.js instead, keeping your global scope clean.
This library works in nodejs and in any canvas supporting browser.

Install npm:

npm install histogram

Install client:

component install microjs/histogram


Example usage
Expand All @@ -15,30 +22,18 @@ NodeJS
var histogram = require('histogram');

histogram(fileName || Buffer, function (data) {
console.log(filePath + ' has ' + data.colors.rgba + ' colors');
console.log(filePath + ' has ' + data.colors.rgba + ' colors');
});
```

Browser with require.js
Browser with component
``` javascript
require(['path/to/histogram.min.js'], function (histogram) {
histogram(URL || FileReader.result, function (data) {
console.log(filePath + ' has ' + data.colors.rgba + ' colors');
});
var histogram = require('histogram');
histogram(URL || FileReader.result, function (data) {
console.log(filePath + ' has ' + data.colors.rgba + ' colors');
});
```

Vanilla browser
``` html
<script src="path/to/histogram.min.js"></script>
<script>
histogram(URL || FileReader.result, function (data) {
console.log(filePath + ' has ' + data.colors.rgba + ' colors');
});
</script>
```


Data structure
--------------
``` javascript
Expand Down

0 comments on commit b8c2052

Please sign in to comment.