Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hughsk/opaque
Detect whether an image or canvas element contains any transparent pixels.
https://github.com/hughsk/opaque
Last synced: 8 days ago
JSON representation
Detect whether an image or canvas element contains any transparent pixels.
- Host: GitHub
- URL: https://github.com/hughsk/opaque
- Owner: hughsk
- License: other
- Created: 2013-01-30T01:10:03.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2013-01-30T01:48:11.000Z (almost 12 years ago)
- Last Synced: 2024-10-17T16:39:06.483Z (22 days ago)
- Language: JavaScript
- Size: 111 KB
- Stars: 3
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# opaque #
Browserify module for detecting if an image or canvas element has transparent
pixels.## Installation ##
Using [NPM](http://npmjs.org) and [Browserify](http://github.com/substack/node-browserify):
``` bash
npm install opaque
```As a [component](http://github.com/component/component):
``` bash
component install hughsk/opaque
```## Usage ##
`opaque(element)`
Returns `false` if transparent, or `true` if not.
`opaque.transparent(element)`
The opposite of `opaque`: `true` if transparent, `false` if not.
``` javascript
var opaque = require('opaque')
, transparent = require('opaque').transparentvar brick = new Image
brick.src = '/brick.png'
brick.onload = function() {
opaque(brick) // true
transparent(brick) // false
};var glass = new Image
glass.src = '/glass.png'
glass.onload = function() {
opaque(glass) // false
transparent(glass) // true
};
```*Note that an image must be fully loaded before being checked.*