@delirius/welcard
Version:
WelCard is a lightweight and futuristic welcome card library designed for WhatsApp Bots.
31 lines (30 loc) • 1.64 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.adjustBrightness = void 0;
/**
* Adjusts the brightness of an RGB color by a specified amount.
*
* @param r - The red component of the color (0-255).
* @param g - The green component of the color (0-255).
* @param b - The blue component of the color (0-255).
* @param adjustment - The amount to adjust the brightness by (can be positive or negative).
* @returns An array containing the adjusted RGB values.
*/
function adjustBrightness(r, g, b, adjustment) {
return __awaiter(this, void 0, void 0, function* () {
const adjustedR = Math.max(0, Math.min(255, r + adjustment));
const adjustedG = Math.max(0, Math.min(255, g + adjustment));
const adjustedB = Math.max(0, Math.min(255, b + adjustment));
return [adjustedR, adjustedG, adjustedB];
});
}
exports.adjustBrightness = adjustBrightness;