|
1 rok pred | |
---|---|---|
.. | ||
LICENSE.md | 1 rok pred | |
README.md | 1 rok pred | |
color.js | 1 rok pred | |
color.min.js | 1 rok pred | |
css.color.js | 1 rok pred | |
css.color.min.js | 1 rok pred |
Version 0.2.1.2
Create and manipulate colors with ease.
Color.get("violet")
Color(0xEE82EE)
Color("#EE82EE")
Color("EE82EE")
Color(0xEE, 0x82, 0xEE)
Color("EE", "82", "EE")
Color(238, 130, 238)
Color.rgb(238, 130, 238)
Color.hsl(0.8333333333333334, 0.7605633802816902, 0.7215686274509804)
// 300°, 75.88652482269505%, 72.35294117647058%
Color("#ABC") // "#AABBCC"
Color("ABC") // "#AABBCC"
var c = new Color('#ABC123', 0.6);
c.getRGBA(); // rgba(171,193,35,0.6)
setValue
and channels
var myColor = new Color;
myColor.setValue(0xAA7F00);
myColor.hexTriplet() === "#aa7f00";
myColor.channels[0] = 0xFF;
myColor.hexTriplet() === "#ff7f00"; // orange
Color.define("rind", [92, 163, 16])
Color.get("rind").hexTriplet() === "#5ca310"
Color.random("green", "blue");
red = Color.parse("rgb(255, 0, 0)");
green = Color.parse("rgb ,128"); // shorthand
blue = Color.parse("hsl(240, 100%, 50%)");
red.hexTriplet() === "#ff0000";
green.hexTriplet() === "#008000";
blue.hexTriplet() === "#0000ff";
color.js can be used in any ECMAScript environment as it does not make use of the DOM. color.js is very useful on the server-side and the client-side.
The color.js CSS module defines all of the standard CSS colors for use in color.js.
Note: HSL values are in the form of fractions (0 to 1). A hue value of 0.5 is equivalent to a hue of 180°.
Color objects can be instantiated in any of the following ways:
color = [new ]Color(color:int | string, [, alpha:float])
color = [new ]Color(red:int | string, green:int | string, blue:int | string [, alpha:float | string])
color = Color.rgb(red:int, green:int, blue:int [, alpha:float])
color = Color.hsl(hue:float, saturation:float, lightness:float [, alpha:float])
channels : array
rgb()
rgba()
hsl()
hsla()
css()
hexTriplet()
.
Otherwise, this returns rgba()
.
getValue()
and valueOf()
setValue(value:int)
value
.
hexTriplet()
rgbData()
hslData()
toString()
this[Color.TO_STRING_METHOD]()
.
Color names are case-insensitive.
Color.define(colorName:string, RGB:array | string)
Color.get(colorName:string)
colorName
.
Color.del(colorName:string)
colorName
.
Color.clearColors()
Color.parse(cssFunction:string)
hsl(0, 100%, 50%)
)
or hex triplet. If no color could be parsed, this returns null.
This function intentionally allows invalid syntax when parsing
css functions. As long as the first three non-whitespace characters
(case-insensitive) are "rgb" or "hsl" and the arguments (which are
all optional and default to zero) are separated by commas, this
function will be able to parse the CSS function.
Color.random([rangeStart:int | string] [, rangeEnd:int | string])
Color.rgb(red:int, green:int, blue:int [, alpha:float])
Color.hsl(hue:float, saturation:float, lightness:float [, alpha:float])
Color.RGBtoHSL(rgb:array)
Color.HSLtoRGB(hsl:array)
Color.TO_STRING_METHOD : string
The method name of which to call when a color instance's
<code>toString()</code> method is called. This defaults to
<code>hexTriplet</code>.