Comparing version
export declare function fromRadian(r: number): number; | ||
export declare function toRadian(d: number): number; | ||
declare const _default: { | ||
fromRadian: typeof fromRadian; | ||
toRadian: typeof toRadian; | ||
}; | ||
export default _default; |
@@ -26,2 +26,3 @@ "use strict"; | ||
exports.toRadian = toRadian; | ||
exports["default"] = { fromRadian: fromRadian, toRadian: toRadian }; | ||
//# sourceMappingURL=degree.js.map |
@@ -37,2 +37,1 @@ import { IXYCoordinate, TIlluminant } from "./types"; | ||
}; | ||
export default illuminants; |
@@ -31,3 +31,2 @@ "use strict"; | ||
}; | ||
exports["default"] = exports.illuminants; | ||
//# sourceMappingURL=illuminant.js.map |
@@ -1,7 +0,7 @@ | ||
import * as degree from "./degree"; | ||
import * as illuminant from "./illuminant"; | ||
import * as matrix from "./matrix"; | ||
import * as rgb from "./rgb"; | ||
import * as workspace from "./workspace"; | ||
import * as xyz from "./xyz"; | ||
export { degree, illuminant, matrix, rgb, workspace, xyz, }; | ||
export { default as degree } from "./degree"; | ||
export * from "./illuminant"; | ||
export { default as matrix } from "./matrix"; | ||
export { default as rgb } from "./rgb"; | ||
export * from "./types"; | ||
export * from "./workspace"; | ||
export * from "./xyz"; |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
exports.__esModule = true; | ||
var degree = require("./degree"); | ||
exports.degree = degree; | ||
var illuminant = require("./illuminant"); | ||
exports.illuminant = illuminant; | ||
var matrix = require("./matrix"); | ||
exports.matrix = matrix; | ||
var rgb = require("./rgb"); | ||
exports.rgb = rgb; | ||
var workspace = require("./workspace"); | ||
exports.workspace = workspace; | ||
var xyz = require("./xyz"); | ||
exports.xyz = xyz; | ||
var degree_1 = require("./degree"); | ||
exports.degree = degree_1["default"]; | ||
__export(require("./illuminant")); | ||
var matrix_1 = require("./matrix"); | ||
exports.matrix = matrix_1["default"]; | ||
var rgb_1 = require("./rgb"); | ||
exports.rgb = rgb_1["default"]; | ||
__export(require("./workspace")); | ||
__export(require("./xyz")); | ||
//# sourceMappingURL=index.js.map |
import { Matrix3D, Vector3D } from "./types"; | ||
export declare function transpose(M: Matrix3D): number[][]; | ||
export declare function determinant(M: Matrix3D): number; | ||
export declare function inverse(M: Matrix3D): number[][]; | ||
export declare function multiply(M: Matrix3D, v: Vector3D): number[]; | ||
export declare function scalar(M: Matrix3D, v: Vector3D): number[][]; | ||
export declare function product(M: Matrix3D, N: Matrix3D): number[][]; | ||
declare function transpose(M: Matrix3D): number[][]; | ||
declare function determinant(M: Matrix3D): number; | ||
declare function inverse(M: Matrix3D): number[][]; | ||
declare function multiply(M: Matrix3D, v: Vector3D): number[]; | ||
declare function scalar(M: Matrix3D, v: Vector3D): number[][]; | ||
declare function product(M: Matrix3D, N: Matrix3D): number[][]; | ||
declare const _default: { | ||
determinant: typeof determinant; | ||
inverse: typeof inverse; | ||
multiply: typeof multiply; | ||
product: typeof product; | ||
scalar: typeof scalar; | ||
transpose: typeof transpose; | ||
}; | ||
export default _default; |
@@ -10,3 +10,2 @@ "use strict"; | ||
} | ||
exports.transpose = transpose; | ||
function determinant(M) { | ||
@@ -17,3 +16,2 @@ return (M[0][0] * (M[2][2] * M[1][1] - M[2][1] * M[1][2]) + | ||
} | ||
exports.determinant = determinant; | ||
function inverse(M) { | ||
@@ -25,3 +23,2 @@ var c = 1 / determinant(M); | ||
} | ||
exports.inverse = inverse; | ||
function multiply(M, v) { | ||
@@ -32,3 +29,2 @@ return ([M[0][0] * v[0] + M[0][1] * v[1] + M[0][2] * v[2], | ||
} | ||
exports.multiply = multiply; | ||
function scalar(M, v) { | ||
@@ -39,3 +35,2 @@ return ([[M[0][0] * v[0], M[0][1] * v[1], M[0][2] * v[2]], | ||
} | ||
exports.scalar = scalar; | ||
function product(M, N) { | ||
@@ -46,3 +41,10 @@ return ([[M[0][0] * N[0][0] + M[0][1] * N[1][0] + M[0][2] * N[2][0], M[0][0] * N[0][1] + M[0][1] * N[1][1] + M[0][2] * N[2][1], M[0][0] * N[0][2] + M[0][1] * N[1][2] + M[0][2] * N[2][2]], | ||
} | ||
exports.product = product; | ||
exports["default"] = { | ||
determinant: determinant, | ||
inverse: inverse, | ||
multiply: multiply, | ||
product: product, | ||
scalar: scalar, | ||
transpose: transpose | ||
}; | ||
//# sourceMappingURL=matrix.js.map |
export declare function fromHex(hex: string): number[]; | ||
export declare function toHex(RGB: [number, number, number]): string; | ||
declare const _default: { | ||
fromHex: typeof fromHex; | ||
toHex: typeof toHex; | ||
}; | ||
export default _default; |
@@ -22,2 +22,3 @@ "use strict"; | ||
exports.toHex = toHex; | ||
exports["default"] = { fromHex: fromHex, toHex: toHex }; | ||
//# sourceMappingURL=rgb.js.map |
import { IColorSpaceEncoder, IWorkspace } from "./types"; | ||
export declare const sign: (n: number) => number; | ||
export declare const sRgbGamma: IColorSpaceEncoder; | ||
@@ -11,2 +12,1 @@ export declare const proPhotoGamma: IColorSpaceEncoder; | ||
}; | ||
export default workspaces; |
"use strict"; | ||
exports.__esModule = true; | ||
var abs = Math.abs, pow = Math.pow; | ||
var sign = function (n) { return isNaN(n) ? NaN : n > 0 ? 1 : n < 0 ? -1 : 0; }; | ||
exports.sign = function (n) { return isNaN(n) ? NaN : n > 0 ? 1 : n < 0 ? -1 : 0; }; | ||
exports.sRgbGamma = { | ||
@@ -14,4 +14,4 @@ decode: function (v) { return (v <= 0.04045 ? v / 12.92 : pow((v + 0.055) / 1.055, 2.4)); }, | ||
exports.simpleGamma = function (g) { return ({ | ||
decode: function (v) { return sign(v) * pow(abs(v), g); }, | ||
encode: function (v) { return sign(v) * pow(abs(v), 1 / g); } | ||
decode: function (v) { return exports.sign(v) * pow(abs(v), g); }, | ||
encode: function (v) { return exports.sign(v) * pow(abs(v), 1 / g); } | ||
}); }; | ||
@@ -45,3 +45,2 @@ // tslint:disable:object-literal-sort-keys | ||
}; | ||
exports["default"] = exports.workspaces; | ||
//# sourceMappingURL=workspace.js.map |
@@ -6,2 +6,1 @@ import { IWorkspace, TIlluminant } from "./types"; | ||
}; | ||
export default Converter; |
"use strict"; | ||
exports.__esModule = true; | ||
var illuminant_1 = require("./illuminant"); | ||
var matrix = require("./matrix"); | ||
var matrix_1 = require("./matrix"); | ||
var workspace_1 = require("./workspace"); | ||
// http://www.brucelindbloom.com/Eqn_RGB_XYZ_Matrix.html | ||
function Converter(rgbSpace, whitePoint) { | ||
if (rgbSpace === void 0) { rgbSpace = workspace_1["default"].sRGB; } | ||
if (whitePoint === void 0) { whitePoint = illuminant_1["default"].D65; } | ||
if (rgbSpace === void 0) { rgbSpace = workspace_1.workspaces.sRGB; } | ||
if (whitePoint === void 0) { whitePoint = illuminant_1.illuminants.D65; } | ||
var primaries = [rgbSpace.r, rgbSpace.g, rgbSpace.b]; | ||
var M_P = matrix.transpose(primaries.map(function (_a) { | ||
var M_P = matrix_1["default"].transpose(primaries.map(function (_a) { | ||
var x = _a.x, y = _a.y; | ||
@@ -23,11 +23,11 @@ return [ | ||
var gamma = rgbSpace.gamma; | ||
var M_S = matrix.multiply(matrix.inverse(M_P), whitePoint); | ||
var M_RGB_XYZ = matrix.scalar(M_P, M_S); | ||
var M_XYZ_RGB = matrix.inverse(M_RGB_XYZ); | ||
var M_S = matrix_1["default"].multiply(matrix_1["default"].inverse(M_P), whitePoint); | ||
var M_RGB_XYZ = matrix_1["default"].scalar(M_P, M_S); | ||
var M_XYZ_RGB = matrix_1["default"].inverse(M_RGB_XYZ); | ||
return { | ||
fromRgb: function (RGB) { | ||
return matrix.multiply(M_RGB_XYZ, RGB.map(gamma.decode)); | ||
return matrix_1["default"].multiply(M_RGB_XYZ, RGB.map(gamma.decode)); | ||
}, | ||
toRgb: function (XYZ) { | ||
return matrix.multiply(M_XYZ_RGB, XYZ).map(gamma.encode); | ||
return matrix_1["default"].multiply(M_XYZ_RGB, XYZ).map(gamma.encode); | ||
} | ||
@@ -37,3 +37,2 @@ }; | ||
exports.Converter = Converter; | ||
exports["default"] = Converter; | ||
//# sourceMappingURL=xyz.js.map |
{ | ||
"name": "ciebase-ts", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "TypeScript port of ciebase - Basic building blocks for CIE color spaces", | ||
@@ -5,0 +5,0 @@ "author": "Frédérique Mittelstaedt <npm@gfm.io> (https://www.gfm.io)", |
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
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
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
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
47275
-13.37%44
-15.38%516
-28.33%