Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

color

Package Overview
Dependencies
Maintainers
2
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

color - npm Package Compare versions

Comparing version 0.8.0 to 0.9.0

5

CHANGELOG.md

@@ -0,1 +1,6 @@

# 0.9.0 - 2015-06-21
- Fixed: `mix()` implementation is now the same as in Sass
([#60](https://github.com/harthur/color/pull/60))
# 0.8.0 - 2015-03-03

@@ -2,0 +7,0 @@

40

index.js

@@ -294,25 +294,25 @@ /* MIT license */

mix: function(color2, weight) {
weight = 1 - (weight == null ? 0.5 : weight);
/**
* Ported from sass implementation in C
* https://github.com/sass/libsass/blob/0e6b4a2850092356aa3ece07c6b249f0221caced/functions.cpp#L209
*/
mix: function(mixinColor, weight) {
var color1 = this;
var color2 = mixinColor;
var weight = weight || 50;
// algorithm from Sass's mix(). Ratio of first color in mix is
// determined by the alphas of both colors and the weight
var t1 = weight * 2 - 1,
d = this.alpha() - color2.alpha();
var p = weight / 100;
var w = 2 * p - 1;
var a = color1.alpha() - color2.alpha();
var weight1 = (((t1 * d == -1) ? t1 : (t1 + d) / (1 + t1 * d)) + 1) / 2;
var weight2 = 1 - weight1;
var w1 = (((w * a == -1) ? w : (w + a)/(1 + w*a)) + 1) / 2.0;
var w2 = 1 - w1;
var rgb = this.rgbArray();
var rgb2 = color2.rgbArray();
for (var i = 0; i < rgb.length; i++) {
rgb[i] = rgb[i] * weight1 + rgb2[i] * weight2;
}
this.setValues("rgb", rgb);
var alpha = this.alpha() * weight + color2.alpha() * (1 - weight);
this.setValues("alpha", alpha);
return this;
return this
.rgb(
w1 * color1.red() + w2 * color2.red(),
w1 * color1.green() + w2 * color2.green(),
w1 * color1.blue() + w2 * color2.blue()
)
.alpha(color1.alpha() * p + color2.alpha() * (1 - p));
},

@@ -319,0 +319,0 @@

{
"name": "color",
"version": "0.8.0",
"version": "0.9.0",
"description": "Color conversion and manipulation with CSS string support",

@@ -25,8 +25,11 @@ "keywords": [

"scripts": {
"test": "node test"
"test": "mocha"
},
"dependencies": {
"color-convert": "^0.5.0",
"color-convert": "^0.5.3",
"color-string": "^0.3.0"
},
"devDependencies": {
"mocha": "^2.2.5"
}
}
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc