hap-nodejs
Version:
HAP-NodeJS is a Node.js implementation of HomeKit Accessory Server.
442 lines • 11.6 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ColorUtils = void 0;
const tslib_1 = require("tslib");
const assert_1 = tslib_1.__importDefault(require("assert"));
const lookupTable = new Map([
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],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]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
[ ]],
]);
/**
* @group Utils
*/
class ColorUtils {
/**
* Returns the Hue and Saturation representation of the given color temperature in mired.
*
* @param colorTemperature - The color temperature in mired.
* @param roundResults - The lookup table has a precision of .1 decimal places. The given characteristics only have a step value of 1.
* Thus, the method will round the results by default to an integer value. This can be turned off using this option.
* @returns An number array of length 2 with the first element being the saturation and the second argument being the hue.
*/
static colorTemperatureToHueAndSaturation(colorTemperature, roundResults = true) {
if (colorTemperature > 500) {
colorTemperature = 500;
}
else if (colorTemperature < 100) {
colorTemperature = 100;
}
colorTemperature = Math.round(colorTemperature); // ensure integer
const hueAndTemperature = lookupTable.get(colorTemperature);
(0, assert_1.default)(colorTemperature != null, "lookup for temperature " + colorTemperature + " did not yield any results");
if (roundResults) {
hueAndTemperature[0] = Math.round(hueAndTemperature[0]);
hueAndTemperature[1] = Math.round(hueAndTemperature[1]);
}
return {
saturation: hueAndTemperature[0],
hue: hueAndTemperature[1],
};
}
}
exports.ColorUtils = ColorUtils;
//# sourceMappingURL=color-utils.js.map