first commit
This commit is contained in:
6
build/node_modules/tinycolor2/.npmignore
generated
vendored
Normal file
6
build/node_modules/tinycolor2/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
.DS_Store
|
||||
ehthumbs.db
|
||||
Icon?
|
||||
Thumbs.db
|
||||
node_modules
|
||||
.idea
|
||||
7
build/node_modules/tinycolor2/.travis.yml
generated
vendored
Normal file
7
build/node_modules/tinycolor2/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.11"
|
||||
before_script:
|
||||
- npm install -g grunt-cli
|
||||
script:
|
||||
- grunt default --verbose
|
||||
59
build/node_modules/tinycolor2/Gruntfile.js
generated
vendored
Normal file
59
build/node_modules/tinycolor2/Gruntfile.js
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
|
||||
module.exports = function(grunt) {
|
||||
|
||||
grunt.initConfig({
|
||||
pkg: grunt.file.readJSON('package.json'),
|
||||
meta: {
|
||||
banner: '// TinyColor v<%= pkg.version %>\n' +
|
||||
'// https://github.com/bgrins/TinyColor\n' +
|
||||
'// <%= grunt.template.today("yyyy-mm-dd") %>, Brian Grinstead, MIT License\n'
|
||||
},
|
||||
|
||||
uglify: {
|
||||
options: {
|
||||
mangle: true,
|
||||
banner: '<%= meta.banner %>'
|
||||
},
|
||||
dist: {
|
||||
files: {
|
||||
'dist/tinycolor-min.js': ['tinycolor.js']
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
qunit: {
|
||||
all: ['test/index.html']
|
||||
},
|
||||
|
||||
|
||||
jshint: {
|
||||
options: {
|
||||
browser: true,
|
||||
sub: true,
|
||||
globals: {
|
||||
jQuery: true
|
||||
}
|
||||
},
|
||||
all: ['tinycolor.js']
|
||||
},
|
||||
|
||||
docco: {
|
||||
debug: {
|
||||
src: ['tinycolor.js'],
|
||||
options: {
|
||||
output: 'docs/'
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||
grunt.loadNpmTasks('grunt-contrib-jshint');
|
||||
grunt.loadNpmTasks('grunt-contrib-qunit');
|
||||
grunt.loadNpmTasks('grunt-docco');
|
||||
|
||||
grunt.registerTask('default', ['jshint', 'qunit']);
|
||||
grunt.registerTask('version-bump', ['jshint', 'qunit', 'uglify', 'docco']);
|
||||
|
||||
};
|
||||
20
build/node_modules/tinycolor2/LICENSE
generated
vendored
Normal file
20
build/node_modules/tinycolor2/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
Copyright (c), Brian Grinstead, http://briangrinstead.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
469
build/node_modules/tinycolor2/README.md
generated
vendored
Normal file
469
build/node_modules/tinycolor2/README.md
generated
vendored
Normal file
@@ -0,0 +1,469 @@
|
||||
# TinyColor
|
||||
|
||||
## JavaScript color tooling
|
||||
|
||||
TinyColor is a small, fast library for color manipulation and conversion in JavaScript. It allows many forms of input, while providing color conversions and other color utility functions. It has no dependencies.
|
||||
|
||||
[](https://travis-ci.org/bgrins/TinyColor)
|
||||
|
||||
## Including in a browser
|
||||
|
||||
Download [tinycolor.js](https://raw.githubusercontent.com/bgrins/TinyColor/master/tinycolor.js) or install it with bower:
|
||||
|
||||
bower install tinycolor
|
||||
|
||||
Then just include it in the page in a `script` tag:
|
||||
```html
|
||||
<script type='text/javascript' src='tinycolor.js'></script>
|
||||
<script type='text/javascript'>
|
||||
var color = tinycolor("red");
|
||||
</script>
|
||||
```
|
||||
## Including in node
|
||||
|
||||
`tinycolor` may also be included as a [node](http://nodejs.org/) module like so:
|
||||
|
||||
npm install tinycolor2
|
||||
|
||||
Then it can be used in your script like so:
|
||||
```js
|
||||
var tinycolor = require("tinycolor2");
|
||||
var color = tinycolor("red");
|
||||
```
|
||||
## Usage
|
||||
|
||||
Call `tinycolor(input)` or `new tinycolor(input)`, and you will have an object with the following properties. See Accepted String Input and Accepted Object Input below for more information about what is accepted.
|
||||
|
||||
## Accepted String Input
|
||||
|
||||
The string parsing is very permissive. It is meant to make typing a color as input as easy as possible. All commas, percentages, parenthesis are optional, and most input allow either 0-1, 0%-100%, or 0-n (where n is either 100, 255, or 360 depending on the value).
|
||||
|
||||
HSL and HSV both require either 0%-100% or 0-1 for the `S`/`L`/`V` properties. The `H` (hue) can have values between 0%-100% or 0-360.
|
||||
|
||||
RGB input requires either 0-255 or 0%-100%.
|
||||
|
||||
If you call `tinycolor.fromRatio`, RGB and Hue input can also accept 0-1.
|
||||
|
||||
Here are some examples of string input:
|
||||
|
||||
### Hex, 8-digit (RGBA) Hex
|
||||
```js
|
||||
tinycolor("#000");
|
||||
tinycolor("000");
|
||||
tinycolor("#369C");
|
||||
tinycolor("369C");
|
||||
tinycolor("#f0f0f6");
|
||||
tinycolor("f0f0f6");
|
||||
tinycolor("#f0f0f688");
|
||||
tinycolor("f0f0f688");
|
||||
```
|
||||
### RGB, RGBA
|
||||
```js
|
||||
tinycolor("rgb (255, 0, 0)");
|
||||
tinycolor("rgb 255 0 0");
|
||||
tinycolor("rgba (255, 0, 0, .5)");
|
||||
tinycolor({ r: 255, g: 0, b: 0 });
|
||||
tinycolor.fromRatio({ r: 1, g: 0, b: 0 });
|
||||
tinycolor.fromRatio({ r: .5, g: .5, b: .5 });
|
||||
```
|
||||
### HSL, HSLA
|
||||
```js
|
||||
tinycolor("hsl(0, 100%, 50%)");
|
||||
tinycolor("hsla(0, 100%, 50%, .5)");
|
||||
tinycolor("hsl(0, 100%, 50%)");
|
||||
tinycolor("hsl 0 1.0 0.5");
|
||||
tinycolor({ h: 0, s: 1, l: .5 });
|
||||
tinycolor.fromRatio({ h: 1, s: 0, l: 0 });
|
||||
tinycolor.fromRatio({ h: .5, s: .5, l: .5 });
|
||||
```
|
||||
### HSV, HSVA
|
||||
```js
|
||||
tinycolor("hsv(0, 100%, 100%)");
|
||||
tinycolor("hsva(0, 100%, 100%, .5)");
|
||||
tinycolor("hsv (0 100% 100%)");
|
||||
tinycolor("hsv 0 1 1");
|
||||
tinycolor({ h: 0, s: 100, v: 100 });
|
||||
tinycolor.fromRatio({ h: 1, s: 0, v: 0 });
|
||||
tinycolor.fromRatio({ h: .5, s: .5, v: .5 });
|
||||
```
|
||||
### Named
|
||||
```js
|
||||
tinycolor("RED");
|
||||
tinycolor("blanchedalmond");
|
||||
tinycolor("darkblue");
|
||||
```
|
||||
### Accepted Object Input
|
||||
|
||||
If you are calling this from code, you may want to use object input. Here are some examples of the different types of accepted object inputs:
|
||||
|
||||
{ r: 255, g: 0, b: 0 }
|
||||
{ r: 255, g: 0, b: 0, a: .5 }
|
||||
{ h: 0, s: 100, l: 50 }
|
||||
{ h: 0, s: 100, v: 100 }
|
||||
|
||||
## Methods
|
||||
|
||||
### getFormat
|
||||
|
||||
Returns the format used to create the tinycolor instance
|
||||
```js
|
||||
var color = tinycolor("red");
|
||||
color.getFormat(); // "name"
|
||||
color = tinycolor({r:255, g:255, b:255});
|
||||
color.getFormat(); // "rgb"
|
||||
```
|
||||
|
||||
### getOriginalInput
|
||||
|
||||
Returns the input passed into the constructer used to create the tinycolor instance
|
||||
```js
|
||||
var color = tinycolor("red");
|
||||
color.getOriginalInput(); // "red"
|
||||
color = tinycolor({r:255, g:255, b:255});
|
||||
color.getOriginalInput(); // "{r: 255, g: 255, b: 255}"
|
||||
```
|
||||
|
||||
### isValid
|
||||
|
||||
Return a boolean indicating whether the color was successfully parsed. Note: if the color is not valid then it will act like `black` when being used with other methods.
|
||||
```js
|
||||
var color1 = tinycolor("red");
|
||||
color1.isValid(); // true
|
||||
color1.toHexString(); // "#ff0000"
|
||||
|
||||
var color2 = tinycolor("not a color");
|
||||
color2.isValid(); // false
|
||||
color2.toString(); // "#000000"
|
||||
```
|
||||
### getBrightness
|
||||
|
||||
Returns the perceived brightness of a color, from `0-255`, as defined by [Web Content Accessibility Guidelines (Version 1.0)](http://www.w3.org/TR/AERT#color-contrast).
|
||||
```js
|
||||
var color1 = tinycolor("#fff");
|
||||
color1.getBrightness(); // 255
|
||||
|
||||
var color2 = tinycolor("#000");
|
||||
color2.getBrightness(); // 0
|
||||
```
|
||||
### isLight
|
||||
|
||||
Return a boolean indicating whether the color's perceived brightness is light.
|
||||
```js
|
||||
var color1 = tinycolor("#fff");
|
||||
color1.isLight(); // true
|
||||
|
||||
var color2 = tinycolor("#000");
|
||||
color2.isLight(); // false
|
||||
```
|
||||
### isDark
|
||||
|
||||
Return a boolean indicating whether the color's perceived brightness is dark.
|
||||
```js
|
||||
var color1 = tinycolor("#fff");
|
||||
color1.isDark(); // false
|
||||
|
||||
var color2 = tinycolor("#000");
|
||||
color2.isDark(); // true
|
||||
```
|
||||
### getLuminance
|
||||
|
||||
Returns the perceived luminance of a color, from `0-1` as defined by [Web Content Accessibility Guidelines (Version 2.0).](http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef)
|
||||
```js
|
||||
var color1 = tinycolor("#fff");
|
||||
color1.getLuminance(); // 1
|
||||
|
||||
var color2 = tinycolor("#000");
|
||||
color2.getLuminance(); // 0
|
||||
```
|
||||
### getAlpha
|
||||
|
||||
Returns the alpha value of a color, from `0-1`.
|
||||
```js
|
||||
var color1 = tinycolor("rgba(255, 0, 0, .5)");
|
||||
color1.getAlpha(); // 0.5
|
||||
|
||||
var color2 = tinycolor("rgb(255, 0, 0)");
|
||||
color2.getAlpha(); // 1
|
||||
|
||||
var color3 = tinycolor("transparent");
|
||||
color3.getAlpha(); // 0
|
||||
```
|
||||
### setAlpha
|
||||
|
||||
Sets the alpha value on a current color. Accepted range is in between `0-1`.
|
||||
```js
|
||||
var color = tinycolor("red");
|
||||
color.getAlpha(); // 1
|
||||
color.setAlpha(.5);
|
||||
color.getAlpha(); // .5
|
||||
color.toRgbString(); // "rgba(255, 0, 0, .5)"
|
||||
```
|
||||
### String Representations
|
||||
|
||||
The following methods will return a property for the `alpha` value, which can be ignored: `toHsv`, `toHsl`, `toRgb`
|
||||
|
||||
### toHsv
|
||||
```js
|
||||
var color = tinycolor("red");
|
||||
color.toHsv(); // { h: 0, s: 1, v: 1, a: 1 }
|
||||
```
|
||||
### toHsvString
|
||||
```js
|
||||
var color = tinycolor("red");
|
||||
color.toHsvString(); // "hsv(0, 100%, 100%)"
|
||||
color.setAlpha(0.5);
|
||||
color.toHsvString(); // "hsva(0, 100%, 100%, 0.5)"
|
||||
```
|
||||
### toHsl
|
||||
```js
|
||||
var color = tinycolor("red");
|
||||
color.toHsl(); // { h: 0, s: 1, l: 0.5, a: 1 }
|
||||
```
|
||||
### toHslString
|
||||
```js
|
||||
var color = tinycolor("red");
|
||||
color.toHslString(); // "hsl(0, 100%, 50%)"
|
||||
color.setAlpha(0.5);
|
||||
color.toHslString(); // "hsla(0, 100%, 50%, 0.5)"
|
||||
```
|
||||
### toHex
|
||||
```js
|
||||
var color = tinycolor("red");
|
||||
color.toHex(); // "ff0000"
|
||||
```
|
||||
### toHexString
|
||||
```js
|
||||
var color = tinycolor("red");
|
||||
color.toHexString(); // "#ff0000"
|
||||
```
|
||||
### toHex8
|
||||
```js
|
||||
var color = tinycolor("red");
|
||||
color.toHex8(); // "ff0000ff"
|
||||
```
|
||||
### toHex8String
|
||||
```js
|
||||
var color = tinycolor("red");
|
||||
color.toHex8String(); // "#ff0000ff"
|
||||
```
|
||||
### toRgb
|
||||
```js
|
||||
var color = tinycolor("red");
|
||||
color.toRgb(); // { r: 255, g: 0, b: 0, a: 1 }
|
||||
```
|
||||
### toRgbString
|
||||
```js
|
||||
var color = tinycolor("red");
|
||||
color.toRgbString(); // "rgb(255, 0, 0)"
|
||||
color.setAlpha(0.5);
|
||||
color.toRgbString(); // "rgba(255, 0, 0, 0.5)"
|
||||
```
|
||||
### toPercentageRgb
|
||||
```js
|
||||
var color = tinycolor("red");
|
||||
color.toPercentageRgb() // { r: "100%", g: "0%", b: "0%", a: 1 }
|
||||
```
|
||||
### toPercentageRgbString
|
||||
```js
|
||||
var color = tinycolor("red");
|
||||
color.toPercentageRgbString(); // "rgb(100%, 0%, 0%)"
|
||||
color.setAlpha(0.5);
|
||||
color.toPercentageRgbString(); // "rgba(100%, 0%, 0%, 0.5)"
|
||||
```
|
||||
### toName
|
||||
```js
|
||||
var color = tinycolor("red");
|
||||
color.toName(); // "red"
|
||||
```
|
||||
### toFilter
|
||||
```
|
||||
var color = tinycolor("red");
|
||||
color.toFilter(); // "progid:DXImageTransform.Microsoft.gradient(startColorstr=#ffff0000,endColorstr=#ffff0000)"
|
||||
```
|
||||
### toString
|
||||
|
||||
Print to a string, depending on the input format. You can also override this by passing one of `"rgb", "prgb", "hex6", "hex3", "hex8", "name", "hsl", "hsv"` into the function.
|
||||
```js
|
||||
var color1 = tinycolor("red");
|
||||
color1.toString(); // "red"
|
||||
color1.toString("hsv"); // "hsv(0, 100%, 100%)"
|
||||
|
||||
var color2 = tinycolor("rgb(255, 0, 0)");
|
||||
color2.toString(); // "rgb(255, 0, 0)"
|
||||
color2.setAlpha(.5);
|
||||
color2.toString(); // "rgba(255, 0, 0, 0.5)"
|
||||
```
|
||||
### Color Modification
|
||||
|
||||
These methods manipulate the current color, and return it for chaining. For instance:
|
||||
```js
|
||||
tinycolor("red").lighten().desaturate().toHexString() // "#f53d3d"
|
||||
```
|
||||
### lighten
|
||||
|
||||
`lighten: function(amount = 10) -> TinyColor`. Lighten the color a given amount, from 0 to 100. Providing 100 will always return white.
|
||||
```js
|
||||
tinycolor("#f00").lighten().toString(); // "#ff3333"
|
||||
tinycolor("#f00").lighten(100).toString(); // "#ffffff"
|
||||
```
|
||||
### brighten
|
||||
|
||||
`brighten: function(amount = 10) -> TinyColor`. Brighten the color a given amount, from 0 to 100.
|
||||
```js
|
||||
tinycolor("#f00").brighten().toString(); // "#ff1919"
|
||||
```
|
||||
### darken
|
||||
|
||||
`darken: function(amount = 10) -> TinyColor`. Darken the color a given amount, from 0 to 100. Providing 100 will always return black.
|
||||
```js
|
||||
tinycolor("#f00").darken().toString(); // "#cc0000"
|
||||
tinycolor("#f00").darken(100).toString(); // "#000000"
|
||||
```
|
||||
### desaturate
|
||||
|
||||
`desaturate: function(amount = 10) -> TinyColor`. Desaturate the color a given amount, from 0 to 100. Providing 100 will is the same as calling `greyscale`.
|
||||
```js
|
||||
tinycolor("#f00").desaturate().toString(); // "#f20d0d"
|
||||
tinycolor("#f00").desaturate(100).toString(); // "#808080"
|
||||
```
|
||||
### saturate
|
||||
|
||||
`saturate: function(amount = 10) -> TinyColor`. Saturate the color a given amount, from 0 to 100.
|
||||
```js
|
||||
tinycolor("hsl(0, 10%, 50%)").saturate().toString(); // "hsl(0, 20%, 50%)"
|
||||
```
|
||||
### greyscale
|
||||
|
||||
`greyscale: function() -> TinyColor`. Completely desaturates a color into greyscale. Same as calling `desaturate(100)`.
|
||||
```js
|
||||
tinycolor("#f00").greyscale().toString(); // "#808080"
|
||||
```
|
||||
### spin
|
||||
|
||||
`spin: function(amount = 0) -> TinyColor`. Spin the hue a given amount, from -360 to 360. Calling with 0, 360, or -360 will do nothing (since it sets the hue back to what it was before).
|
||||
```js
|
||||
tinycolor("#f00").spin(180).toString(); // "#00ffff"
|
||||
tinycolor("#f00").spin(-90).toString(); // "#7f00ff"
|
||||
tinycolor("#f00").spin(90).toString(); // "#80ff00"
|
||||
|
||||
// spin(0) and spin(360) do nothing
|
||||
tinycolor("#f00").spin(0).toString(); // "#ff0000"
|
||||
tinycolor("#f00").spin(360).toString(); // "#ff0000"
|
||||
```
|
||||
### Color Combinations
|
||||
|
||||
Combination functions return an array of TinyColor objects unless otherwise noted.
|
||||
|
||||
### analogous
|
||||
|
||||
`analogous: function(, results = 6, slices = 30) -> array<TinyColor>`.
|
||||
```js
|
||||
var colors = tinycolor("#f00").analogous();
|
||||
|
||||
colors.map(function(t) { return t.toHexString(); }); // [ "#ff0000", "#ff0066", "#ff0033", "#ff0000", "#ff3300", "#ff6600" ]
|
||||
```
|
||||
### monochromatic
|
||||
|
||||
`monochromatic: function(, results = 6) -> array<TinyColor>`.
|
||||
```js
|
||||
var colors = tinycolor("#f00").monochromatic();
|
||||
|
||||
colors.map(function(t) { return t.toHexString(); }); // [ "#ff0000", "#2a0000", "#550000", "#800000", "#aa0000", "#d40000" ]
|
||||
```
|
||||
### splitcomplement
|
||||
|
||||
`splitcomplement: function() -> array<TinyColor>`.
|
||||
```js
|
||||
var colors = tinycolor("#f00").splitcomplement();
|
||||
|
||||
colors.map(function(t) { return t.toHexString(); }); // [ "#ff0000", "#ccff00", "#0066ff" ]
|
||||
```
|
||||
### triad
|
||||
|
||||
`triad: function() -> array<TinyColor>`.
|
||||
```js
|
||||
var colors = tinycolor("#f00").triad();
|
||||
|
||||
colors.map(function(t) { return t.toHexString(); }); // [ "#ff0000", "#00ff00", "#0000ff" ]
|
||||
```
|
||||
### tetrad
|
||||
|
||||
`tetrad: function() -> array<TinyColor>`.
|
||||
```js
|
||||
var colors = tinycolor("#f00").tetrad();
|
||||
|
||||
colors.map(function(t) { return t.toHexString(); }); // [ "#ff0000", "#80ff00", "#00ffff", "#7f00ff" ]
|
||||
|
||||
```
|
||||
### complement
|
||||
|
||||
`complement: function() -> TinyColor`.
|
||||
```js
|
||||
tinycolor("#f00").complement().toHexString(); // "#00ffff"
|
||||
```
|
||||
## Color Utilities
|
||||
```js
|
||||
tinycolor.equals(color1, color2)
|
||||
tinycolor.mix(color1, color2, amount = 50)
|
||||
```
|
||||
### random
|
||||
|
||||
Returns a random color.
|
||||
```js
|
||||
var color = tinycolor.random();
|
||||
color.toRgb(); // "{r: 145, g: 40, b: 198, a: 1}"
|
||||
```
|
||||
|
||||
### Readability
|
||||
|
||||
TinyColor assesses readability based on the [Web Content Accessibility Guidelines (Version 2.0)](http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef).
|
||||
|
||||
#### readability
|
||||
|
||||
`readability: function(TinyColor, TinyColor) -> Object`.
|
||||
Returns the contrast ratio between two colors.
|
||||
```js
|
||||
tinycolor.readability("#000", "#000"); // 1
|
||||
tinycolor.readability("#000", "#111"); // 1.1121078324840545
|
||||
tinycolor.readability("#000", "#fff"); // 21
|
||||
```
|
||||
Use the values in your own calculations, or use one of the convenience functions below.
|
||||
|
||||
#### isReadable
|
||||
|
||||
`isReadable: function(TinyColor, TinyColor, Object) -> Boolean`. Ensure that foreground and background color combinations meet WCAG guidelines. `Object` is optional, defaulting to `{level: "AA",size: "small"}`. `level` can be `"AA"` or "AAA" and `size` can be `"small"` or `"large"`.
|
||||
|
||||
Here are links to read more about the [AA](http://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html) and [AAA](http://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast7.html) requirements.
|
||||
```js
|
||||
tinycolor.isReadable("#000", "#111", {}); // false
|
||||
tinycolor.isReadable("#ff0088", "#5c1a72",{level:"AA",size:"small"}); //false
|
||||
tinycolor.isReadable("#ff0088", "#5c1a72",{level:"AA",size:"large"}), //true
|
||||
```
|
||||
#### mostReadable
|
||||
|
||||
`mostReadable: function(TinyColor, [TinyColor, Tinycolor ...], Object) -> Boolean`.
|
||||
Given a base color and a list of possible foreground or background colors for that base, returns the most readable color.
|
||||
If none of the colors in the list is readable, `mostReadable` will return the better of black or white if `includeFallbackColors:true`.
|
||||
```js
|
||||
tinycolor.mostReadable("#000", ["#f00", "#0f0", "#00f"]).toHexString(); // "#00ff00"
|
||||
tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:false}).toHexString(); // "#112255"
|
||||
tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:true}).toHexString(); // "#ffffff"
|
||||
tinycolor.mostReadable("#ff0088", ["#2e0c3a"],{includeFallbackColors:true,level:"AAA",size:"large"}).toHexString() // "#2e0c3a",
|
||||
tinycolor.mostReadable("#ff0088", ["#2e0c3a"],{includeFallbackColors:true,level:"AAA",size:"small"}).toHexString() // "#000000",
|
||||
```
|
||||
See [index.html](https://github.com/bgrins/TinyColor/blob/master/index.html) in the project for a demo.
|
||||
|
||||
## Common operations
|
||||
|
||||
### clone
|
||||
|
||||
`clone: function() -> TinyColor`.
|
||||
Instantiate a new TinyColor object with the same color. Any changes to the new one won't affect the old one.
|
||||
```js
|
||||
var color1 = tinycolor("#F00");
|
||||
var color2 = color1.clone();
|
||||
color2.setAlpha(.5);
|
||||
|
||||
color1.toString(); // "#ff0000"
|
||||
color2.toString(); // "rgba(255, 0, 0, 0.5)"
|
||||
```
|
||||
9
build/node_modules/tinycolor2/bower.json
generated
vendored
Normal file
9
build/node_modules/tinycolor2/bower.json
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "tinycolor",
|
||||
"repository": "bgrins/TinyColor",
|
||||
"version": "1.4.1",
|
||||
"main": "tinycolor.js",
|
||||
"scripts": ["tinycolor.js"],
|
||||
"license": "MIT",
|
||||
"ignore": ["test"]
|
||||
}
|
||||
23
build/node_modules/tinycolor2/demo/demo.css
generated
vendored
Normal file
23
build/node_modules/tinycolor2/demo/demo.css
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
html { font-size: 100%; overflow-y: scroll; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; }
|
||||
body { font-size: 15px; line-height: 1.231; margin: 4px; background-color: #FCFFFD; }
|
||||
body, button, input, select, textarea { font-family: Droid Sans, Verdana, sans-serif; color: #222; }
|
||||
a { color: #33f; }
|
||||
table th { width: 200px; text-align: right; padding-right:10px; font-family: Georgia serif;}
|
||||
#container { width: 90%; margin:0 auto; }
|
||||
#code-output { border: solid 5px #333; margin:15px; border-top-width: 40px; }
|
||||
#color { width: 200px; height: 2em;}
|
||||
#inputter a { padding:3px; }
|
||||
.invisible { visibility: hidden; }
|
||||
h1 { font-size: 3.8em; color: #293c11; font-family:Tahoma; margin: 3px 0; padding:0; }
|
||||
h1 .small { font-size: 0.4em; }
|
||||
h1 a { text-decoration: none }
|
||||
h2 { font-size: 1.5em; color: #293c11; margin: 0;margin-left: 10px; }
|
||||
h3 { color: #293c11; }
|
||||
.description { font-size: 1.2em; margin-bottom: 30px; margin-top: 30px; font-style: italic;}
|
||||
.download { float: right; }
|
||||
pre { background: #000; color: #fff; padding: 15px;}
|
||||
hr { border: 0; width: 80%; border-bottom: 1px solid #aaa}
|
||||
.footer { text-align:center; padding-top:30px; font-style: italic; }
|
||||
|
||||
#filter-output div, #combine-output span { width: 40px; height: 40px; display:inline-block; margin: 10px; }
|
||||
9597
build/node_modules/tinycolor2/demo/jquery-1.9.1.js
generated
vendored
Normal file
9597
build/node_modules/tinycolor2/demo/jquery-1.9.1.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
4
build/node_modules/tinycolor2/dist/tinycolor-min.js
generated
vendored
Normal file
4
build/node_modules/tinycolor2/dist/tinycolor-min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
192
build/node_modules/tinycolor2/docs/docco.css
generated
vendored
Normal file
192
build/node_modules/tinycolor2/docs/docco.css
generated
vendored
Normal file
@@ -0,0 +1,192 @@
|
||||
/*--------------------- Layout and Typography ----------------------------*/
|
||||
body {
|
||||
font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;
|
||||
font-size: 15px;
|
||||
line-height: 22px;
|
||||
color: #252519;
|
||||
margin: 0; padding: 0;
|
||||
}
|
||||
a {
|
||||
color: #261a3b;
|
||||
}
|
||||
a:visited {
|
||||
color: #261a3b;
|
||||
}
|
||||
p {
|
||||
margin: 0 0 15px 0;
|
||||
}
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
margin: 0px 0 15px 0;
|
||||
}
|
||||
h1 {
|
||||
margin-top: 40px;
|
||||
}
|
||||
hr {
|
||||
border: 0 none;
|
||||
border-top: 1px solid #e5e5ee;
|
||||
height: 1px;
|
||||
margin: 20px 0;
|
||||
}
|
||||
#container {
|
||||
position: relative;
|
||||
}
|
||||
#background {
|
||||
position: fixed;
|
||||
top: 0; left: 525px; right: 0; bottom: 0;
|
||||
background: #f5f5ff;
|
||||
border-left: 1px solid #e5e5ee;
|
||||
z-index: -1;
|
||||
}
|
||||
#jump_to, #jump_page {
|
||||
background: white;
|
||||
-webkit-box-shadow: 0 0 25px #777; -moz-box-shadow: 0 0 25px #777;
|
||||
-webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomleft: 5px;
|
||||
font: 10px Arial;
|
||||
text-transform: uppercase;
|
||||
cursor: pointer;
|
||||
text-align: right;
|
||||
}
|
||||
#jump_to, #jump_wrapper {
|
||||
position: fixed;
|
||||
right: 0; top: 0;
|
||||
padding: 5px 10px;
|
||||
}
|
||||
#jump_wrapper {
|
||||
padding: 0;
|
||||
display: none;
|
||||
}
|
||||
#jump_to:hover #jump_wrapper {
|
||||
display: block;
|
||||
}
|
||||
#jump_page {
|
||||
padding: 5px 0 3px;
|
||||
margin: 0 0 25px 25px;
|
||||
}
|
||||
#jump_page .source {
|
||||
display: block;
|
||||
padding: 5px 10px;
|
||||
text-decoration: none;
|
||||
border-top: 1px solid #eee;
|
||||
}
|
||||
#jump_page .source:hover {
|
||||
background: #f5f5ff;
|
||||
}
|
||||
#jump_page .source:first-child {
|
||||
}
|
||||
table td {
|
||||
border: 0;
|
||||
outline: 0;
|
||||
}
|
||||
td.docs, th.docs {
|
||||
max-width: 450px;
|
||||
min-width: 450px;
|
||||
min-height: 5px;
|
||||
padding: 10px 25px 1px 50px;
|
||||
overflow-x: hidden;
|
||||
vertical-align: top;
|
||||
text-align: left;
|
||||
}
|
||||
.docs pre {
|
||||
margin: 15px 0 15px;
|
||||
padding-left: 15px;
|
||||
}
|
||||
.docs p tt, .docs p code {
|
||||
background: #f8f8ff;
|
||||
border: 1px solid #dedede;
|
||||
font-size: 12px;
|
||||
padding: 0 0.2em;
|
||||
}
|
||||
.pilwrap {
|
||||
position: relative;
|
||||
}
|
||||
.pilcrow {
|
||||
font: 12px Arial;
|
||||
text-decoration: none;
|
||||
color: #454545;
|
||||
position: absolute;
|
||||
top: 3px; left: -20px;
|
||||
padding: 1px 2px;
|
||||
opacity: 0;
|
||||
-webkit-transition: opacity 0.2s linear;
|
||||
}
|
||||
td.docs:hover .pilcrow {
|
||||
opacity: 1;
|
||||
}
|
||||
td.code, th.code {
|
||||
padding: 14px 15px 16px 25px;
|
||||
width: 100%;
|
||||
vertical-align: top;
|
||||
background: #f5f5ff;
|
||||
border-left: 1px solid #e5e5ee;
|
||||
}
|
||||
pre, tt, code {
|
||||
font-size: 12px; line-height: 18px;
|
||||
font-family: Menlo, Monaco, Consolas, "Lucida Console", monospace;
|
||||
margin: 0; padding: 0;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------- Syntax Highlighting -----------------------------*/
|
||||
td.linenos { background-color: #f0f0f0; padding-right: 10px; }
|
||||
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
|
||||
body .hll { background-color: #ffffcc }
|
||||
body .c { color: #408080; font-style: italic } /* Comment */
|
||||
body .err { border: 1px solid #FF0000 } /* Error */
|
||||
body .k { color: #954121 } /* Keyword */
|
||||
body .o { color: #666666 } /* Operator */
|
||||
body .cm { color: #408080; font-style: italic } /* Comment.Multiline */
|
||||
body .cp { color: #BC7A00 } /* Comment.Preproc */
|
||||
body .c1 { color: #408080; font-style: italic } /* Comment.Single */
|
||||
body .cs { color: #408080; font-style: italic } /* Comment.Special */
|
||||
body .gd { color: #A00000 } /* Generic.Deleted */
|
||||
body .ge { font-style: italic } /* Generic.Emph */
|
||||
body .gr { color: #FF0000 } /* Generic.Error */
|
||||
body .gh { color: #000080; font-weight: bold } /* Generic.Heading */
|
||||
body .gi { color: #00A000 } /* Generic.Inserted */
|
||||
body .go { color: #808080 } /* Generic.Output */
|
||||
body .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
|
||||
body .gs { font-weight: bold } /* Generic.Strong */
|
||||
body .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
|
||||
body .gt { color: #0040D0 } /* Generic.Traceback */
|
||||
body .kc { color: #954121 } /* Keyword.Constant */
|
||||
body .kd { color: #954121; font-weight: bold } /* Keyword.Declaration */
|
||||
body .kn { color: #954121; font-weight: bold } /* Keyword.Namespace */
|
||||
body .kp { color: #954121 } /* Keyword.Pseudo */
|
||||
body .kr { color: #954121; font-weight: bold } /* Keyword.Reserved */
|
||||
body .kt { color: #B00040 } /* Keyword.Type */
|
||||
body .m { color: #666666 } /* Literal.Number */
|
||||
body .s { color: #219161 } /* Literal.String */
|
||||
body .na { color: #7D9029 } /* Name.Attribute */
|
||||
body .nb { color: #954121 } /* Name.Builtin */
|
||||
body .nc { color: #0000FF; font-weight: bold } /* Name.Class */
|
||||
body .no { color: #880000 } /* Name.Constant */
|
||||
body .nd { color: #AA22FF } /* Name.Decorator */
|
||||
body .ni { color: #999999; font-weight: bold } /* Name.Entity */
|
||||
body .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
|
||||
body .nf { color: #0000FF } /* Name.Function */
|
||||
body .nl { color: #A0A000 } /* Name.Label */
|
||||
body .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
|
||||
body .nt { color: #954121; font-weight: bold } /* Name.Tag */
|
||||
body .nv { color: #19469D } /* Name.Variable */
|
||||
body .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
|
||||
body .w { color: #bbbbbb } /* Text.Whitespace */
|
||||
body .mf { color: #666666 } /* Literal.Number.Float */
|
||||
body .mh { color: #666666 } /* Literal.Number.Hex */
|
||||
body .mi { color: #666666 } /* Literal.Number.Integer */
|
||||
body .mo { color: #666666 } /* Literal.Number.Oct */
|
||||
body .sb { color: #219161 } /* Literal.String.Backtick */
|
||||
body .sc { color: #219161 } /* Literal.String.Char */
|
||||
body .sd { color: #219161; font-style: italic } /* Literal.String.Doc */
|
||||
body .s2 { color: #219161 } /* Literal.String.Double */
|
||||
body .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
|
||||
body .sh { color: #219161 } /* Literal.String.Heredoc */
|
||||
body .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
|
||||
body .sx { color: #954121 } /* Literal.String.Other */
|
||||
body .sr { color: #BB6688 } /* Literal.String.Regex */
|
||||
body .s1 { color: #219161 } /* Literal.String.Single */
|
||||
body .ss { color: #19469D } /* Literal.String.Symbol */
|
||||
body .bp { color: #954121 } /* Name.Builtin.Pseudo */
|
||||
body .vc { color: #19469D } /* Name.Variable.Class */
|
||||
body .vg { color: #19469D } /* Name.Variable.Global */
|
||||
body .vi { color: #19469D } /* Name.Variable.Instance */
|
||||
body .il { color: #666666 } /* Literal.Number.Integer.Long */
|
||||
1023
build/node_modules/tinycolor2/docs/tinycolor.html
generated
vendored
Normal file
1023
build/node_modules/tinycolor2/docs/tinycolor.html
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
207
build/node_modules/tinycolor2/index.html
generated
vendored
Normal file
207
build/node_modules/tinycolor2/index.html
generated
vendored
Normal file
@@ -0,0 +1,207 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset='utf-8'>
|
||||
|
||||
<title>TinyColor - Fast, small color manipulation in JavaScript</title>
|
||||
|
||||
<link rel="stylesheet" href="demo/demo.css" type="text/css" media="screen" />
|
||||
<script type='text/javascript' src='demo/jquery-1.9.1.js'></script>
|
||||
<script type='text/javascript' src='tinycolor.js'></script>
|
||||
<script type='text/javascript'>
|
||||
|
||||
function colorChange(color) {
|
||||
var tiny = tinycolor(color);
|
||||
|
||||
var output = [
|
||||
"hex:\t" + tiny.toHexString(),
|
||||
"hex8:\t" + tiny.toHex8String(),
|
||||
"rgb:\t" + tiny.toRgbString(),
|
||||
"hsl:\t" + tiny.toHslString(),
|
||||
"hsv:\t" + tiny.toHsvString(),
|
||||
"name:\t" + (tiny.toName() || "none"),
|
||||
"format:\t" + (tiny.getFormat()),
|
||||
"format string:\t" + tiny.toString(),
|
||||
].join("\n");
|
||||
|
||||
$("#code-output").text(output).css("border-color", tiny.toHexString());
|
||||
|
||||
var filters = $("#filter-output").toggleClass("invisible", !tiny.isValid());
|
||||
|
||||
filters.find(".lighten").css("background-color",
|
||||
tinycolor(color).lighten(20).toHexString()
|
||||
);
|
||||
filters.find(".darken").css("background-color",
|
||||
tinycolor(color).darken(20).toHexString()
|
||||
);
|
||||
filters.find(".saturate").css("background-color",
|
||||
tinycolor(color).saturate(20).toHexString()
|
||||
);
|
||||
filters.find(".desaturate").css("background-color",
|
||||
tinycolor(color).desaturate(20).toHexString()
|
||||
);
|
||||
filters.find(".greyscale").css("background-color",
|
||||
tinycolor(color).greyscale().toHexString()
|
||||
);
|
||||
filters.find(".brighten").css("background-color",
|
||||
tinycolor(color).brighten(20).toHexString()
|
||||
);
|
||||
|
||||
var allColors = [];
|
||||
for (var i in tinycolor.names) {
|
||||
allColors.push(i);
|
||||
}
|
||||
var mostReadable = tinycolor.mostReadable(color, allColors);
|
||||
|
||||
$("#mostReadable").css("background-color",
|
||||
mostReadable.toHexString()
|
||||
);
|
||||
|
||||
var combines = $("#combine-output").toggleClass("invisible", !tiny.isValid());
|
||||
|
||||
function colorArrayToHTML(arr) {
|
||||
return $.map(arr, function(e) {
|
||||
return '<span style="background:'+e.toHexString()+'"></span>'
|
||||
}).join('');
|
||||
}
|
||||
|
||||
var triad = tiny.triad();
|
||||
combines.find(".triad").html(colorArrayToHTML(triad));
|
||||
console.log(triad.map(function(f) {return f.toHexString();}));
|
||||
|
||||
var tetrad = tiny.tetrad();
|
||||
combines.find(".tetrad").html(colorArrayToHTML(tetrad));
|
||||
|
||||
var mono = tiny.monochromatic();
|
||||
combines.find(".mono").html(colorArrayToHTML(mono));
|
||||
|
||||
var analogous = tiny.analogous();
|
||||
combines.find(".analogous").html(colorArrayToHTML(analogous));
|
||||
|
||||
var splitcomplement = tiny.splitcomplement();
|
||||
combines.find(".sc").html(colorArrayToHTML(splitcomplement));
|
||||
}
|
||||
|
||||
$(function() {
|
||||
$("#color").bind("keyup change", function() {
|
||||
colorChange($(this).val());
|
||||
});
|
||||
colorChange({r: 150, g: 0, b: 100});
|
||||
|
||||
$("#inputter a").click(function() {
|
||||
$("#color").val($(this).text()).trigger("change");
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="container">
|
||||
<h1>TinyColor</h1>
|
||||
<h2>Fast, small color manipulation and conversion for JavaScript</h2>
|
||||
|
||||
<p>
|
||||
<a href="https://github.com/bgrins/TinyColor">TinyColor</a> is a micro framework for inputting colors and outputting colors as different formats.
|
||||
Input is meant to be as permissive as possible.
|
||||
</p>
|
||||
|
||||
<h3>Usage Documentation</h3>
|
||||
<p>Read all the documentation on the <a href='https://github.com/bgrins/TinyColor'>TinyColor project page</a> on github.</p>
|
||||
|
||||
<h3>Code</h3>
|
||||
<p><a href='docs/tinycolor.html'>View the annotated source code</a> or <a href='https://github.com/bgrins/TinyColor/blob/master/tinycolor.js'>see the full source on github</a>.</p>
|
||||
|
||||
<h3>Tests</h3>
|
||||
<p><a href='test/'>View the QUnit Tests</a>.</p>
|
||||
|
||||
<h3>Demo</h3>
|
||||
<div id='demo'>
|
||||
<div id='inputter'>
|
||||
<p>
|
||||
Enter a color: <input type="text" placeholder="any color." id='color' />
|
||||
</p>
|
||||
<p>
|
||||
Or try these:
|
||||
<a href="#">red</a>
|
||||
<a href="#">0f0</a>
|
||||
<a href="#">rgb 255 128 128</a>
|
||||
<a href='#'>hsl(0, 100%, 50%)</a>
|
||||
<a href='#'>hsv 0, 100%, 50%</a>
|
||||
</p>
|
||||
<p>And I'll tell you what I know about it:</p>
|
||||
</div>
|
||||
|
||||
<pre id='code-output'></pre>
|
||||
|
||||
<div id='filter-output'>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Lighten</th>
|
||||
<td><div class='lighten'></div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Darken</th>
|
||||
<td><div class='darken'></div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Saturate</th>
|
||||
<td><div class='saturate'></div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Desaturate</th>
|
||||
<td><div class='desaturate'></div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Greyscale</th>
|
||||
<td><div class='greyscale'></div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Brighten</th>
|
||||
<td><div class='brighten'></div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Most Readable</th>
|
||||
<td><div id='mostReadable'></div></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id='combine-output'>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Triad</th> <td><div class='triad'></div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Tetrad</th> <td><div class='tetrad'></div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Monochromatic</th> <td><div class='mono'></div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Analogous</th> <td><div class='analogous'></div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Split Complements</th> <td><div class='sc'></div></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<h3>Credit</h3>
|
||||
<p>
|
||||
Developed by <a href='http://briangrinstead.com'>Brian Grinstead</a>. Big thanks to the following places:
|
||||
</p>
|
||||
<ul>
|
||||
<li><a href='https://github.com/cloudhead/less.js/blob/master/lib/less/functions.js'>less.js</a> for some of the modification functions</li>
|
||||
<li><a href='https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js'>jQuery xColor</a> for some of the combination functions</li>
|
||||
<li><a href='http://www.w3.org/TR/css3-color/#svg-color'>w3.org</a> for the color list and parsing rules</li>
|
||||
<li><a href='http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript'>mjijackson.com</a> for the first stab at RGB / HSL / HSV converters</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
63
build/node_modules/tinycolor2/package.json
generated
vendored
Normal file
63
build/node_modules/tinycolor2/package.json
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"tinycolor2@1.4.1",
|
||||
"/Users/asciidisco/Desktop/asciidisco.com/build"
|
||||
]
|
||||
],
|
||||
"_from": "tinycolor2@1.4.1",
|
||||
"_id": "tinycolor2@1.4.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-9PrTM0R7wLB9TcjpIJ2POaisd+g=",
|
||||
"_location": "/tinycolor2",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "tinycolor2@1.4.1",
|
||||
"name": "tinycolor2",
|
||||
"escapedName": "tinycolor2",
|
||||
"rawSpec": "1.4.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.4.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/jimp"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/tinycolor2/-/tinycolor2-1.4.1.tgz",
|
||||
"_spec": "1.4.1",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build",
|
||||
"author": {
|
||||
"name": "Brian Grinstead",
|
||||
"email": "briangrinstead@gmail.com",
|
||||
"url": "http://briangrinstead.com"
|
||||
},
|
||||
"contributors": [],
|
||||
"description": "Fast Color Parsing and Manipulation",
|
||||
"devDependencies": {
|
||||
"grunt": "~0.4.1",
|
||||
"grunt-contrib-concat": "~0.1.3",
|
||||
"grunt-contrib-jshint": "~0.1.1",
|
||||
"grunt-contrib-qunit": "^0.7.0",
|
||||
"grunt-contrib-uglify": "~0.2.0",
|
||||
"grunt-docco": "~0.2.0"
|
||||
},
|
||||
"directories": {},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"keywords": [
|
||||
"color",
|
||||
"parser",
|
||||
"tinycolor"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "./tinycolor.js",
|
||||
"name": "tinycolor2",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://bgrins.github.com/TinyColor"
|
||||
},
|
||||
"url": "http://bgrins.github.com/TinyColor",
|
||||
"version": "1.4.1"
|
||||
}
|
||||
19
build/node_modules/tinycolor2/test/index.html
generated
vendored
Normal file
19
build/node_modules/tinycolor2/test/index.html
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen" />
|
||||
<script type='text/javascript' src='qunit.js'></script>
|
||||
<script type='text/javascript' src='../demo/jquery-1.9.1.js'></script>
|
||||
<script type='text/javascript' src='../tinycolor.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1 id="qunit-header">TinyColor Tests</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
<div id="qunit-fixture">test markup, will be hidden</div>
|
||||
<script type='text/javascript' src='test.js'></script>
|
||||
</body>
|
||||
</html>
|
||||
244
build/node_modules/tinycolor2/test/qunit.css
generated
vendored
Normal file
244
build/node_modules/tinycolor2/test/qunit.css
generated
vendored
Normal file
@@ -0,0 +1,244 @@
|
||||
/**
|
||||
* QUnit v1.11.0 - A JavaScript Unit Testing Framework
|
||||
*
|
||||
* http://qunitjs.com
|
||||
*
|
||||
* Copyright 2012 jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
|
||||
/** Font Family and Sizes */
|
||||
|
||||
#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult {
|
||||
font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
||||
#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
|
||||
#qunit-tests { font-size: smaller; }
|
||||
|
||||
|
||||
/** Resets */
|
||||
|
||||
#qunit-tests, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult, #qunit-modulefilter {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
|
||||
/** Header */
|
||||
|
||||
#qunit-header {
|
||||
padding: 0.5em 0 0.5em 1em;
|
||||
|
||||
color: #8699a4;
|
||||
background-color: #0d3349;
|
||||
|
||||
font-size: 1.5em;
|
||||
line-height: 1em;
|
||||
font-weight: normal;
|
||||
|
||||
border-radius: 5px 5px 0 0;
|
||||
-moz-border-radius: 5px 5px 0 0;
|
||||
-webkit-border-top-right-radius: 5px;
|
||||
-webkit-border-top-left-radius: 5px;
|
||||
}
|
||||
|
||||
#qunit-header a {
|
||||
text-decoration: none;
|
||||
color: #c2ccd1;
|
||||
}
|
||||
|
||||
#qunit-header a:hover,
|
||||
#qunit-header a:focus {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#qunit-testrunner-toolbar label {
|
||||
display: inline-block;
|
||||
padding: 0 .5em 0 .1em;
|
||||
}
|
||||
|
||||
#qunit-banner {
|
||||
height: 5px;
|
||||
}
|
||||
|
||||
#qunit-testrunner-toolbar {
|
||||
padding: 0.5em 0 0.5em 2em;
|
||||
color: #5E740B;
|
||||
background-color: #eee;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#qunit-userAgent {
|
||||
padding: 0.5em 0 0.5em 2.5em;
|
||||
background-color: #2b81af;
|
||||
color: #fff;
|
||||
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
|
||||
}
|
||||
|
||||
#qunit-modulefilter-container {
|
||||
float: right;
|
||||
}
|
||||
|
||||
/** Tests: Pass/Fail */
|
||||
|
||||
#qunit-tests {
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
#qunit-tests li {
|
||||
padding: 0.4em 0.5em 0.4em 2.5em;
|
||||
border-bottom: 1px solid #fff;
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
#qunit-tests.hidepass li.pass, #qunit-tests.hidepass li.running {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#qunit-tests li strong {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#qunit-tests li a {
|
||||
padding: 0.5em;
|
||||
color: #c2ccd1;
|
||||
text-decoration: none;
|
||||
}
|
||||
#qunit-tests li a:hover,
|
||||
#qunit-tests li a:focus {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
#qunit-tests li .runtime {
|
||||
float: right;
|
||||
font-size: smaller;
|
||||
}
|
||||
|
||||
.qunit-assert-list {
|
||||
margin-top: 0.5em;
|
||||
padding: 0.5em;
|
||||
|
||||
background-color: #fff;
|
||||
|
||||
border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
}
|
||||
|
||||
.qunit-collapsed {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#qunit-tests table {
|
||||
border-collapse: collapse;
|
||||
margin-top: .2em;
|
||||
}
|
||||
|
||||
#qunit-tests th {
|
||||
text-align: right;
|
||||
vertical-align: top;
|
||||
padding: 0 .5em 0 0;
|
||||
}
|
||||
|
||||
#qunit-tests td {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
#qunit-tests pre {
|
||||
margin: 0;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
#qunit-tests del {
|
||||
background-color: #e0f2be;
|
||||
color: #374e0c;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#qunit-tests ins {
|
||||
background-color: #ffcaca;
|
||||
color: #500;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/*** Test Counts */
|
||||
|
||||
#qunit-tests b.counts { color: black; }
|
||||
#qunit-tests b.passed { color: #5E740B; }
|
||||
#qunit-tests b.failed { color: #710909; }
|
||||
|
||||
#qunit-tests li li {
|
||||
padding: 5px;
|
||||
background-color: #fff;
|
||||
border-bottom: none;
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
/*** Passing Styles */
|
||||
|
||||
#qunit-tests li li.pass {
|
||||
color: #3c510c;
|
||||
background-color: #fff;
|
||||
border-left: 10px solid #C6E746;
|
||||
}
|
||||
|
||||
#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
|
||||
#qunit-tests .pass .test-name { color: #366097; }
|
||||
|
||||
#qunit-tests .pass .test-actual,
|
||||
#qunit-tests .pass .test-expected { color: #999999; }
|
||||
|
||||
#qunit-banner.qunit-pass { background-color: #C6E746; }
|
||||
|
||||
/*** Failing Styles */
|
||||
|
||||
#qunit-tests li li.fail {
|
||||
color: #710909;
|
||||
background-color: #fff;
|
||||
border-left: 10px solid #EE5757;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
#qunit-tests > li:last-child {
|
||||
border-radius: 0 0 5px 5px;
|
||||
-moz-border-radius: 0 0 5px 5px;
|
||||
-webkit-border-bottom-right-radius: 5px;
|
||||
-webkit-border-bottom-left-radius: 5px;
|
||||
}
|
||||
|
||||
#qunit-tests .fail { color: #000000; background-color: #EE5757; }
|
||||
#qunit-tests .fail .test-name,
|
||||
#qunit-tests .fail .module-name { color: #000000; }
|
||||
|
||||
#qunit-tests .fail .test-actual { color: #EE5757; }
|
||||
#qunit-tests .fail .test-expected { color: green; }
|
||||
|
||||
#qunit-banner.qunit-fail { background-color: #EE5757; }
|
||||
|
||||
|
||||
/** Result */
|
||||
|
||||
#qunit-testresult {
|
||||
padding: 0.5em 0.5em 0.5em 2.5em;
|
||||
|
||||
color: #2b81af;
|
||||
background-color: #D2E0E6;
|
||||
|
||||
border-bottom: 1px solid white;
|
||||
}
|
||||
#qunit-testresult .module-name {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/** Fixture */
|
||||
|
||||
#qunit-fixture {
|
||||
position: absolute;
|
||||
top: -10000px;
|
||||
left: -10000px;
|
||||
width: 1000px;
|
||||
height: 1000px;
|
||||
}
|
||||
2152
build/node_modules/tinycolor2/test/qunit.js
generated
vendored
Normal file
2152
build/node_modules/tinycolor2/test/qunit.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
791
build/node_modules/tinycolor2/test/test.js
generated
vendored
Normal file
791
build/node_modules/tinycolor2/test/test.js
generated
vendored
Normal file
@@ -0,0 +1,791 @@
|
||||
|
||||
test("TinyColor initialization", function() {
|
||||
ok(typeof tinycolor != "undefined", "tinycolor is initialized on the page");
|
||||
ok(typeof tinycolor("red") == "object", "tinycolor is able to be instantiated");
|
||||
|
||||
var r = tinycolor("red");
|
||||
ok(tinycolor(r) === r, "when given a tinycolor instance, tinycolor() returns it");
|
||||
ok(new tinycolor(r) === r, "when given a tinycolor instance, new tinycolor() returns it");
|
||||
equal(tinycolor("red", { format: "hex" }).toString(), "#ff0000", "tinycolor options are being parsed");
|
||||
equal(tinycolor.fromRatio({r: 1, g: 0, b: 0 }, { format: "hex" }).toString(), "#ff0000", "tinycolor options are being parsed");
|
||||
|
||||
var obj = {h: 180, s: 0.5, l: 0.5};
|
||||
var color = tinycolor(obj);
|
||||
ok(obj.s === 0.5, "when given an object, the original object is not modified");
|
||||
});
|
||||
|
||||
test("Original input", function() {
|
||||
var colorRgbUp = "RGB(39, 39, 39)";
|
||||
var colorRgbLow = "rgb(39, 39, 39)";
|
||||
var colorRgbMix = "RgB(39, 39, 39)";
|
||||
var tinycolorObj = tinycolor(colorRgbMix);
|
||||
var inputObj = {r:100,g:100,b:100};
|
||||
var r = tinycolor("red");
|
||||
|
||||
ok(tinycolor(colorRgbLow).getOriginalInput() === colorRgbLow, "original lowercase input is returned");
|
||||
ok(tinycolor(colorRgbUp).getOriginalInput() === colorRgbUp, "original uppercase input is returned");
|
||||
ok(tinycolor(colorRgbMix).getOriginalInput() === colorRgbMix, "original mixed input is returned");
|
||||
ok(tinycolor(tinycolorObj).getOriginalInput() === colorRgbMix, "when given a tinycolor instance, the color string is returned");
|
||||
ok(tinycolor(inputObj).getOriginalInput() === inputObj, "when given an object, the object is returned");
|
||||
ok(new tinycolor("").getOriginalInput() === "", "when given an empty string, an empty string is returned");
|
||||
ok(new tinycolor(null).getOriginalInput() === "", "when given a null value, an empty string is returned");
|
||||
});
|
||||
|
||||
test("Cloning color", function() {
|
||||
var originalColor = tinycolor("red");
|
||||
var originalColorRgbString = originalColor.toRgbString();
|
||||
|
||||
var clonedColor = originalColor.clone();
|
||||
ok(clonedColor.toRgbString() === originalColor.toRgbString(), "cloned color is identical");
|
||||
|
||||
clonedColor.setAlpha(0.5);
|
||||
ok(clonedColor.toRgbString() !== originalColor.toRgbString(), "cloned color is changing independently from original color");
|
||||
ok(originalColorRgbString === originalColor.toRgbString(), "original color was not changed by cloned color change");
|
||||
});
|
||||
|
||||
// Taken from convertWikipediaColors.html
|
||||
var conversions = [
|
||||
{"hex":"#FFFFFF","hex8":"#FFFFFFFF","rgb":{"r":"100.0%","g":"100.0%","b":"100.0%"},"hsv":{"h":"0","s":"0.000","v":"1.000"},"hsl":{"h":"0","s":"0.000","l":"1.000"}},
|
||||
{"hex":"#808080","hex8":"#808080FF","rgb":{"r":"050.0%","g":"050.0%","b":"050.0%"},"hsv":{"h":"0","s":"0.000","v":"0.500"},"hsl":{"h":"0","s":"0.000","l":"0.500"}},
|
||||
{"hex":"#000000","hex8":"#000000FF","rgb":{"r":"000.0%","g":"000.0%","b":"000.0%"},"hsv":{"h":"0","s":"0.000","v":"0.000"},"hsl":{"h":"0","s":"0.000","l":"0.000"}},
|
||||
{"hex":"#FF0000","hex8":"#FF0000FF","rgb":{"r":"100.0%","g":"000.0%","b":"000.0%"},"hsv":{"h":"0.0","s":"1.000","v":"1.000"},"hsl":{"h":"0.0","s":"1.000","l":"0.500"}},
|
||||
{"hex":"#BFBF00","hex8":"#BFBF00FF","rgb":{"r":"075.0%","g":"075.0%","b":"000.0%"},"hsv":{"h":"60.0","s":"1.000","v":"0.750"},"hsl":{"h":"60.0","s":"1.000","l":"0.375"}},
|
||||
{"hex":"#008000","hex8":"#008000FF","rgb":{"r":"000.0%","g":"050.0%","b":"000.0%"},"hsv":{"h":"120.0","s":"1.000","v":"0.500"},"hsl":{"h":"120.0","s":"1.000","l":"0.250"}},
|
||||
{"hex":"#80FFFF","hex8":"#80FFFFFF","rgb":{"r":"050.0%","g":"100.0%","b":"100.0%"},"hsv":{"h":"180.0","s":"0.500","v":"1.000"},"hsl":{"h":"180.0","s":"1.000","l":"0.750"}},
|
||||
{"hex":"#8080FF","hex8":"#8080FFFF","rgb":{"r":"050.0%","g":"050.0%","b":"100.0%"},"hsv":{"h":"240.0","s":"0.500","v":"1.000"},"hsl":{"h":"240.0","s":"1.000","l":"0.750"}},
|
||||
{"hex":"#BF40BF","hex8":"#BF40BFFF","rgb":{"r":"075.0%","g":"025.0%","b":"075.0%"},"hsv":{"h":"300.0","s":"0.667","v":"0.750"},"hsl":{"h":"300.0","s":"0.500","l":"0.500"}},
|
||||
{"hex":"#A0A424","hex8":"#A0A424FF","rgb":{"r":"062.8%","g":"064.3%","b":"014.2%"},"hsv":{"h":"61.8","s":"0.779","v":"0.643"},"hsl":{"h":"61.8","s":"0.638","l":"0.393"}},
|
||||
{"hex":"#1EAC41","hex8":"#1EAC41FF","rgb":{"r":"011.6%","g":"067.5%","b":"025.5%"},"hsv":{"h":"134.9","s":"0.828","v":"0.675"},"hsl":{"h":"134.9","s":"0.707","l":"0.396"}},
|
||||
{"hex":"#B430E5","hex8":"#B430E5FF","rgb":{"r":"070.4%","g":"018.7%","b":"089.7%"},"hsv":{"h":"283.7","s":"0.792","v":"0.897"},"hsl":{"h":"283.7","s":"0.775","l":"0.542"}},
|
||||
{"hex":"#FEF888","hex8":"#FEF888FF","rgb":{"r":"099.8%","g":"097.4%","b":"053.2%"},"hsv":{"h":"56.9","s":"0.467","v":"0.998"},"hsl":{"h":"56.9","s":"0.991","l":"0.765"}},
|
||||
{"hex":"#19CB97","hex8":"#19CB97FF","rgb":{"r":"009.9%","g":"079.5%","b":"059.1%"},"hsv":{"h":"162.4","s":"0.875","v":"0.795"},"hsl":{"h":"162.4","s":"0.779","l":"0.447"}},
|
||||
{"hex":"#362698","hex8":"#362698FF","rgb":{"r":"021.1%","g":"014.9%","b":"059.7%"},"hsv":{"h":"248.3","s":"0.750","v":"0.597"},"hsl":{"h":"248.3","s":"0.601","l":"0.373"}},
|
||||
{"hex":"#7E7EB8","hex8":"#7E7EB8FF","rgb":{"r":"049.5%","g":"049.3%","b":"072.1%"},"hsv":{"h":"240.5","s":"0.316","v":"0.721"},"hsl":{"h":"240.5","s":"0.290","l":"0.607"}}
|
||||
];
|
||||
|
||||
module("Color translations");
|
||||
|
||||
test("Color Equality", function() {
|
||||
for (var i = 0; i < conversions.length; i++) {
|
||||
var c = conversions[i];
|
||||
var tiny = tinycolor(c.hex);
|
||||
|
||||
ok(true, tiny.isValid());
|
||||
ok(true,
|
||||
"Testing " + c.hex + ": " + tiny.toRgbString() + " " + tiny.toPercentageRgbString() + " " + tiny.toHsvString() + " " + tiny.toHslString() + " " + tiny.toHexString() +
|
||||
"Original: " + JSON.stringify(c.rgb) + " " + JSON.stringify(c.hsv) + " " + JSON.stringify(c.hsl)
|
||||
);
|
||||
ok(tinycolor.equals(c.rgb, c.hex), "RGB equals hex " + c.hex);
|
||||
ok(tinycolor.equals(c.rgb, c.hex8), "RGB equals hex " + c.hex);
|
||||
ok(tinycolor.equals(c.rgb, c.hsl), "RGB equals HSL " + c.hex);
|
||||
ok(tinycolor.equals(c.rgb, c.hsv), "RGB equals HSV " + c.hex);
|
||||
ok(tinycolor.equals(c.rgb, c.rgb), "RGB equals RGB " + c.hex);
|
||||
|
||||
ok(tinycolor.equals(c.hex, c.hex), "hex equals hex " + c.hex);
|
||||
ok(tinycolor.equals(c.hex, c.hex8), "hex equals hex8 " + c.hex);
|
||||
ok(tinycolor.equals(c.hex, c.hsl), "hex equals HSL " + c.hex);
|
||||
ok(tinycolor.equals(c.hex, c.hsv), "hex equals HSV " + c.hex);
|
||||
|
||||
ok(tinycolor.equals(c.hsl, c.hsv), "HSL equals HSV " + c.hex);
|
||||
}
|
||||
});
|
||||
|
||||
module("Ratio Parsing");
|
||||
|
||||
test("With Ratio", function() {
|
||||
equal(tinycolor.fromRatio({r: 1, g: 1, b: 1}).toHexString(), "#ffffff", "white");
|
||||
equal(tinycolor.fromRatio({r: 1, g: 0, b: 0, a: .5 }).toRgbString(), "rgba(255, 0, 0, 0.5)", "alpha works when ratio is parsed");
|
||||
equal(tinycolor.fromRatio({r: 1, g: 0, b: 0, a: 1 }).toRgbString(), "rgb(255, 0, 0)", "alpha = 1 works when ratio is parsed");
|
||||
equal(tinycolor.fromRatio({r: 1, g: 0, b: 0, a: 10 }).toRgbString(), "rgb(255, 0, 0)", "alpha > 1 works when ratio is parsed");
|
||||
equal(tinycolor.fromRatio({r: 1, g: 0, b: 0, a: -1 }).toRgbString(), "rgb(255, 0, 0)", "alpha < 1 works when ratio is parsed");
|
||||
});
|
||||
|
||||
test("Without Ratio", function() {
|
||||
equal(tinycolor({r: 1, g: 1, b: 1}).toHexString(), "#010101", "010101");
|
||||
equal(tinycolor({r: .1, g: .1, b: .1}).toHexString(), "#000000", "000000");
|
||||
equal(tinycolor("rgb .1 .1 .1").toHexString(), "#000000", "000000");
|
||||
});
|
||||
|
||||
module("String Parsing");
|
||||
|
||||
test("RGB Text Parsing", function() {
|
||||
equal(tinycolor("rgb 255 0 0").toHexString(), "#ff0000", "spaced input");
|
||||
equal(tinycolor("rgb(255, 0, 0)").toHexString(), "#ff0000", "parenthesized input");
|
||||
equal(tinycolor("rgb (255, 0, 0)").toHexString(), "#ff0000", "parenthesized spaced input");
|
||||
equal(tinycolor({ r: 255, g: 0, b: 0 }).toHexString(), "#ff0000", "object input");
|
||||
deepEqual (tinycolor({ r: 255, g: 0, b: 0 }).toRgb(), { r: 255, g: 0, b: 0, a: 1 }, "object input and compare");
|
||||
|
||||
|
||||
ok(tinycolor.equals({r:200, g: 100, b: 0 }, "rgb(200, 100, 0)"));
|
||||
ok(tinycolor.equals({r:200, g: 100, b: 0 }, "rgb 200 100 0"));
|
||||
ok(tinycolor.equals({r:200, g: 100, b: 0 }, "rgb 200 100 0"));
|
||||
ok(tinycolor.equals({r:200, g: 100, b: 0, a: .4 }, "rgba 200 100 0 .4"));
|
||||
ok(!tinycolor.equals({r:199, g: 100, b: 0 }, "rgba 200 100 0 1"));
|
||||
|
||||
ok(!tinycolor.equals({r:199, g: 100, b: 0 }, "rgb(200, 100, 0)"));
|
||||
ok(!tinycolor.equals({r:199, g: 100, b: 0 }, "rgb 200 100 0"));
|
||||
ok(!tinycolor.equals({r:199, g: 100, b: 0 }, "rgb 200 100 0"));
|
||||
|
||||
|
||||
ok(tinycolor.equals(tinycolor({r:200, g: 100, b: 0 }), "rgb(200, 100, 0)"));
|
||||
ok(tinycolor.equals(tinycolor({r:200, g: 100, b: 0 }), "rgb 200 100 0"));
|
||||
ok(tinycolor.equals(tinycolor({r:200, g: 100, b: 0 }), "rgb 200 100 0"));
|
||||
});
|
||||
|
||||
test("Percentage RGB Text Parsing", function() {
|
||||
equal(tinycolor("rgb 100% 0% 0%").toHexString(), "#ff0000", "spaced input");
|
||||
equal(tinycolor("rgb(100%, 0%, 0%)").toHexString(), "#ff0000", "parenthesized input");
|
||||
equal(tinycolor("rgb (100%, 0%, 0%)").toHexString(), "#ff0000", "parenthesized spaced input");
|
||||
equal(tinycolor({ r: "100%", g: "0%", b: "0%" }).toHexString(), "#ff0000", "object input");
|
||||
deepEqual (tinycolor({ r: "100%", g: "0%", b: "0%" }).toRgb(), { r: 255, g: 0, b: 0, a: 1 }, "object input and compare");
|
||||
|
||||
|
||||
ok(tinycolor.equals({r:"90%", g: "45%", b: "0%" }, "rgb(90%, 45%, 0%)"));
|
||||
ok(tinycolor.equals({r:"90%", g: "45%", b: "0%" }, "rgb 90% 45% 0%"));
|
||||
ok(tinycolor.equals({r:"90%", g: "45%", b: "0%" }, "rgb 90% 45% 0%"));
|
||||
ok(tinycolor.equals({r:"90%", g: "45%", b: "0%", a: .4 }, "rgba 90% 45% 0% .4"));
|
||||
ok(!tinycolor.equals({r:"89%", g: "45%", b: "0%" }, "rgba 90% 45% 0% 1"));
|
||||
|
||||
ok(!tinycolor.equals({r:"89%", g: "45%", b: "0%" }, "rgb(90%, 45%, 0%)"));
|
||||
ok(!tinycolor.equals({r:"89%", g: "45%", b: "0%" }, "rgb 90% 45% 0%"));
|
||||
ok(!tinycolor.equals({r:"89%", g: "45%", b: "0%" }, "rgb 90% 45% 0%"));
|
||||
|
||||
|
||||
ok(tinycolor.equals(tinycolor({r:"90%", g: "45%", b: "0%" }), "rgb(90%, 45%, 0%)"));
|
||||
ok(tinycolor.equals(tinycolor({r:"90%", g: "45%", b: "0%" }), "rgb 90% 45% 0%"));
|
||||
ok(tinycolor.equals(tinycolor({r:"90%", g: "45%", b: "0%" }), "rgb 90% 45% 0%"));
|
||||
});
|
||||
|
||||
test("HSL parsing", function() {
|
||||
equal(tinycolor({ h: 251, s: 100, l: .38 }).toHexString(), "#2400c2", "to hex");
|
||||
equal(tinycolor({ h: 251, s: 100, l: .38 }).toRgbString(), "rgb(36, 0, 194)", "to rgb");
|
||||
equal(tinycolor({ h: 251, s: 100, l: .38 }).toHslString(), "hsl(251, 100%, 38%)", "to hsl");
|
||||
equal(tinycolor("hsl(251, 100, 38)").toHexString(), "#2400c2", "to hex");
|
||||
equal(tinycolor("hsl(251, 100%, 38%)").toRgbString(), "rgb(36, 0, 194)", "to rgb");
|
||||
equal(tinycolor("hsl(251, 100%, 38%)").toHslString(), "hsl(251, 100%, 38%)", "to hsl");
|
||||
equal(tinycolor("hsl 100 20 10").toHslString(), "hsl(100, 20%, 10%)", "problematic hsl");
|
||||
});
|
||||
|
||||
test("Hex Parsing", function() {
|
||||
equal(tinycolor("rgb 255 0 0").toHexString(), "#ff0000");
|
||||
equal(tinycolor("rgb 255 0 0").toHexString(true), "#f00");
|
||||
|
||||
equal(tinycolor("rgba 255 0 0 0.5").toHex8String(), "#ff000080");
|
||||
equal(tinycolor("rgba 255 0 0 0").toHex8String(), "#ff000000");
|
||||
equal(tinycolor("rgba 255 0 0 1").toHex8String(), "#ff0000ff");
|
||||
equal(tinycolor("rgba 255 0 0 1").toHex8String(true), "#f00f");
|
||||
|
||||
equal(tinycolor("rgb 255 0 0").toHex(), "ff0000");
|
||||
equal(tinycolor("rgb 255 0 0").toHex(true), "f00");
|
||||
equal(tinycolor("rgba 255 0 0 0.5").toHex8(), "ff000080");
|
||||
});
|
||||
|
||||
test("HSV Parsing", function() {
|
||||
equal(tinycolor("hsv 251.1 0.887 .918").toHsvString(), "hsv(251, 89%, 92%)");
|
||||
equal(tinycolor("hsv 251.1 0.887 0.918").toHsvString(), "hsv(251, 89%, 92%)");
|
||||
equal(tinycolor("hsva 251.1 0.887 0.918 0.5").toHsvString(), "hsva(251, 89%, 92%, 0.5)");
|
||||
});
|
||||
|
||||
test("Invalid Parsing", function() {
|
||||
var invalidColor = tinycolor("this is not a color");
|
||||
equal(invalidColor.toHexString(), "#000000");
|
||||
equal(false, invalidColor.isValid());
|
||||
|
||||
invalidColor = tinycolor("#red");
|
||||
equal(invalidColor.toHexString(), "#000000");
|
||||
equal(false, invalidColor.isValid());
|
||||
|
||||
invalidColor = tinycolor(" #red");
|
||||
equal(invalidColor.toHexString(), "#000000");
|
||||
equal(false, invalidColor.isValid());
|
||||
|
||||
invalidColor = tinycolor("##123456");
|
||||
equal(invalidColor.toHexString(), "#000000");
|
||||
equal(false, invalidColor.isValid());
|
||||
|
||||
invalidColor = tinycolor(" ##123456");
|
||||
equal(invalidColor.toHexString(), "#000000");
|
||||
equal(false, invalidColor.isValid());
|
||||
|
||||
invalidColor = tinycolor({r: 'invalid', g: 'invalid', b: 'invalid' });
|
||||
equal(invalidColor.toHexString(), "#000000");
|
||||
equal(false, invalidColor.isValid());
|
||||
|
||||
invalidColor = tinycolor({h: 'invalid', s: 'invalid', l: 'invalid' });
|
||||
equal(invalidColor.toHexString(), "#000000");
|
||||
equal(false, invalidColor.isValid());
|
||||
|
||||
invalidColor = tinycolor({h: 'invalid', s: 'invalid', v: 'invalid' });
|
||||
equal(invalidColor.toHexString(), "#000000");
|
||||
equal(false, invalidColor.isValid());
|
||||
});
|
||||
|
||||
test("Named colors", function() {
|
||||
equal(tinycolor("aliceblue").toHex(), "f0f8ff");
|
||||
equal(tinycolor("antiquewhite").toHex(), "faebd7");
|
||||
equal(tinycolor("aqua").toHex(), "00ffff");
|
||||
equal(tinycolor("aquamarine").toHex(), "7fffd4");
|
||||
equal(tinycolor("azure").toHex(), "f0ffff");
|
||||
equal(tinycolor("beige").toHex(), "f5f5dc");
|
||||
equal(tinycolor("bisque").toHex(), "ffe4c4");
|
||||
equal(tinycolor("black").toHex(), "000000");
|
||||
equal(tinycolor("blanchedalmond").toHex(), "ffebcd");
|
||||
equal(tinycolor("blue").toHex(), "0000ff");
|
||||
equal(tinycolor("blueviolet").toHex(), "8a2be2");
|
||||
equal(tinycolor("brown").toHex(), "a52a2a");
|
||||
equal(tinycolor("burlywood").toHex(), "deb887");
|
||||
equal(tinycolor("cadetblue").toHex(), "5f9ea0");
|
||||
equal(tinycolor("chartreuse").toHex(), "7fff00");
|
||||
equal(tinycolor("chocolate").toHex(), "d2691e");
|
||||
equal(tinycolor("coral").toHex(), "ff7f50");
|
||||
equal(tinycolor("cornflowerblue").toHex(), "6495ed");
|
||||
equal(tinycolor("cornsilk").toHex(), "fff8dc");
|
||||
equal(tinycolor("crimson").toHex(), "dc143c");
|
||||
equal(tinycolor("cyan").toHex(), "00ffff");
|
||||
equal(tinycolor("darkblue").toHex(), "00008b");
|
||||
equal(tinycolor("darkcyan").toHex(), "008b8b");
|
||||
equal(tinycolor("darkgoldenrod").toHex(), "b8860b");
|
||||
equal(tinycolor("darkgray").toHex(), "a9a9a9");
|
||||
equal(tinycolor("darkgreen").toHex(), "006400");
|
||||
equal(tinycolor("darkkhaki").toHex(), "bdb76b");
|
||||
equal(tinycolor("darkmagenta").toHex(), "8b008b");
|
||||
equal(tinycolor("darkolivegreen").toHex(), "556b2f");
|
||||
equal(tinycolor("darkorange").toHex(), "ff8c00");
|
||||
equal(tinycolor("darkorchid").toHex(), "9932cc");
|
||||
equal(tinycolor("darkred").toHex(), "8b0000");
|
||||
equal(tinycolor("darksalmon").toHex(), "e9967a");
|
||||
equal(tinycolor("darkseagreen").toHex(), "8fbc8f");
|
||||
equal(tinycolor("darkslateblue").toHex(), "483d8b");
|
||||
equal(tinycolor("darkslategray").toHex(), "2f4f4f");
|
||||
equal(tinycolor("darkturquoise").toHex(), "00ced1");
|
||||
equal(tinycolor("darkviolet").toHex(), "9400d3");
|
||||
equal(tinycolor("deeppink").toHex(), "ff1493");
|
||||
equal(tinycolor("deepskyblue").toHex(), "00bfff");
|
||||
equal(tinycolor("dimgray").toHex(), "696969");
|
||||
equal(tinycolor("dodgerblue").toHex(), "1e90ff");
|
||||
equal(tinycolor("firebrick").toHex(), "b22222");
|
||||
equal(tinycolor("floralwhite").toHex(), "fffaf0");
|
||||
equal(tinycolor("forestgreen").toHex(), "228b22");
|
||||
equal(tinycolor("fuchsia").toHex(), "ff00ff");
|
||||
equal(tinycolor("gainsboro").toHex(), "dcdcdc");
|
||||
equal(tinycolor("ghostwhite").toHex(), "f8f8ff");
|
||||
equal(tinycolor("gold").toHex(), "ffd700");
|
||||
equal(tinycolor("goldenrod").toHex(), "daa520");
|
||||
equal(tinycolor("gray").toHex(), "808080");
|
||||
equal(tinycolor("grey").toHex(), "808080");
|
||||
equal(tinycolor("green").toHex(), "008000");
|
||||
equal(tinycolor("greenyellow").toHex(), "adff2f");
|
||||
equal(tinycolor("honeydew").toHex(), "f0fff0");
|
||||
equal(tinycolor("hotpink").toHex(), "ff69b4");
|
||||
equal(tinycolor("indianred ").toHex(), "cd5c5c");
|
||||
equal(tinycolor("indigo ").toHex(), "4b0082");
|
||||
equal(tinycolor("ivory").toHex(), "fffff0");
|
||||
equal(tinycolor("khaki").toHex(), "f0e68c");
|
||||
equal(tinycolor("lavender").toHex(), "e6e6fa");
|
||||
equal(tinycolor("lavenderblush").toHex(), "fff0f5");
|
||||
equal(tinycolor("lawngreen").toHex(), "7cfc00");
|
||||
equal(tinycolor("lemonchiffon").toHex(), "fffacd");
|
||||
equal(tinycolor("lightblue").toHex(), "add8e6");
|
||||
equal(tinycolor("lightcoral").toHex(), "f08080");
|
||||
equal(tinycolor("lightcyan").toHex(), "e0ffff");
|
||||
equal(tinycolor("lightgoldenrodyellow").toHex(), "fafad2");
|
||||
equal(tinycolor("lightgrey").toHex(), "d3d3d3");
|
||||
equal(tinycolor("lightgreen").toHex(), "90ee90");
|
||||
equal(tinycolor("lightpink").toHex(), "ffb6c1");
|
||||
equal(tinycolor("lightsalmon").toHex(), "ffa07a");
|
||||
equal(tinycolor("lightseagreen").toHex(), "20b2aa");
|
||||
equal(tinycolor("lightskyblue").toHex(), "87cefa");
|
||||
equal(tinycolor("lightslategray").toHex(), "778899");
|
||||
equal(tinycolor("lightsteelblue").toHex(), "b0c4de");
|
||||
equal(tinycolor("lightyellow").toHex(), "ffffe0");
|
||||
equal(tinycolor("lime").toHex(), "00ff00");
|
||||
equal(tinycolor("limegreen").toHex(), "32cd32");
|
||||
equal(tinycolor("linen").toHex(), "faf0e6");
|
||||
equal(tinycolor("magenta").toHex(), "ff00ff");
|
||||
equal(tinycolor("maroon").toHex(), "800000");
|
||||
equal(tinycolor("mediumaquamarine").toHex(), "66cdaa");
|
||||
equal(tinycolor("mediumblue").toHex(), "0000cd");
|
||||
equal(tinycolor("mediumorchid").toHex(), "ba55d3");
|
||||
equal(tinycolor("mediumpurple").toHex(), "9370db");
|
||||
equal(tinycolor("mediumseagreen").toHex(), "3cb371");
|
||||
equal(tinycolor("mediumslateblue").toHex(), "7b68ee");
|
||||
equal(tinycolor("mediumspringgreen").toHex(), "00fa9a");
|
||||
equal(tinycolor("mediumturquoise").toHex(), "48d1cc");
|
||||
equal(tinycolor("mediumvioletred").toHex(), "c71585");
|
||||
equal(tinycolor("midnightblue").toHex(), "191970");
|
||||
equal(tinycolor("mintcream").toHex(), "f5fffa");
|
||||
equal(tinycolor("mistyrose").toHex(), "ffe4e1");
|
||||
equal(tinycolor("moccasin").toHex(), "ffe4b5");
|
||||
equal(tinycolor("navajowhite").toHex(), "ffdead");
|
||||
equal(tinycolor("navy").toHex(), "000080");
|
||||
equal(tinycolor("oldlace").toHex(), "fdf5e6");
|
||||
equal(tinycolor("olive").toHex(), "808000");
|
||||
equal(tinycolor("olivedrab").toHex(), "6b8e23");
|
||||
equal(tinycolor("orange").toHex(), "ffa500");
|
||||
equal(tinycolor("orangered").toHex(), "ff4500");
|
||||
equal(tinycolor("orchid").toHex(), "da70d6");
|
||||
equal(tinycolor("palegoldenrod").toHex(), "eee8aa");
|
||||
equal(tinycolor("palegreen").toHex(), "98fb98");
|
||||
equal(tinycolor("paleturquoise").toHex(), "afeeee");
|
||||
equal(tinycolor("palevioletred").toHex(), "db7093");
|
||||
equal(tinycolor("papayawhip").toHex(), "ffefd5");
|
||||
equal(tinycolor("peachpuff").toHex(), "ffdab9");
|
||||
equal(tinycolor("peru").toHex(), "cd853f");
|
||||
equal(tinycolor("pink").toHex(), "ffc0cb");
|
||||
equal(tinycolor("plum").toHex(), "dda0dd");
|
||||
equal(tinycolor("powderblue").toHex(), "b0e0e6");
|
||||
equal(tinycolor("purple").toHex(), "800080");
|
||||
equal(tinycolor("rebeccapurple").toHex(), "663399");
|
||||
equal(tinycolor("red").toHex(), "ff0000");
|
||||
equal(tinycolor("rosybrown").toHex(), "bc8f8f");
|
||||
equal(tinycolor("royalblue").toHex(), "4169e1");
|
||||
equal(tinycolor("saddlebrown").toHex(), "8b4513");
|
||||
equal(tinycolor("salmon").toHex(), "fa8072");
|
||||
equal(tinycolor("sandybrown").toHex(), "f4a460");
|
||||
equal(tinycolor("seagreen").toHex(), "2e8b57");
|
||||
equal(tinycolor("seashell").toHex(), "fff5ee");
|
||||
equal(tinycolor("sienna").toHex(), "a0522d");
|
||||
equal(tinycolor("silver").toHex(), "c0c0c0");
|
||||
equal(tinycolor("skyblue").toHex(), "87ceeb");
|
||||
equal(tinycolor("slateblue").toHex(), "6a5acd");
|
||||
equal(tinycolor("slategray").toHex(), "708090");
|
||||
equal(tinycolor("snow").toHex(), "fffafa");
|
||||
equal(tinycolor("springgreen").toHex(), "00ff7f");
|
||||
equal(tinycolor("steelblue").toHex(), "4682b4");
|
||||
equal(tinycolor("tan").toHex(), "d2b48c");
|
||||
equal(tinycolor("teal").toHex(), "008080");
|
||||
equal(tinycolor("thistle").toHex(), "d8bfd8");
|
||||
equal(tinycolor("tomato").toHex(), "ff6347");
|
||||
equal(tinycolor("turquoise").toHex(), "40e0d0");
|
||||
equal(tinycolor("violet").toHex(), "ee82ee");
|
||||
equal(tinycolor("wheat").toHex(), "f5deb3");
|
||||
equal(tinycolor("white").toHex(), "ffffff");
|
||||
equal(tinycolor("whitesmoke").toHex(), "f5f5f5");
|
||||
equal(tinycolor("yellow").toHex(), "ffff00");
|
||||
equal(tinycolor("yellowgreen").toHex(), "9acd32");
|
||||
|
||||
equal(tinycolor("#f00").toName(), "red");
|
||||
equal(tinycolor("#fa0a0a").toName(), false);
|
||||
});
|
||||
|
||||
module("Alpha handling");
|
||||
|
||||
test("Invalid alpha should normalize to 1", function() {
|
||||
equal(tinycolor({r:255,g:20,b:10,a: -1}).toRgbString(), "rgb(255, 20, 10)", "Negative value");
|
||||
equal(tinycolor({r:255,g:20,b:10,a: -0}).toRgbString(), "rgba(255, 20, 10, 0)", "Negative 0");
|
||||
equal(tinycolor({r:255,g:20,b:10,a: 0}).toRgbString(), "rgba(255, 20, 10, 0)", "0");
|
||||
equal(tinycolor({r:255,g:20,b:10,a: .5}).toRgbString(), "rgba(255, 20, 10, 0.5)", ".5");
|
||||
equal(tinycolor({r:255,g:20,b:10,a: 1}).toRgbString(), "rgb(255, 20, 10)", "1");
|
||||
equal(tinycolor({r:255,g:20,b:10,a: 100}).toRgbString(), "rgb(255, 20, 10)", "Greater than 1");
|
||||
equal(tinycolor({r:255,g:20,b:10,a: "asdfasd"}).toRgbString(), "rgb(255, 20, 10)", "Non Numeric");
|
||||
|
||||
equal(tinycolor("#fff").toRgbString(), "rgb(255, 255, 255)", "Hex should be 1");
|
||||
equal(tinycolor("rgba 255 0 0 100").toRgbString(), "rgb(255, 0, 0)", "Greater than 1 in string parsing");
|
||||
});
|
||||
|
||||
test("toString() with alpha set", function() {
|
||||
var redNamed = tinycolor.fromRatio({ r: 255, g: 0, b: 0, a: .6}, {format: "name"});
|
||||
var transparentNamed = tinycolor.fromRatio({ r: 255, g: 0, b: 0, a: 0 }, {format: "name"});
|
||||
var redHex = tinycolor.fromRatio({ r: 255, g: 0, b: 0, a: .4}, {format: "hex"});
|
||||
|
||||
equal(redNamed.getFormat(), "name", "getFormat() is correct");
|
||||
equal(redHex.getFormat(), "hex", "getFormat() is correct");
|
||||
|
||||
equal(redNamed.toString(), "rgba(255, 0, 0, 0.6)", "Names should default to rgba if alpha is < 1");
|
||||
equal(redHex.toString(), "rgba(255, 0, 0, 0.4)", "Hex should default to rgba if alpha is < 1");
|
||||
|
||||
equal(redNamed.toString("hex"), "#ff0000", "Names should not be returned as rgba if format is specified");
|
||||
equal(redNamed.toString("hex6"), "#ff0000", "Names should not be returned as rgba if format is specified");
|
||||
equal(redNamed.toString("hex3"), "#f00", "Names should not be returned as rgba if format is specified");
|
||||
equal(redNamed.toString("hex8"), "#ff000099", "Names should not be returned as rgba if format is specified");
|
||||
equal(redNamed.toString("hex4"), "#f009", "Names should not be returned as rgba if format is specified");
|
||||
equal(redNamed.toString("name"), "#ff0000", "Semi transparent names should return hex in toString() if name format is specified");
|
||||
|
||||
equal(redNamed.toName(), false, "Semi transparent names should be false in toName()");
|
||||
|
||||
equal(redHex.toString(), "rgba(255, 0, 0, 0.4)", "Hex should default to rgba if alpha is < 1");
|
||||
equal(transparentNamed.toString(), "transparent", "Named color should equal transparent if alpha == 0");
|
||||
|
||||
redHex.setAlpha(0);
|
||||
equal(redHex.toString(), "rgba(255, 0, 0, 0)", "Hex should default to rgba if alpha is = 0");
|
||||
});
|
||||
|
||||
test("setting alpha", function() {
|
||||
var hexSetter = tinycolor("rgba(255, 0, 0, 1)");
|
||||
equal(hexSetter.getAlpha(), 1, "Alpha should start as 1");
|
||||
var returnedFromSetAlpha = hexSetter.setAlpha(.9);
|
||||
equal(returnedFromSetAlpha, hexSetter, "setAlpha return value should be the color.");
|
||||
equal(hexSetter.getAlpha(), .9, "setAlpha should change alpha value");
|
||||
hexSetter.setAlpha(.5);
|
||||
equal(hexSetter.getAlpha(), .5, "setAlpha should change alpha value");
|
||||
hexSetter.setAlpha(0);
|
||||
equal(hexSetter.getAlpha(), 0, "setAlpha should change alpha value");
|
||||
hexSetter.setAlpha(-1);
|
||||
equal(hexSetter.getAlpha(), 1, "setAlpha with value < 0 should be bound to 1");
|
||||
hexSetter.setAlpha(2);
|
||||
equal(hexSetter.getAlpha(), 1, "setAlpha with value > 1 should be bound to 1");
|
||||
hexSetter.setAlpha();
|
||||
equal(hexSetter.getAlpha(), 1, "setAlpha with invalid value should be bound to 1");
|
||||
hexSetter.setAlpha(null);
|
||||
equal(hexSetter.getAlpha(), 1, "setAlpha with invalid value should be bound to 1");
|
||||
hexSetter.setAlpha("test");
|
||||
equal(hexSetter.getAlpha(), 1, "setAlpha with invalid value should be bound to 1");
|
||||
});
|
||||
|
||||
test("Alpha = 0 should act differently on toName()", function() {
|
||||
equal(tinycolor({r:255,g:20,b:10,a: 0}).toName(), "transparent", "0");
|
||||
equal(tinycolor("transparent").toString(), "transparent", "toString when passed");
|
||||
equal(tinycolor("transparent").toHex(), "000000", "toHex");
|
||||
});
|
||||
|
||||
|
||||
module("Brightness handling");
|
||||
|
||||
test("getBrightness", function() {
|
||||
equal(tinycolor('#000').getBrightness(), 0, 'returns 0 for #000');
|
||||
equal(tinycolor('#fff').getBrightness(), 255, 'returns 255 for #fff');
|
||||
});
|
||||
|
||||
test("getLuminance", function() {
|
||||
equal(tinycolor('#000').getLuminance(), 0, 'returns 0 for #000');
|
||||
equal(tinycolor('#fff').getLuminance(), 1, 'returns 1 for #fff');
|
||||
});
|
||||
|
||||
test("isDark returns true/false for dark/light colors", function() {
|
||||
equal(tinycolor('#000').isDark(), true, '#000 is dark');
|
||||
equal(tinycolor('#111').isDark(), true, '#111 is dark');
|
||||
equal(tinycolor('#222').isDark(), true, '#222 is dark');
|
||||
equal(tinycolor('#333').isDark(), true, '#333 is dark');
|
||||
equal(tinycolor('#444').isDark(), true, '#444 is dark');
|
||||
equal(tinycolor('#555').isDark(), true, '#555 is dark');
|
||||
equal(tinycolor('#666').isDark(), true, '#666 is dark');
|
||||
equal(tinycolor('#777').isDark(), true, '#777 is dark');
|
||||
equal(tinycolor('#888').isDark(), false, '#888 is not dark');
|
||||
equal(tinycolor('#999').isDark(), false, '#999 is not dark');
|
||||
equal(tinycolor('#aaa').isDark(), false, '#aaa is not dark');
|
||||
equal(tinycolor('#bbb').isDark(), false, '#bbb is not dark');
|
||||
equal(tinycolor('#ccc').isDark(), false, '#ccc is not dark');
|
||||
equal(tinycolor('#ddd').isDark(), false, '#ddd is not dark');
|
||||
equal(tinycolor('#eee').isDark(), false, '#eee is not dark');
|
||||
equal(tinycolor('#fff').isDark(), false, '#fff is not dark');
|
||||
});
|
||||
|
||||
test("isLight returns true/false for light/dark colors", function() {
|
||||
equal(tinycolor('#000').isLight(), false, '#000 is not light');
|
||||
equal(tinycolor('#111').isLight(), false, '#111 is not light');
|
||||
equal(tinycolor('#222').isLight(), false, '#222 is not light');
|
||||
equal(tinycolor('#333').isLight(), false, '#333 is not light');
|
||||
equal(tinycolor('#444').isLight(), false, '#444 is not light');
|
||||
equal(tinycolor('#555').isLight(), false, '#555 is not light');
|
||||
equal(tinycolor('#666').isLight(), false, '#666 is not light');
|
||||
equal(tinycolor('#777').isLight(), false, '#777 is not light');
|
||||
equal(tinycolor('#888').isLight(), true, '#888 is light');
|
||||
equal(tinycolor('#999').isLight(), true, '#999 is light');
|
||||
equal(tinycolor('#aaa').isLight(), true, '#aaa is light');
|
||||
equal(tinycolor('#bbb').isLight(), true, '#bbb is light');
|
||||
equal(tinycolor('#ccc').isLight(), true, '#ccc is light');
|
||||
equal(tinycolor('#ddd').isLight(), true, '#ddd is light');
|
||||
equal(tinycolor('#eee').isLight(), true, '#eee is light');
|
||||
equal(tinycolor('#fff').isLight(), true, '#fff is light');
|
||||
});
|
||||
|
||||
module("Initialization from tinycolor output");
|
||||
|
||||
test("HSL Object", function() {
|
||||
for (var i = 0; i < conversions.length; i++) {
|
||||
var c = conversions[i];
|
||||
var tiny = tinycolor(c.hex);
|
||||
equal(tiny.toHexString(), tinycolor(tiny.toHsl()).toHexString(), "HSL Object");
|
||||
}
|
||||
});
|
||||
|
||||
test("HSL String", function() {
|
||||
for (var i = 0; i < conversions.length; i++) {
|
||||
var c = conversions[i];
|
||||
var tiny = tinycolor(c.hex);
|
||||
var input = tiny.toRgb();
|
||||
var output = tinycolor(tiny.toHslString()).toRgb();
|
||||
var maxDiff = 2;
|
||||
|
||||
equal(Math.abs(input.r - output.r) <= maxDiff, true, "toHslString red value difference <= " + maxDiff);
|
||||
equal(Math.abs(input.g - output.g) <= maxDiff, true, "toHslString green value difference <= " + maxDiff);
|
||||
equal(Math.abs(input.b - output.b) <= maxDiff, true, "toHslString blue value difference <= " + maxDiff);
|
||||
}
|
||||
});
|
||||
|
||||
test("HSV String", function() {
|
||||
for (var i = 0; i < conversions.length; i++) {
|
||||
var c = conversions[i];
|
||||
var tiny = tinycolor(c.hex);
|
||||
var input = tiny.toRgb();
|
||||
var output = tinycolor(tiny.toHsvString()).toRgb();
|
||||
var maxDiff = 2;
|
||||
|
||||
equal(Math.abs(input.r - output.r) <= maxDiff, true, "toHsvString red value difference <= " + maxDiff);
|
||||
equal(Math.abs(input.g - output.g) <= maxDiff, true, "toHsvString green value difference <= " + maxDiff);
|
||||
equal(Math.abs(input.b - output.b) <= maxDiff, true, "toHsvString blue value difference <= " + maxDiff);
|
||||
}
|
||||
});
|
||||
|
||||
test("HSV Object", function() {
|
||||
for (var i = 0; i < conversions.length; i++) {
|
||||
var c = conversions[i];
|
||||
var tiny = tinycolor(c.hex);
|
||||
equal(tiny.toHexString(), tinycolor(tiny.toHsv()).toHexString(), "HSV Object");
|
||||
}
|
||||
});
|
||||
|
||||
test("RGB Object", function() {
|
||||
for (var i = 0; i < conversions.length; i++) {
|
||||
var c = conversions[i];
|
||||
var tiny = tinycolor(c.hex);
|
||||
equal(tiny.toHexString(), tinycolor(tiny.toRgb()).toHexString(), "RGB Object");
|
||||
}
|
||||
});
|
||||
|
||||
test("RGB String", function() {
|
||||
for (var i = 0; i < conversions.length; i++) {
|
||||
var c = conversions[i];
|
||||
var tiny = tinycolor(c.hex);
|
||||
equal(tiny.toHexString(), tinycolor(tiny.toRgbString()).toHexString(), "RGB String");
|
||||
}
|
||||
});
|
||||
|
||||
test("PRGB Object", function() {
|
||||
for (var i = 0; i < conversions.length; i++) {
|
||||
var c = conversions[i];
|
||||
var tiny = tinycolor(c.hex);
|
||||
var input = tiny.toRgb();
|
||||
var output = tinycolor(tiny.toPercentageRgb()).toRgb();
|
||||
var maxDiff = 2;
|
||||
|
||||
equal(Math.abs(input.r - output.r) <= maxDiff, true, "Red value difference <= " + maxDiff);
|
||||
equal(Math.abs(input.g - output.g) <= maxDiff, true, "Green value difference <= " + maxDiff);
|
||||
equal(Math.abs(input.b - output.b) <= maxDiff, true, "Blue value difference <= " + maxDiff);
|
||||
}
|
||||
});
|
||||
|
||||
test("PRGB String", function() {
|
||||
for (var i = 0; i < conversions.length; i++) {
|
||||
var c = conversions[i];
|
||||
var tiny = tinycolor(c.hex);
|
||||
var input = tiny.toRgb();
|
||||
var output = tinycolor(tiny.toPercentageRgbString()).toRgb();
|
||||
var maxDiff = 2;
|
||||
|
||||
equal(Math.abs(input.r - output.r) <= maxDiff, true, "Red value difference <= " + maxDiff);
|
||||
equal(Math.abs(input.g - output.g) <= maxDiff, true, "Green value difference <= " + maxDiff);
|
||||
equal(Math.abs(input.b - output.b) <= maxDiff, true, "Blue value difference <= " + maxDiff);
|
||||
}
|
||||
});
|
||||
|
||||
test("Object", function() {
|
||||
for (var i = 0; i < conversions.length; i++) {
|
||||
var c = conversions[i];
|
||||
var tiny = tinycolor(c.hex);
|
||||
equal(tiny.toHexString(), tinycolor(tiny).toHexString(), "Object");
|
||||
}
|
||||
});
|
||||
|
||||
module("Utilities");
|
||||
|
||||
test("Color equality", function() {
|
||||
ok(tinycolor.equals("#ff0000", "#ff0000"), "Same hex");
|
||||
ok(tinycolor.equals("#ff0000", "rgb(255, 0, 0)"), "Same alphas");
|
||||
ok(!tinycolor.equals("#ff0000", "rgba(255, 0, 0, .1)"), "Different alphas");
|
||||
ok(tinycolor.equals("#ff000066", "rgba(255, 0, 0, .4)"), "Same alphas");
|
||||
ok(tinycolor.equals("#f009", "rgba(255, 0, 0, .6)"), "Same alphas");
|
||||
ok(tinycolor.equals("#336699CC", "369C"), "Same hex");
|
||||
ok(tinycolor.equals("ff0000", "#ff0000"), "Same hex");
|
||||
ok(tinycolor.equals("#f00", "#ff0000"), "Same hex");
|
||||
ok(tinycolor.equals("#f00", "#ff0000"), "Same hex");
|
||||
ok(tinycolor.equals("f00", "#ff0000"), "Same hex");
|
||||
equal(tinycolor("010101").toHexString(), "#010101");
|
||||
ok(!tinycolor.equals("#ff0000", "#00ff00"), "Different hex");
|
||||
ok(tinycolor.equals("#ff8000", "rgb(100%, 50%, 0%)"), "Percentage bounds checking");
|
||||
});
|
||||
|
||||
test("isReadable", function() {
|
||||
// "#ff0088", "#8822aa" (values used in old WCAG1 tests)
|
||||
ok(tinycolor.isReadable("#000000", "#ffffff",{level:"AA",size:"small"}), "white/black is readable");
|
||||
ok(!tinycolor.isReadable("#ff0088", "#5c1a72",{}), "not readable - empty wcag2 object");
|
||||
ok(!tinycolor.isReadable("#ff0088", "#8822aa",{level:"AA",size:"small"}), "not readable - AA small");
|
||||
ok(!tinycolor.isReadable("#ff0088", "#8822aa",{level:"AA",size:"large"}), "not readable - AA large");
|
||||
ok(!tinycolor.isReadable("#ff0088", "#8822aa",{level:"AAA",size:"small"}), "not readable - AAA small");
|
||||
ok(!tinycolor.isReadable("#ff0088", "#8822aa",{level:"AAA",size:"large"}), "not readable - AAA large");
|
||||
|
||||
// values derived from and validated using the calculators at http://www.dasplankton.de/ContrastA/
|
||||
// and http://webaim.org/resources/contrastchecker/
|
||||
|
||||
// "#ff0088", "#5c1a72": contrast ratio 3.04
|
||||
ok(!tinycolor.isReadable("#ff0088", "#5c1a72",{level:"AA",size:"small"}), "not readable - AA small");
|
||||
ok(tinycolor.isReadable("#ff0088", "#5c1a72",{level:"AA",size:"large"}), "readable - AA large");
|
||||
ok(!tinycolor.isReadable("#ff0088", "#5c1a72",{level:"AAA",size:"small"}), "not readable - AAA small");
|
||||
ok(!tinycolor.isReadable("#ff0088", "#5c1a72",{level:"AAA",size:"large"}), "not readable - AAA large");
|
||||
|
||||
// "#ff0088", "#2e0c3a": contrast ratio 4.56
|
||||
ok(tinycolor.isReadable("#ff0088", "#2e0c3a",{level:"AA",size:"small"}), "readable - AA small");
|
||||
ok(tinycolor.isReadable("#ff0088", "#2e0c3a",{level:"AA",size:"large"}), "readable - AA large");
|
||||
ok(!tinycolor.isReadable("#ff0088", "#2e0c3a",{level:"AAA",size:"small"}), "not readable - AAA small");
|
||||
ok(tinycolor.isReadable("#ff0088", "#2e0c3a",{level:"AAA",size:"large"}), "readable - AAA large");
|
||||
|
||||
// "#db91b8", "#2e0c3a": contrast ratio 7.12
|
||||
ok(tinycolor.isReadable("#db91b8", "#2e0c3a",{level:"AA",size:"small"}), "readable - AA small");
|
||||
ok(tinycolor.isReadable("#db91b8", "#2e0c3a",{level:"AA",size:"large"}), "readable - AA large");
|
||||
ok(tinycolor.isReadable("#db91b8", "#2e0c3a",{level:"AAA",size:"small"}), "readable - AAA small");
|
||||
ok(tinycolor.isReadable("#db91b8", "#2e0c3a",{level:"AAA",size:"large"}), "readable - AAA large");
|
||||
});
|
||||
|
||||
test("readability", function() {
|
||||
// check return values from readability function. See isReadable above for standards tests.
|
||||
equal(tinycolor.readability("#000", "#000"), 1, "Readability function test 0");
|
||||
deepEqual(tinycolor.readability("#000", "#111"), 1.1121078324840545, "Readability function test 1");
|
||||
deepEqual(tinycolor.readability("#000", "#fff"), 21, "Readability function test 2");
|
||||
});
|
||||
|
||||
test("mostReadable", function () {
|
||||
equal(tinycolor.mostReadable("#000", ["#111", "#222",{wcag2:{}}]).toHexString(), "#222222", "readable color present");
|
||||
equal(tinycolor.mostReadable("#f00", ["#d00", "#0d0"],{wcag2:{}}).toHexString(), "#00dd00", "readable color present");
|
||||
equal(tinycolor.mostReadable("#fff", ["#fff", "#fff"],{wcag2:{}}).toHexString(), "#ffffff", "no different color in list");
|
||||
//includeFallbackColors
|
||||
equal(tinycolor.mostReadable("#fff", ["#fff", "#fff"],{includeFallbackColors:true}).toHexString(), "#000000", "no different color in list");
|
||||
equal(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:false}).toHexString(), "#112255", "no readable color in list");
|
||||
equal(tinycolor.mostReadable("#123", ["#000", "#fff"],{includeFallbackColors:false}).toHexString(), "#ffffff", "verify assumption");
|
||||
equal(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:true}).toHexString(), "#ffffff", "no readable color in list");
|
||||
|
||||
equal(tinycolor.mostReadable("#ff0088", ["#000", "#fff"],{includeFallbackColors:false}).toHexString(), "#000000", "verify assumption");
|
||||
equal(tinycolor.mostReadable("#ff0088", ["#2e0c3a"],{includeFallbackColors:true,level:"AAA",size:"large"}).toHexString(), "#2e0c3a", "readable color present");
|
||||
equal(tinycolor.mostReadable("#ff0088", ["#2e0c3a"],{includeFallbackColors:true,level:"AAA",size:"small"}).toHexString(), "#000000", "no readable color in list");
|
||||
|
||||
equal(tinycolor.mostReadable("#371b2c", ["#000", "#fff"],{includeFallbackColors:false}).toHexString(), "#ffffff", "verify assumption");
|
||||
equal(tinycolor.mostReadable("#371b2c", ["#a9acb6"],{includeFallbackColors:true,level:"AAA",size:"large"}).toHexString(), "#a9acb6", "readable color present");
|
||||
equal(tinycolor.mostReadable("#371b2c", ["#a9acb6"],{includeFallbackColors:true,level:"AAA",size:"small"}).toHexString(), "#ffffff", "no readable color in list");
|
||||
});
|
||||
|
||||
|
||||
test("Filters", function () {
|
||||
equal(tinycolor("red").toFilter(), "progid:DXImageTransform.Microsoft.gradient(startColorstr=#ffff0000,endColorstr=#ffff0000)");
|
||||
equal(tinycolor("red").toFilter("blue"), "progid:DXImageTransform.Microsoft.gradient(startColorstr=#ffff0000,endColorstr=#ff0000ff)");
|
||||
|
||||
equal(tinycolor("transparent").toFilter(), "progid:DXImageTransform.Microsoft.gradient(startColorstr=#00000000,endColorstr=#00000000)");
|
||||
equal(tinycolor("transparent").toFilter("red"), "progid:DXImageTransform.Microsoft.gradient(startColorstr=#00000000,endColorstr=#ffff0000)");
|
||||
|
||||
equal(tinycolor("#f0f0f0dd").toFilter(), "progid:DXImageTransform.Microsoft.gradient(startColorstr=#ddf0f0f0,endColorstr=#ddf0f0f0)");
|
||||
equal(tinycolor("rgba(0, 0, 255, .5").toFilter(), "progid:DXImageTransform.Microsoft.gradient(startColorstr=#800000ff,endColorstr=#800000ff)");
|
||||
});
|
||||
|
||||
module("Modifications");
|
||||
|
||||
/* Originally generated with:
|
||||
var results = [];
|
||||
for (var i = 0; i <= 100; i++) results.push( tinycolor.saturate("red", i).toHex() )
|
||||
console.log(JSON.stringify(results))
|
||||
*/
|
||||
var DESATURATIONS = ["ff0000","fe0101","fc0303","fb0404","fa0505","f90606","f70808","f60909","f50a0a","f40b0b","f20d0d","f10e0e","f00f0f","ee1111","ed1212","ec1313","eb1414","e91616","e81717","e71818","e61919","e41b1b","e31c1c","e21d1d","e01f1f","df2020","de2121","dd2222","db2424","da2525","d92626","d72828","d62929","d52a2a","d42b2b","d22d2d","d12e2e","d02f2f","cf3030","cd3232","cc3333","cb3434","c93636","c83737","c73838","c63939","c43b3b","c33c3c","c23d3d","c13e3e","bf4040","be4141","bd4242","bb4444","ba4545","b94646","b84747","b64949","b54a4a","b44b4b","b34d4d","b14e4e","b04f4f","af5050","ad5252","ac5353","ab5454","aa5555","a85757","a75858","a65959","a45b5b","a35c5c","a25d5d","a15e5e","9f6060","9e6161","9d6262","9c6363","9a6565","996666","986767","966969","956a6a","946b6b","936c6c","916e6e","906f6f","8f7070","8e7171","8c7373","8b7474","8a7575","887777","877878","867979","857a7a","837c7c","827d7d","817e7e","808080"];
|
||||
var SATURATIONS = ["ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000","ff0000"];
|
||||
var LIGHTENS = ["ff0000","ff0505","ff0a0a","ff0f0f","ff1414","ff1a1a","ff1f1f","ff2424","ff2929","ff2e2e","ff3333","ff3838","ff3d3d","ff4242","ff4747","ff4d4d","ff5252","ff5757","ff5c5c","ff6161","ff6666","ff6b6b","ff7070","ff7575","ff7a7a","ff8080","ff8585","ff8a8a","ff8f8f","ff9494","ff9999","ff9e9e","ffa3a3","ffa8a8","ffadad","ffb3b3","ffb8b8","ffbdbd","ffc2c2","ffc7c7","ffcccc","ffd1d1","ffd6d6","ffdbdb","ffe0e0","ffe5e5","ffebeb","fff0f0","fff5f5","fffafa","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff","ffffff"];
|
||||
var BRIGHTENS = ["ff0000","ff0303","ff0505","ff0808","ff0a0a","ff0d0d","ff0f0f","ff1212","ff1414","ff1717","ff1919","ff1c1c","ff1f1f","ff2121","ff2424","ff2626","ff2929","ff2b2b","ff2e2e","ff3030","ff3333","ff3636","ff3838","ff3b3b","ff3d3d","ff4040","ff4242","ff4545","ff4747","ff4a4a","ff4c4c","ff4f4f","ff5252","ff5454","ff5757","ff5959","ff5c5c","ff5e5e","ff6161","ff6363","ff6666","ff6969","ff6b6b","ff6e6e","ff7070","ff7373","ff7575","ff7878","ff7a7a","ff7d7d","ff7f7f","ff8282","ff8585","ff8787","ff8a8a","ff8c8c","ff8f8f","ff9191","ff9494","ff9696","ff9999","ff9c9c","ff9e9e","ffa1a1","ffa3a3","ffa6a6","ffa8a8","ffabab","ffadad","ffb0b0","ffb2b2","ffb5b5","ffb8b8","ffbaba","ffbdbd","ffbfbf","ffc2c2","ffc4c4","ffc7c7","ffc9c9","ffcccc","ffcfcf","ffd1d1","ffd4d4","ffd6d6","ffd9d9","ffdbdb","ffdede","ffe0e0","ffe3e3","ffe5e5","ffe8e8","ffebeb","ffeded","fff0f0","fff2f2","fff5f5","fff7f7","fffafa","fffcfc","ffffff"];
|
||||
var DARKENS = ["ff0000","fa0000","f50000","f00000","eb0000","e60000","e00000","db0000","d60000","d10000","cc0000","c70000","c20000","bd0000","b80000","b30000","ad0000","a80000","a30000","9e0000","990000","940000","8f0000","8a0000","850000","800000","7a0000","750000","700000","6b0000","660000","610000","5c0000","570000","520000","4d0000","470000","420000","3d0000","380000","330000","2e0000","290000","240000","1f0000","190000","140000","0f0000","0a0000","050000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000","000000"];
|
||||
|
||||
test("Modifications", function () {
|
||||
for (var i = 0; i <= 100; i++) {
|
||||
equal(tinycolor("red").desaturate(i).toHex(), DESATURATIONS[i], "Desaturation " + i + " works");
|
||||
}
|
||||
for (var i = 0; i <= 100; i++) {
|
||||
equal(tinycolor("red").saturate(i).toHex(), SATURATIONS[i], "Saturation " + i + " works");
|
||||
}
|
||||
for (var i = 0; i <= 100; i++) {
|
||||
equal(tinycolor("red").lighten(i).toHex(), LIGHTENS[i], "Lighten " + i + " works");
|
||||
}
|
||||
for (var i = 0; i <= 100; i++) {
|
||||
equal(tinycolor("red").brighten(i).toHex(), BRIGHTENS[i], "Brighter " + i + " works");
|
||||
}
|
||||
for (var i = 0; i <= 100; i++) {
|
||||
equal(tinycolor("red").darken(i).toHex(), DARKENS[i], "Darken " + i + " works");
|
||||
}
|
||||
|
||||
equal(tinycolor("red").greyscale().toHex(), "808080", "Greyscale works");
|
||||
});
|
||||
|
||||
test("Spin", function () {
|
||||
equal(Math.round(tinycolor("#f00").spin(-1234).toHsl().h), 206, "Spinning -1234 works");
|
||||
equal(Math.round(tinycolor("#f00").spin(-360).toHsl().h), 0, "Spinning -360 works");
|
||||
equal(Math.round(tinycolor("#f00").spin(-120).toHsl().h), 240, "Spinning -120 works");
|
||||
equal(Math.round(tinycolor("#f00").spin(0).toHsl().h), 0, "Spinning 0 works");
|
||||
equal(Math.round(tinycolor("#f00").spin(10).toHsl().h), 10, "Spinning 10 works");
|
||||
equal(Math.round(tinycolor("#f00").spin(360).toHsl().h), 0, "Spinning 360 works");
|
||||
equal(Math.round(tinycolor("#f00").spin(2345).toHsl().h), 185, "Spinning 2345 works");
|
||||
|
||||
[-360, 0, 360].forEach(function (delta) {
|
||||
Object.keys(tinycolor.names).forEach(function (name) {
|
||||
equal(tinycolor(name).toHex(), tinycolor(name).spin(delta).toHex(), "Spinning " + delta.toString() + " has no effect")
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
test("Mix", function () {
|
||||
// amount 0 or none
|
||||
equal(tinycolor.mix('#000', '#fff').toHsl().l, 0.5, "Mixing without amount works");
|
||||
equal(tinycolor.mix('#f00', '#000', 0).toHex(), 'ff0000', "Mixing with 0 amount works");
|
||||
// This case checks the the problem with floating point numbers (eg 255/90)
|
||||
equal(tinycolor.mix('#fff', '#000', 90).toHex(), '1a1a1a', "Mixing with 90 amount works correctly");
|
||||
|
||||
// black and white
|
||||
for (var i = 0; i < 100; i++) {
|
||||
equal(Math.round(tinycolor.mix('#000', '#fff', i).toHsl().l * 100) / 100, i / 100, "Mixing black and white with " + i + " amount works");
|
||||
}
|
||||
|
||||
// with colors
|
||||
for (var i = 0; i < 100; i++) {
|
||||
var new_hex = Math.round((255 * (100 - i)) / 100).toString(16);
|
||||
|
||||
if (new_hex.length === 1) {
|
||||
new_hex = '0' + new_hex;
|
||||
}
|
||||
|
||||
equal(tinycolor.mix('#f00', '#000', i).toHex(), new_hex + '0000', "Mixing " + i + " (red channel)");
|
||||
equal(tinycolor.mix('#0f0', '#000', i).toHex(), '00' + new_hex + '00', "Mixing " + i + " (green channel)");
|
||||
equal(tinycolor.mix('#00f', '#000', i).toHex(), '0000' + new_hex, "Mixing " + i + " (blue channel)");
|
||||
equal(tinycolor.mix(tinycolor('transparent'), '#000', i).toRgb().a, i / 100, "Mixing " + i + " (alpha channel)");
|
||||
}
|
||||
});
|
||||
|
||||
// The combination tests need to be expanded further
|
||||
module("Combinations");
|
||||
|
||||
function colorsToHexString(colors) {
|
||||
return colors.map(function(c) {
|
||||
return c.toHex();
|
||||
}).join(",");
|
||||
}
|
||||
|
||||
test("complement", function() {
|
||||
var complementDoesntModifyInstance = tinycolor("red");
|
||||
equal(complementDoesntModifyInstance.complement().toHex(), "00ffff", "Complement works");
|
||||
equal(complementDoesntModifyInstance.toHex(), "ff0000", "Complement did not modify this color");
|
||||
});
|
||||
|
||||
test("analogous", function() {
|
||||
var combination = tinycolor("red").analogous();
|
||||
equal(colorsToHexString(combination), "ff0000,ff0066,ff0033,ff0000,ff3300,ff6600", "Correct Combination");
|
||||
});
|
||||
|
||||
test("monochromatic", function() {
|
||||
var combination = tinycolor("red").monochromatic();
|
||||
equal(colorsToHexString(combination), "ff0000,2a0000,550000,800000,aa0000,d40000", "Correct Combination");
|
||||
});
|
||||
|
||||
test("splitcomplement", function() {
|
||||
var combination = tinycolor("red").splitcomplement();
|
||||
equal(colorsToHexString(combination), "ff0000,ccff00,0066ff", "Correct Combination");
|
||||
});
|
||||
|
||||
test("triad", function() {
|
||||
var combination = tinycolor("red").triad();
|
||||
equal(colorsToHexString(combination), "ff0000,00ff00,0000ff", "Correct Combination");
|
||||
});
|
||||
|
||||
test("tetrad", function() {
|
||||
var combination = tinycolor("red").tetrad();
|
||||
equal(colorsToHexString(combination), "ff0000,80ff00,00ffff,7f00ff", "Correct Combination");
|
||||
});
|
||||
1195
build/node_modules/tinycolor2/tinycolor.js
generated
vendored
Normal file
1195
build/node_modules/tinycolor2/tinycolor.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user