From 186c28c8e76ff6a7fce92fd6dcaef9a9dcd385c0 Mon Sep 17 00:00:00 2001 From: Marcel Date: Thu, 7 Mar 2019 16:12:24 +0100 Subject: [PATCH] Move text out of state circle when too long --- js/components/state.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/js/components/state.js b/js/components/state.js index d31b5c0..3e0acd1 100644 --- a/js/components/state.js +++ b/js/components/state.js @@ -58,7 +58,11 @@ class State { } 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) { ctx.beginPath();