sc4
Version:
A command line utility for automating SimCity 4 modding tasks & modifying savegames
21 lines (20 loc) • 502 B
JavaScript
// # color.js
export default class Color {
r = 0;
g = 0;
b = 0;
a = 0xff;
constructor(r = 0, g = 0, b = 0, a = 0xff) {
Object.assign(this, { r, g, b, a });
}
[Symbol.toPrimitive]() {
let { r, g, b, a } = this;
return '#' + pad(r) + pad(g) + pad(b) + pad(a);
}
[Symbol.for('nodejs.util.inspect.custom')]() {
return '\x1B[36m' + String(this) + '\x1B[39m';
}
}
function pad(value) {
return value.toString(16).padStart(2, '0');
}