mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-08 01:13:27 +01:00
arc drawing improvements
This commit is contained in:
parent
c18798e079
commit
1566ea0a16
2 changed files with 19 additions and 3 deletions
|
|
@ -53,9 +53,16 @@ TCAD.TWO.Arc.prototype.distanceB = function() {
|
|||
TCAD.TWO.Arc.prototype.drawImpl = function(ctx, scale) {
|
||||
ctx.beginPath();
|
||||
var r = this.radiusForDrawing();
|
||||
ctx.arc(this.c.x, this.c.y, r,
|
||||
Math.atan2(this.a.y - this.c.y, this.a.x - this.c.x),
|
||||
Math.atan2(this.b.y - this.c.y, this.b.x - this.c.x));
|
||||
var startAngle = Math.atan2(this.a.y - this.c.y, this.a.x - this.c.x);
|
||||
var endAngle;
|
||||
if ( this.a.isCoincidentTo(this.b) ||
|
||||
(TCAD.utils.areEqual(this.a.x, this.b.x, TCAD.utils.TOLERANCE) &&
|
||||
TCAD.utils.areEqual(this.a.y, this.b.y, TCAD.utils.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();
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -274,6 +274,15 @@ TCAD.TWO.SketchObject = function() {
|
|||
this.linked = [];
|
||||
};
|
||||
|
||||
TCAD.TWO.SketchObject.prototype.isCoincidentTo = function(other) {
|
||||
for (var i = 0; i < this.linked.length; i++) {
|
||||
var obj = this.linked[i];
|
||||
if (obj.id === other.id) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
TCAD.TWO.SketchObject.prototype._translate = function(dx, dy, translated) {
|
||||
translated[this.id] = 'x';
|
||||
|
|
|
|||
Loading…
Reference in a new issue