text = ({
center: [400, 100],
text: '123',
family: 'monospace',
size: 120,
style: '',
weight: '',
align: 'center',
baseline: 'center',
lineWidth: 1,
lineJoin: 'butt',
fill: 'black',
stroke: null,
opacity: 1,
draw(ctx) {
ctx.textAlign = this.align;
ctx.textBaseline = this.baseline;
ctx.font = `${this.style} ${this.weight} ${this.size}px ${this.family}`;
if (this.stroke) {
ctx.strokeStyle = this.stroke;
ctx.lineWidth = this.lineWidth;
ctx.lineJoin = this.lineJoin;
ctx.strokeText(this.text, ...this.center);
}
if (this.fill) {
ctx.fillStyle = this.fill;
ctx.fillText(this.text, ...this.center);
}
}
})