@discord-card/core
Version:
Discord Card core
28 lines • 868 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RadialGradient = void 0;
const _1 = require(".");
class RadialGradient extends _1.Gradient {
constructor(...colors) {
super('radial', ...colors);
}
toString(ctx, xPos, yPos, width, height) {
let x0 = xPos, y0 = yPos, r0, x1 = xPos + width, y1 = yPos + height, r1;
if (width > height) {
r0 = r1 = height / 2;
}
else {
r0 = r1 = width / 2;
}
x0 += r0;
y0 += r0;
x1 -= r0;
y1 -= r0;
let grad = ctx.createRadialGradient(x0, y0, r0, x1, y1, r1);
for (const v of this.colors)
grad.addColorStop(v.offset, v.color);
return grad;
}
}
exports.RadialGradient = RadialGradient;
//# sourceMappingURL=Radial.js.map