1
0
mirror of https://github.com/Pomax/BezierInfo-2.git synced 2025-09-27 00:29:00 +02:00

poly-bezier

This commit is contained in:
Pomax
2020-09-03 22:21:05 -07:00
parent d2992ebd15
commit 83dcab57cb
19 changed files with 367 additions and 290 deletions

View File

@@ -97,6 +97,8 @@ class GraphicsAPI extends BaseAPI {
d = new Vector(p).dist(this.cursor);
if (d <= cdist) {
this.currentPoint = p;
this.currentPoint.mark = { x: p.x, y: p.y };
this.currentPoint.last = { x: p.x, y: p.y };
break;
}
}
@@ -105,8 +107,20 @@ class GraphicsAPI extends BaseAPI {
onMouseMove(evt) {
super.onMouseMove(evt);
if (this.currentPoint) {
this.currentPoint.last = {
x: this.currentPoint.x,
y: this.currentPoint.y,
};
this.currentPoint.x = this.cursor.x;
this.currentPoint.y = this.cursor.y;
this.currentPoint.diff = {
x: this.cursor.x - this.currentPoint.last.x,
y: this.cursor.y - this.currentPoint.last.y,
total: {
x: this.cursor.x - this.currentPoint.mark.x,
y: this.cursor.y - this.currentPoint.mark.y,
},
};
} else {
for (let i = 0, e = this.movable.length, p; i < e; i++) {
p = this.movable[i];
@@ -121,6 +135,9 @@ class GraphicsAPI extends BaseAPI {
onMouseUp(evt) {
super.onMouseUp(evt);
delete this.currentPoint.mark;
delete this.currentPoint.last;
delete this.currentPoint.diff;
this.currentPoint = false;
}