From f99a788ee72fe03d09f2323837c7bfb5afcb8d32 Mon Sep 17 00:00:00 2001 From: Val Erastov Date: Wed, 25 Feb 2015 01:18:45 -0800 Subject: [PATCH] Eye candy for unsolved arcs --- web/app/sketcher/shapes/arc.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/web/app/sketcher/shapes/arc.js b/web/app/sketcher/shapes/arc.js index 41911ff6..dd4682c1 100644 --- a/web/app/sketcher/shapes/arc.js +++ b/web/app/sketcher/shapes/arc.js @@ -50,14 +50,25 @@ TCAD.TWO.Arc.prototype.drawImpl = function(ctx, scale) { var r = this.radiusForDrawing(); var startAngle = Math.atan2(this.a.y - this.c.y, this.a.x - this.c.x); var endAngle; - if (TCAD.utils.areEqual(this.a.x, this.b.x, TCAD.TOLERANCE) && + if (TCAD.utils.areEqual(this.a.x, this.b.x, TCAD.TOLERANCE) && TCAD.utils.areEqual(this.a.y, this.b.y, TCAD.TOLERANCE)) { endAngle = startAngle + 2 * Math.PI; } else { endAngle = Math.atan2(this.b.y - this.c.y, this.b.x - this.c.x); - } + } ctx.arc(this.c.x, this.c.y, r, startAngle, endAngle); - ctx.stroke(); + var distanceB = this.distanceB(); + if (Math.abs(r - distanceB) * scale > 1) { + var adj = r / distanceB; + ctx.save(); + ctx.setLineDash([7 / scale]); + ctx.lineTo(this.b.x, this.b.y); + ctx.moveTo(this.b.x + (this.b.x - this.c.x) / adj, this.b.y + (this.b.y - this.c.y) / adj); + ctx.stroke(); + ctx.restore(); + } else { + ctx.stroke(); + } };