2024-07-06 19:17:10 +00:00
|
|
|
import { Vector2 } from "./math.js";
|
|
|
|
import { Drawable } from "./drawable.js";
|
|
|
|
|
|
|
|
export class Line extends Drawable {
|
|
|
|
constructor(parent) {
|
|
|
|
super(parent);
|
|
|
|
this._offsetVec = new Vector2(10, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
draw() {
|
|
|
|
artworld.setStrokeColor(this._stroke);
|
|
|
|
artworld.setStrokeWeight(this._strokeWeight);
|
2024-07-06 20:21:35 +00:00
|
|
|
artworld.drawLine(this.worldPos, this.worldPos.add(this._offsetVec));
|
2024-07-06 19:17:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
to(vec) {
|
|
|
|
this._offsetVec = vec;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
angle(angle) {
|
|
|
|
let mag = this._offsetVec.magnitude;
|
|
|
|
return this.to(Vector2.polar(mag, angle));
|
|
|
|
}
|
|
|
|
}
|