Improve the positioning of labels aroud the ruler graphic

This commit is contained in:
Manuel Vögele
2021-05-18 09:46:03 +02:00
parent 38b7df0248
commit 4aab6eec95
3 changed files with 38 additions and 1 deletions
+21
View File
@@ -0,0 +1,21 @@
export class Line {
constructor(m, b) {
this.m = m;
this.b = b;
}
static fromPoints(p1, p2) {
// Bring line into y=mx+b form
const m = (p1.y - p2.y) / (p1.x - p2.x);
const b = p1.y - m * p1.x;
return new Line(m, b);
}
get isVertical() {
return !isFinite(this.m);
}
calcY(x) {
return this.m * x + this.b;
}
}