homebridge-plugin-wrapper
Version:
Wrapper for Homebridge and NodeJS-HAP with reduced dependencies that allows to intercept plugin values and also send to them
443 lines • 11.7 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ColorUtils = void 0;
var tslib_1 = require("tslib");
var assert_1 = (0, tslib_1.__importDefault)(require("assert"));
var lookupTable = new Map([
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
[]],
]);
var ColorUtils = /** @class */ (function () {
function 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 of using this option.
* @returns An number array of length 2 with the first element being the saturation and the second argument being the hue.
*/
ColorUtils.colorTemperatureToHueAndSaturation = function (colorTemperature, roundResults) {
if (roundResults === void 0) { roundResults = true; }
if (colorTemperature > 500) {
colorTemperature = 500;
}
else if (colorTemperature < 100) {
colorTemperature = 100;
}
colorTemperature = Math.round(colorTemperature); // ensure integer
var 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],
};
};
return ColorUtils;
}());
exports.ColorUtils = ColorUtils;
//# sourceMappingURL=color-utils.js.map