UNPKG

color-theme-generator

Version:

Generates random color themes that are based in color theory.

35 lines (34 loc) 2.24 kB
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); }; var _ColorThemeFactory_instances, _ColorThemeFactory_setSaturation, _ColorThemeFactory_setMinLightness, _ColorThemeFactory_setMaxLightness; import { ColorValues } from '../enums/ColorValues.js'; import { MaxMinObject } from './MaxMinObject.js'; import { NumberGenerator } from './NumberGenerator.js'; import { Validator } from './Validator.js'; export class ColorThemeFactory { constructor() { _ColorThemeFactory_instances.add(this); this.validator = new Validator(); this.generator = new NumberGenerator(); this.setHue(new MaxMinObject(ColorValues.HueMax, ColorValues.HueMin)); __classPrivateFieldGet(this, _ColorThemeFactory_instances, "m", _ColorThemeFactory_setSaturation).call(this, new MaxMinObject(ColorValues.SaturationMax, ColorValues.SaturationMin)); __classPrivateFieldGet(this, _ColorThemeFactory_instances, "m", _ColorThemeFactory_setMinLightness).call(this, ColorValues.MinLightness); __classPrivateFieldGet(this, _ColorThemeFactory_instances, "m", _ColorThemeFactory_setMaxLightness).call(this, ColorValues.MaxLightness); } /** * Sets the hue with a randomly generated number that is between the arguments. */ setHue(limits) { this.hue = this.generator.generateRandomNumber(limits); } } _ColorThemeFactory_instances = new WeakSet(), _ColorThemeFactory_setSaturation = function _ColorThemeFactory_setSaturation(limits) { this.saturation = this.generator.generateRandomNumber(limits); }, _ColorThemeFactory_setMinLightness = function _ColorThemeFactory_setMinLightness(value) { this.minLightness = value; }, _ColorThemeFactory_setMaxLightness = function _ColorThemeFactory_setMaxLightness(value) { this.maxLightness = value; };