@adobe/leonardo-contrast-colors
Advanced tools
Comparing version 1.0.0-alpha.2 to 1.0.0-alpha.3
@@ -6,2 +6,13 @@ # Change Log | ||
# [1.0.0-alpha.3](https://github.com/adobe/leonardo/compare/@adobe/leonardo-contrast-colors@1.0.0-alpha.2...@adobe/leonardo-contrast-colors@1.0.0-alpha.3) (2020-01-21) | ||
### Bug Fixes | ||
* corrected midtone color outputs ([#46](https://github.com/adobe/leonardo/issues/46)) ([5c780b7](https://github.com/adobe/leonardo/commit/5c780b7a1f0355f985591076a27f1764e1faee3c)) | ||
# [1.0.0-alpha.2](https://github.com/adobe/leonardo/compare/@adobe/leonardo-contrast-colors@1.0.0-alpha.1...@adobe/leonardo-contrast-colors@1.0.0-alpha.2) (2019-12-12) | ||
@@ -8,0 +19,0 @@ |
@@ -209,10 +209,10 @@ "use strict"; | ||
}); | ||
let baseV = d3.hsluv(base).v / 100; | ||
let Contrasts = d3.range(swatches).map(d => { | ||
let rgbArray = [d3.rgb(scaleData.scale(d)).r, d3.rgb(scaleData.scale(d)).g, d3.rgb(scaleData.scale(d)).b]; | ||
let baseRgbArray = [d3.rgb(base).r, d3.rgb(base).g, d3.rgb(base).b]; | ||
let ca = contrast(rgbArray, baseRgbArray).toFixed(2); | ||
let ca = contrast(rgbArray, baseRgbArray, baseV).toFixed(2); | ||
return Number(ca); | ||
}); | ||
let contrasts = Contrasts.filter(el => el != null); | ||
let baseLum = luminance(d3.rgb(base).r, d3.rgb(base).g, d3.rgb(base).b); | ||
let newColors = []; | ||
@@ -222,3 +222,3 @@ ratios = ratios.map(Number); // Return color matching target ratio, or closest number | ||
for (let i = 0; i < ratios.length; i++) { | ||
let r = binarySearch(contrasts, ratios[i], baseLum); | ||
let r = binarySearch(contrasts, ratios[i], baseV); | ||
newColors.push(d3.rgb(scaleData.colors[r]).hex()); | ||
@@ -239,6 +239,5 @@ } | ||
// } | ||
// Separate files in a lib folder as well. | ||
function contrast(color, base) { | ||
function contrast(color, base, baseV) { | ||
let colorLum = luminance(color[0], color[1], color[2]); | ||
@@ -249,3 +248,3 @@ let baseLum = luminance(base[0], base[1], base[2]); | ||
if (baseLum < 0.5) { | ||
if (baseV < 0.5) { | ||
if (cr1 >= 1) { | ||
@@ -252,0 +251,0 @@ return cr1; |
12
index.js
@@ -217,2 +217,3 @@ /* | ||
let scaleData = createScale({swatches: swatches, colorKeys: colorKeys, colorspace: colorspace, shift: 1}); | ||
let baseV = (d3.hsluv(base).v) / 100; | ||
@@ -222,3 +223,3 @@ let Contrasts = d3.range(swatches).map((d) => { | ||
let baseRgbArray = [d3.rgb(base).r, d3.rgb(base).g, d3.rgb(base).b]; | ||
let ca = contrast(rgbArray, baseRgbArray).toFixed(2); | ||
let ca = contrast(rgbArray, baseRgbArray, baseV).toFixed(2); | ||
@@ -230,4 +231,2 @@ return Number(ca); | ||
let baseLum = luminance(d3.rgb(base).r, d3.rgb(base).g, d3.rgb(base).b); | ||
let newColors = []; | ||
@@ -238,3 +237,3 @@ ratios = ratios.map(Number); | ||
for (let i=0; i < ratios.length; i++){ | ||
let r = binarySearch(contrasts, ratios[i], baseLum); | ||
let r = binarySearch(contrasts, ratios[i], baseV); | ||
newColors.push(d3.rgb(scaleData.colors[r]).hex()); | ||
@@ -260,4 +259,3 @@ } | ||
// Separate files in a lib folder as well. | ||
function contrast(color, base) { | ||
function contrast(color, base, baseV) { | ||
let colorLum = luminance(color[0], color[1], color[2]); | ||
@@ -269,3 +267,3 @@ let baseLum = luminance(base[0], base[1], base[2]); | ||
if (baseLum < 0.5) { | ||
if (baseV < 0.5) { | ||
if (cr1 >= 1) { | ||
@@ -272,0 +270,0 @@ return cr1; |
{ | ||
"name": "@adobe/leonardo-contrast-colors", | ||
"version": "1.0.0-alpha.2", | ||
"version": "1.0.0-alpha.3", | ||
"description": "Generate colors based on a desired contrast ratio", | ||
@@ -51,3 +51,3 @@ "repository": "git@github.com:adobe/leonardo.git", | ||
}, | ||
"gitHead": "18c60dea214686246c2677403ac329a02cfb3c0f" | ||
"gitHead": "d0da2ee31094e16d7714ad59783f505d9ec52171" | ||
} |
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
36572
536
1