mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-12 03:13:24 +01:00
Eye candy for unsolved arcs
This commit is contained in:
parent
7c37a0699c
commit
f99a788ee7
1 changed files with 14 additions and 3 deletions
|
|
@ -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();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue