clone
方法创建一个新的 LineSegment
对象,该对象与原始 LineSegment
对象具有相同的起点和终点。
lineSegment.clone()
lineSegment
:需要复制的 LineSegment
对象。
一个新的 LineSement
对象,它与原始的 LineSegment
对象拥有相同的起点和终点。
const lineSegment1 = new LineSegment({ x: 0, y: 0 }, { x: 1, y: 1 });
const lineSegment2 = lineSegment1.clone();
console.log(lineSegment1); // 输出: LineSegment {startPoint: Point {x: 0, y: 0}, endPoint: Point {x: 1, y: 1}}
console.log(lineSegment2); // 输出: LineSegment {startPoint: Point {x: 0, y: 0}, endPoint: Point {x: 1, y: 1}}
console.log(lineSegment1 === lineSegment2); // 输出: false
clone
方法的执行不会影响原始 LineSegment
对象。