UNPKG

arx-level-generator

Version:
81 lines 2.46 kB
var GlowFlags; (function (GlowFlags) { GlowFlags[GlowFlags["Inactive"] = 0] = "Inactive"; GlowFlags[GlowFlags["Active"] = 1] = "Active"; GlowFlags[GlowFlags["Color"] = 2] = "Color"; GlowFlags[GlowFlags["Size"] = 4] = "Size"; GlowFlags[GlowFlags["Negative"] = 8] = "Negative"; })(GlowFlags || (GlowFlags = {})); /** * glow color is like: 1 or 0 for R G and B channels * 1 is enabled with full intensity, 0 is disabled * in-between values only reduce the radius proportionally * colors are blended with additive color mixing: * 1 1 1 = white * 1 1 0 = yellow * 1 0.5 0 = red with a smaller aura of yellow, not orange * 0 0 0 = transparent * * -n is for inverting channels and making the mixing substractive * resulting in C M Y channels * 1 1 1 = black * * there is a total of 7 light colors and 7 dark colors + intensity */ export class Glow { color; size; isNegative; constructor({ color, size, isNegative = false }) { this.color = color; this.size = size; this.isNegative = isNegative; } on() { const params = { color: '', radius: '' }; let flags = GlowFlags.Active; if (typeof this.color !== 'undefined') { flags |= GlowFlags.Color; params.color = this.color.toScriptColor(); } if (typeof this.size !== 'undefined') { flags |= GlowFlags.Size; params.radius = this.size.toString(); } if (this.isNegative) { flags |= GlowFlags.Negative; } return `halo ${this.stringifyFlags(flags)} ${params.color} ${params.radius}`.trim(); } off() { const flags = GlowFlags.Inactive; return `halo ${this.stringifyFlags(flags)}`; } /** * [o] = active * [f] = inactive * [c] = specify color (default halo color is #3370FF) * [s] = specify size (default size is 45) * [n] = negative */ stringifyFlags(flags) { let letters = ''; if (flags & GlowFlags.Active) { letters += 'o'; } else { letters += 'f'; } if (flags & GlowFlags.Color) { letters += 'c'; } if (flags & GlowFlags.Size) { letters += 's'; } if (flags & GlowFlags.Negative) { letters += 'n'; } return (letters === '' ? '' : '-') + letters; } } //# sourceMappingURL=Glow.js.map