Comparing version 0.0.7 to 0.0.8
@@ -51,3 +51,3 @@ var gulp = require('gulp'); | ||
gulp.task('default', ['jshint', 'jscs']); | ||
gulp.task('default', ['jshint']); | ||
gulp.task('compile', ['jshint', 'jscs', 'docs', 'provide-color-src']); |
@@ -367,4 +367,4 @@ "use strict"; | ||
function translateColor(ycc, luma) { | ||
var endpoint = luma > ycc.luma ? WHITE_YCC : BLACK_YCC; | ||
var cubeFaces = endpoint == WHITE_YCC ? YCC_CUBE_FACES_WHITE : YCC_CUBE_FACES_BLACK; | ||
var lighter = luma > ycc.luma; | ||
var endpoint = lighter ? WHITE_YCC : BLACK_YCC; | ||
@@ -378,28 +378,51 @@ var a = new YCbCr([0, ycc.Cb, ycc.Cr]); | ||
for (var i = 0; i < cubeFaces.length; i++) { | ||
var cubeFace = cubeFaces[i]; | ||
intersection = findIntersection(line, cubeFace); | ||
var cubeFaces = lighter ? YCC_CUBE_FACES_WHITE : YCC_CUBE_FACES_BLACK; | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
if (intersection.z >= 0 && intersection.z <= 1) { | ||
break; | ||
try { | ||
for (var _iterator = cubeFaces[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var cubeFace = _step.value; | ||
var candidateIntersection = findIntersection(line, cubeFace); | ||
if (candidateIntersection.z < 0 || candidateIntersection.z > 1) continue; | ||
if (!intersection) { | ||
intersection = candidateIntersection; | ||
continue; | ||
} | ||
// May intersect more than one plane, since planes continue beyond edges of cube. | ||
// Find the closest intersection to original luma, as this will be the cube edge. | ||
if (Math.abs(candidateIntersection.z - ycc.luma) < Math.abs(intersection.luma - ycc.luma)) intersection = candidateIntersection; | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator["return"]) { | ||
_iterator["return"](); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
} | ||
if (!intersection) { | ||
throw "Couldn't find intersection with YCbCr color cube for Cb=" + ycc.Cb + ", Cr=" + ycc.Cr + "."; | ||
} | ||
if (!intersection) throw "Couldn't find intersection with YCbCr color cube for Cb=" + ycc.Cb + ", Cr=" + ycc.Cr + "."; | ||
if (intersection.x != ycc.x || intersection.y != ycc.y) { | ||
throw "Intersection has wrong Cb/Cr values."; | ||
} | ||
if (intersection.x != ycc.x || intersection.y != ycc.y) throw "Intersection has wrong Cb/Cr values."; | ||
if (Math.abs(endpoint.luma - intersection.luma) < Math.abs(endpoint.luma - luma)) { | ||
var _translatedColor = [luma, ycc.Cb, ycc.Cr]; | ||
// If luma is closer to endpoint than intersection.luma is, point is outside cube. | ||
if (Math.abs(endpoint.luma - intersection.luma) > Math.abs(endpoint.luma - luma)) { | ||
var dLuma = luma - intersection.luma; | ||
var scale = dLuma / (endpoint.luma - intersection.luma); | ||
var _translatedColor = [luma, intersection.Cb - intersection.Cb * scale, intersection.Cr - intersection.Cr * scale]; | ||
return fromYCbCrArray(_translatedColor); | ||
} | ||
var dLuma = luma - intersection.luma; | ||
var scale = dLuma / (endpoint.luma - intersection.luma); | ||
var translatedColor = [luma, intersection.Cb - intersection.Cb * scale, intersection.Cr - intersection.Cr * scale]; | ||
var translatedColor = [luma, ycc.Cb, ycc.Cr]; | ||
return fromYCbCrArray(translatedColor); | ||
@@ -406,0 +429,0 @@ } |
{ | ||
"name": "a11y-color", | ||
"description": "Color evaluation and manipulation tools", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"author": "Jesse Beach <jesse.r.beach@gmail.com>", | ||
@@ -9,5 +9,5 @@ "license": "Apache License 2.0", | ||
"type": "git", | ||
"url": "git://github.com/A11yance/a11y-color.git" | ||
"url": "git://github.com/jessebeach/a11y-color.git" | ||
}, | ||
"bugs": "http://github.com/A11yance/a11y-color/issues", | ||
"bugs": "http://github.com/jessebeach/a11y-color/issues", | ||
"dependencies": { | ||
@@ -21,3 +21,3 @@ "core-js": "^0.9.13" | ||
"chai": "^3.2.0", | ||
"gulp": "^3.9.0", | ||
"gulp": "^3.9.1", | ||
"gulp-jscs": "^2.0.0", | ||
@@ -24,0 +24,0 @@ "gulp-jsdoc": "^0.1.4", |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
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
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
100963
1024
1