CurveEdge.js 1001 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //墙的边缘线
  2. import Geometry from "./Geometry.js";
  3. import VectorType from "../enum/VectorType.js";
  4. import { mathUtil } from "../Util/MathUtil";
  5. export default class CurveEdge extends Geometry {
  6. constructor(start, end, vectorId, parentId) {
  7. super();
  8. this.parent = parentId;
  9. this.start = {};
  10. this.end = {};
  11. this.vectorId = null;
  12. this.points = [];
  13. this.geoType = VectorType.CurveEdge;
  14. this.setId(vectorId);
  15. this.setPositions(start, end);
  16. }
  17. setPositions(point1, point2) {
  18. this.start.x = point1.x;
  19. this.start.y = point1.y;
  20. this.end.x = point2.x;
  21. this.end.y = point2.y;
  22. }
  23. setPosition(position, dir) {
  24. if (dir == "start") {
  25. mathUtil.clonePoint(this.start, position);
  26. } else if (dir == "end") {
  27. mathUtil.clonePoint(this.end, position);
  28. }
  29. }
  30. getPosition(dir) {
  31. if (dir == "start") {
  32. return this.start;
  33. } else if (dir == "end") {
  34. return this.end;
  35. } else {
  36. return null;
  37. }
  38. }
  39. }