https://github.com/ndp/color_spy
jQuery plugin to calculate actual color values of DOM nodes
https://github.com/ndp/color_spy
Last synced: about 1 year ago
JSON representation
jQuery plugin to calculate actual color values of DOM nodes
- Host: GitHub
- URL: https://github.com/ndp/color_spy
- Owner: ndp
- Created: 2010-03-31T06:12:09.000Z (about 16 years ago)
- Default Branch: master
- Last Pushed: 2010-04-01T07:23:45.000Z (about 16 years ago)
- Last Synced: 2025-04-25T12:03:17.866Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 728 KB
- Stars: 8
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Purpose
Built so that could determine the color of an element on the page. This
was critical to being able to write a SIFR plugin that would work
in across a heterogenous set of elements. Could be useful in other
general purpose code.
Tested on Firefox, Chrome, Safari, IE7.
## Usage
alert($('.selector').backgroundColor());
### $(...).backgroundColor()
Returns the background color of the first element as a hex string. For example, #ff0000.
Traverses up the DOM until it finds an explicit color. Converts rgb, rgba and named colors
to their hex equivalents.
### $(...).color()
Returns the color of the first element. Traverses up the DOM until it finds an explicit color.
Converts rgb, rgba and named colors
to their hex equivalents.
### $.toHexColor(color)
Converts varioius formats to the standard size-color hex string.
## Demo & Development
Open **jquery.color_spy_spec.js**
Tests are written in ScrewUnit and included here.
## License
Copyright (c) Andrew J. Peterson / NDPSoftware All Rights Reserved. Use with permission only.