@jimp/plugin-color
Advanced tools
Comparing version
@@ -219,24 +219,7 @@ "use strict"; | ||
var factor = (val + 1) / (1 - val); | ||
function adjust(value) { | ||
var x; | ||
if (val < 0) { | ||
x = value > 127 ? 1 - value / 255 : value / 255; | ||
if (x < 0) { | ||
x = 0; | ||
} | ||
x = 0.5 * Math.pow(x * 2, 1 + val); | ||
return value > 127 ? (1.0 - x) * 255 : x * 255; | ||
} | ||
x = value > 127 ? 1 - value / 255 : value / 255; | ||
if (x < 0) { | ||
x = 0; | ||
} | ||
x = 0.5 * Math.pow(2 * x, val === 1 ? 127 : 1 / (1 - val)); | ||
return value > 127 ? (1 - x) * 255 : x * 255; | ||
value = Math.floor(factor * (value - 127) + 127); | ||
return value < 0 ? 0 : value > 255 ? 255 : value; | ||
} | ||
@@ -243,0 +226,0 @@ |
@@ -187,24 +187,7 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
var factor = (val + 1) / (1 - val); | ||
function adjust(value) { | ||
var x; | ||
if (val < 0) { | ||
x = value > 127 ? 1 - value / 255 : value / 255; | ||
if (x < 0) { | ||
x = 0; | ||
} | ||
x = 0.5 * Math.pow(x * 2, 1 + val); | ||
return value > 127 ? (1.0 - x) * 255 : x * 255; | ||
} | ||
x = value > 127 ? 1 - value / 255 : value / 255; | ||
if (x < 0) { | ||
x = 0; | ||
} | ||
x = 0.5 * Math.pow(2 * x, val === 1 ? 127 : 1 / (1 - val)); | ||
return value > 127 ? (1 - x) * 255 : x * 255; | ||
value = Math.floor(factor * (value - 127) + 127); | ||
return value < 0 ? 0 : value > 255 ? 255 : value; | ||
} | ||
@@ -211,0 +194,0 @@ |
{ | ||
"name": "@jimp/plugin-color", | ||
"version": "0.5.5", | ||
"version": "0.6.0", | ||
"description": "Bitmap manipulation to adjust the color in an image.", | ||
@@ -22,3 +22,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@jimp/utils": "^0.5.0", | ||
"@jimp/utils": "^0.6.0", | ||
"core-js": "^2.5.7", | ||
@@ -28,5 +28,5 @@ "tinycolor2": "^1.4.1" | ||
"devDependencies": { | ||
"@jimp/custom": "^0.5.4", | ||
"@jimp/test-utils": "^0.5.4", | ||
"@jimp/types": "^0.5.4" | ||
"@jimp/custom": "^0.6.0", | ||
"@jimp/test-utils": "^0.6.0", | ||
"@jimp/types": "^0.6.0" | ||
}, | ||
@@ -39,3 +39,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "72634d1c6c614a925bf1bc5e861e3640f5c0bf98" | ||
"gitHead": "ff78c045c32a9fff55f7fd92f72fa57409126485" | ||
} |
@@ -193,26 +193,8 @@ import tinyColor from 'tinycolor2'; | ||
const factor = (val + 1) / (1 - val); | ||
function adjust(value) { | ||
let x; | ||
value = Math.floor(factor * (value - 127) + 127); | ||
if (val < 0) { | ||
x = value > 127 ? 1 - value / 255 : value / 255; | ||
if (x < 0) { | ||
x = 0; | ||
} | ||
x = 0.5 * Math.pow(x * 2, 1 + val); | ||
return value > 127 ? (1.0 - x) * 255 : x * 255; | ||
} | ||
x = value > 127 ? 1 - value / 255 : value / 255; | ||
if (x < 0) { | ||
x = 0; | ||
} | ||
x = 0.5 * Math.pow(2 * x, val === 1 ? 127 : 1 / (1 - val)); | ||
return value > 127 ? (1 - x) * 255 : x * 255; | ||
return value < 0 ? 0 : value > 255 ? 255 : value; | ||
} | ||
@@ -219,0 +201,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
407561
-0.65%1681
-2.1%+ Added
- Removed
Updated