Comparing version 0.16.1 to 0.16.2
## Changelog | ||
## 0.16.2 | ||
* Fixed a regression related to color math ([#443](https://github.com/mapbox/carto/issues/443)) | ||
## 0.16.1 | ||
@@ -4,0 +8,0 @@ |
var chroma = require('chroma-js'), | ||
husl = require('husl'); | ||
husl = require('husl'), | ||
_ = require('lodash'); | ||
@@ -95,3 +96,3 @@ (function(tree) { | ||
// Operations have to be done per-channel, if not, | ||
// Operations have to be done in RGB per-channel, if not, | ||
// channels will spill onto each other. Once we have | ||
@@ -107,5 +108,25 @@ // our result, in the form of an integer triplet, | ||
var normalize = function (x) { | ||
return x / 255; | ||
}; | ||
var denormalize = function (x) { | ||
return x * 255; | ||
}; | ||
var rgb1 = _.map(chroma(this.toString()).rgb(), normalize); | ||
var rgb2 = _.map(chroma(other.toString()).rgb(), normalize); | ||
for (var c = 0; c < 3; c++) { | ||
result[c] = tree.operate(op, this.hsl[c], other.hsl[c]); | ||
result[c] = tree.operate(op, rgb1[c] , rgb2[c]); | ||
} | ||
if (this.perceptual) { | ||
result = husl.fromRGB.apply(this, result); | ||
result[1] = result[1] / 100; | ||
result[2] = result[2] / 100; | ||
} | ||
else { | ||
result = chroma(_.map(result, denormalize)).hsl(); | ||
} | ||
return new tree.Color(result, this.alpha, this.perceptual); | ||
@@ -112,0 +133,0 @@ }, |
{ | ||
"name": "carto", | ||
"version": "0.16.1", | ||
"version": "0.16.2", | ||
"description": "Mapnik Stylesheet Compiler", | ||
@@ -5,0 +5,0 @@ "url": "https://github.com/mapbox/carto", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
985009
3606