Move text out of state circle when too long

This commit is contained in:
Marcel 2019-03-07 16:12:24 +01:00
parent 6f16c5c9b7
commit 186c28c8e7

View File

@ -58,7 +58,11 @@ class State {
} }
ctx.fillStyle = settings.colors.getColor(this); ctx.fillStyle = settings.colors.getColor(this);
ctx.drawText(this.text, this.x, this.y, null, selectedObject === this); const width = ctx.measureText(this.text).width;
if(width < radius * .9)
ctx.drawText(this.text, this.x, this.y, null, selectedObject === this);
else
ctx.drawText(this.text, this.x, this.y + radius * 1.75, null, selectedObject === this);
if(this.isAcceptState) { if(this.isAcceptState) {
ctx.beginPath(); ctx.beginPath();