ControlPoint.js 900 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import VectorType from "../enum/VectorType.js";
  2. import Geometry from "./Geometry";
  3. // 二次贝塞尔曲线
  4. // var ctx=c.getContext("2d");
  5. // ctx.beginPath();
  6. // ctx.moveTo(200,20);
  7. // ctx.quadraticCurveTo(20,100,20,20);
  8. // ctx.stroke();
  9. export default class ControlPoint extends Geometry {
  10. constructor(position, vectorId) {
  11. super();
  12. //控制点坐标
  13. this.x = null;
  14. this.y = null;
  15. this.edgeInfo1 = {
  16. id: null,
  17. dir: null,
  18. };
  19. this.edgeInfo2 = {
  20. id: null,
  21. dir: null,
  22. };
  23. this.geoType = VectorType.ControlPoint;
  24. this.setId(vectorId);
  25. this.setPosition(position);
  26. }
  27. setPosition(position) {
  28. this.x = position.x;
  29. this.y = position.y;
  30. }
  31. setEdgeInfo(edgeId1, dir1, edgeId2, dir2) {
  32. this.edgeInfo1.id = edgeId1;
  33. this.edgeInfo1.dir = dir1;
  34. this.edgeInfo2.id = edgeId2;
  35. this.edgeInfo2.dir = dir2;
  36. }
  37. }