Socket
Socket
Sign inDemoInstall

tinycolor2

Package Overview
Dependencies
0
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.2 to 1.2.1

bower.json

2

Gruntfile.js

@@ -57,4 +57,4 @@

grunt.registerTask('default', ['jshint', 'qunit']);
grunt.registerTask('build', ['jshint', 'qunit', 'uglify', 'docco']);
grunt.registerTask('version-bump', ['jshint', 'qunit', 'uglify', 'docco']);
};
{
"version": "1.1.2",
"version": "1.2.1",
"name": "tinycolor2",
"description": "Fast Color Parsing and Manipulation",
"url": "http://bgrins.github.com/TinyColor",
"license": "MIT",
"repository": {

@@ -24,5 +25,5 @@ "type": "git",

"grunt": "~0.4.1",
"grunt-contrib-concat": "~0.1.3",
"grunt-contrib-jshint": "~0.1.1",
"grunt-contrib-qunit": "~0.2.2",
"grunt-contrib-concat": "~0.1.3",
"grunt-contrib-qunit": "^0.7.0",
"grunt-contrib-uglify": "~0.2.0",

@@ -29,0 +30,0 @@ "grunt-docco": "~0.2.0"

@@ -30,3 +30,3 @@ # TinyColor

var tinycolor = require("./tinycolor");
var tinycolor = require("tinycolor2");
var color = tinycolor("red");

@@ -112,3 +112,3 @@

color = tinycolor({r:255, g:255, b:255});
color.getFormat; // "rgb"
color.getFormat(); // "rgb"
```

@@ -123,3 +123,3 @@

color = tinycolor({r:255, g:255, b:255});
color.getOriginalInput; // "{r: 255, g: 255, b: 255}"
color.getOriginalInput(); // "{r: 255, g: 255, b: 255}"
```

@@ -456,1 +456,15 @@

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.
var color1 = tinycolor("#F00");
var color2 = color1.clone();
color2.setAlpha(.5);
color1.toString(); // "#ff0000"
color2.toString(); // "rgba(255, 0, 0, 0.5)"

@@ -29,2 +29,15 @@

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

@@ -175,2 +188,18 @@ var conversions = [

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());
});

@@ -177,0 +206,0 @@

@@ -1,2 +0,2 @@

// TinyColor v1.1.2
// TinyColor v1.2.1
// https://github.com/bgrins/TinyColor

@@ -7,3 +7,3 @@ // Brian Grinstead, MIT License

var trimLeft = /^[\s,#]+/,
var trimLeft = /^\s+/,
trimRight = /\s+$/,

@@ -211,2 +211,5 @@ tinyCounter = 0,

},
clone: function() {
return tinycolor(this.toString());
},

@@ -508,18 +511,19 @@ _applyModification: function(fn, args) {

}
// `rgbaToHex`
// Converts an RGBA color plus alpha transparency to hex
// Assumes r, g, b and a are contained in the set [0, 255]
// Returns an 8 character hex
function rgbaToHex(r, g, b, a) {
var hex = [
pad2(convertDecimalToHex(a)),
pad2(mathRound(r).toString(16)),
pad2(mathRound(g).toString(16)),
pad2(mathRound(b).toString(16))
];
// `rgbaToHex`
// Converts an RGBA color plus alpha transparency to hex
// Assumes r, g, b and a are contained in the set [0, 255]
// Returns an 8 character hex
function rgbaToHex(r, g, b, a) {
return hex.join("");
}
var hex = [
pad2(convertDecimalToHex(a)),
pad2(mathRound(r).toString(16)),
pad2(mathRound(g).toString(16)),
pad2(mathRound(b).toString(16))
];
return hex.join("");
}
// `equals`

@@ -531,2 +535,3 @@ // Can be called with any tinycolor input

};
tinycolor.random = function() {

@@ -730,3 +735,2 @@ return tinycolor.fromRatio({

// tinycolor.isReadable("#000", "#111",{level:"AA",size:"large"}) => false
tinycolor.isReadable = function(color1, color2, wcag2) {

@@ -764,4 +768,2 @@ var readability = tinycolor.readability(color1, color2);

// tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"small"}).toHexString(); // "#ffffff"
tinycolor.mostReadable = function(baseColor, colorList, args) {

@@ -1068,5 +1070,5 @@ var bestColor = null;

hsva: new RegExp("hsva" + PERMISSIVE_MATCH4),
hex3: /^([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
hex6: /^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
hex8: /^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
};

@@ -1157,2 +1159,3 @@ })();

}
// Node: Export function

@@ -1159,0 +1162,0 @@ if (typeof module !== "undefined" && module.exports) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc