吸附点导出
This commit is contained in:
parent
25aa6ae382
commit
b9a8682f7e
2
lib/graphic/AbsorbablePosition.d.ts
vendored
2
lib/graphic/AbsorbablePosition.d.ts
vendored
@ -34,7 +34,7 @@ export declare const AbsorbablePointParam: {
|
||||
/**
|
||||
* 可吸附点
|
||||
*/
|
||||
export default class AbsorbablePoint extends Graphics implements AbsorbablePosition, VectorGraphic {
|
||||
export declare class AbsorbablePoint extends Graphics implements AbsorbablePosition, VectorGraphic {
|
||||
_point: Point;
|
||||
absorbRange: number;
|
||||
scaledListenerOn: boolean;
|
||||
|
50
lib/index.js
50
lib/index.js
@ -2579,6 +2579,54 @@ const AbsorbablePointGraphic = new Graphics();
|
||||
AbsorbablePointGraphic.beginFill(AbsorbablePointParam.fillColor);
|
||||
AbsorbablePointGraphic.drawCircle(0, 0, AbsorbablePointParam.radius);
|
||||
AbsorbablePointGraphic.endFill();
|
||||
/**
|
||||
* 可吸附点
|
||||
*/
|
||||
class AbsorbablePoint extends Graphics {
|
||||
_point;
|
||||
absorbRange;
|
||||
scaledListenerOn = false;
|
||||
/**
|
||||
*
|
||||
* @param point 画布坐标
|
||||
* @param absorbRange
|
||||
*/
|
||||
constructor(point, absorbRange = 10) {
|
||||
super(AbsorbablePointGraphic.geometry);
|
||||
this._point = new Point(point.x, point.y);
|
||||
this.absorbRange = absorbRange;
|
||||
this.position.copyFrom(this._point);
|
||||
this.interactive;
|
||||
VectorGraphicUtil.handle(this);
|
||||
}
|
||||
compareTo(other) {
|
||||
if (other instanceof AbsorbablePoint) {
|
||||
return this.absorbRange - other.absorbRange;
|
||||
}
|
||||
throw new Error('非可吸附点');
|
||||
}
|
||||
isOverlapping(other) {
|
||||
if (other instanceof AbsorbablePoint) {
|
||||
return (this._point.equals(other._point) &&
|
||||
this.absorbRange === other.absorbRange);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
tryAbsorb(...objs) {
|
||||
for (let i = 0; i < objs.length; i++) {
|
||||
const obj = objs[i];
|
||||
const canvasPosition = obj.getPositionOnCanvas();
|
||||
if (distance(this._point.x, this._point.y, canvasPosition.x, canvasPosition.y) < this.absorbRange) {
|
||||
obj.updatePositionByCanvasPosition(this._point);
|
||||
}
|
||||
}
|
||||
}
|
||||
updateOnScaled() {
|
||||
const scaled = this.getAllParentScaled();
|
||||
const scale = Math.max(scaled.x, scaled.y);
|
||||
this.scale.set(1 / scale, 1 / scale);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 可吸附线
|
||||
*/
|
||||
@ -7654,4 +7702,4 @@ function newDrawApp(options) {
|
||||
return new JlDrawApp(options);
|
||||
}
|
||||
|
||||
export { AbsorbableCircle, AbsorbableLine, AbsorbablePointParam, AnimationManager, AppConsts, AppDragEvent, AppInteractionPlugin, AppWsMsgBroker, BezierCurveEditPlugin, BoundsGraphic, ChildTransform, ClientEngine, CombinationKey, CommonMouseTool, ContextMenu, ContextMenuPlugin, DOWN, DashedLine, DefaultWhiteMenuOptions, DefaultWhiteStyleOptions, DragPlugin, DraggablePoint, DraggablePointParam, GlobalKeyboardHelper, GraphicAnimation, GraphicCopyPlugin, GraphicDataUpdateOperation, GraphicDrawAssistant, GraphicEditPlugin, GraphicIdGenerator, GraphicInteractionPlugin, GraphicRelation, GraphicRelationParam, GraphicStore, GraphicTransform, GraphicTransformEvent, GraphicTransformPlugin, IdGenerator, InteractionPluginBase, InteractionPluginType, JlGraphic, JlGraphicAppKeyboardPlugin, JlGraphicTemplate, JlOperation, KeyListener, LEFT, LineEditPlugin, OperationRecord, OtherInteractionPlugin, OutOfBound, PolylineEditPlugin, RIGHT, RelationManage, ScaleData, ShiftData, TransformPoints, UP, VectorGraphicUtil, VectorText, ViewportMovePlugin, WsMsgCli, addBezierWayPoint, addLineWayPoint, addPolygonSegmentingPoint, addWayPoint, angleOfIncludedAngle, angleToAxisx, assertBezierPoints, calculateBezierPoints, calculateDistanceFromPointToLine, calculateFootPointFromPointToLine, calculateIntersectionPointOfCircleAndLine, calculateIntersectionPointOfCircleAndPoint, calculateLineMidpoint, calculateLineSegmentingPoint, calculateMirrorPoint, calculateMirrorPointBasedOnAxis, calculateOneBezierPoints, circlePoint, circlePoint2, clearWayPoint, convertLineToPolygonPoints, convertRectangleToPolygonPoints, convertToBezierParams, debounce, deserializeTransformInto, distance, distance2, epsilon, floatEquals, getCenterOfTwoRectangle, getIntersectionPoint, getNormalVector, getParallelOfPolyline, getRectangleCenter, getWayLineIndex, getWaypointRangeIndex, isLineContainOther, isParallelLines, isPointOnLine, isZero, lineBox, lineLine, linePoint, linePolygon, movePointAlongNormal, newDrawApp, newGraphicApp, pointBox, pointPoint, pointPoint2, pointPolygon, polylineBox, polylinePoint, polylinePolygon, recursiveChildren, recursiveFindChild, recursiveFindParent, recursiveParents, removeBezierWayPoint, removeLineWayPoint, removeWayPoint, serializeTransform, splitLineEvenly, splitPolyline };
|
||||
export { AbsorbableCircle, AbsorbableLine, AbsorbablePoint, AbsorbablePointParam, AnimationManager, AppConsts, AppDragEvent, AppInteractionPlugin, AppWsMsgBroker, BezierCurveEditPlugin, BoundsGraphic, ChildTransform, ClientEngine, CombinationKey, CommonMouseTool, ContextMenu, ContextMenuPlugin, DOWN, DashedLine, DefaultWhiteMenuOptions, DefaultWhiteStyleOptions, DragPlugin, DraggablePoint, DraggablePointParam, GlobalKeyboardHelper, GraphicAnimation, GraphicCopyPlugin, GraphicDataUpdateOperation, GraphicDrawAssistant, GraphicEditPlugin, GraphicIdGenerator, GraphicInteractionPlugin, GraphicRelation, GraphicRelationParam, GraphicStore, GraphicTransform, GraphicTransformEvent, GraphicTransformPlugin, IdGenerator, InteractionPluginBase, InteractionPluginType, JlGraphic, JlGraphicAppKeyboardPlugin, JlGraphicTemplate, JlOperation, KeyListener, LEFT, LineEditPlugin, OperationRecord, OtherInteractionPlugin, OutOfBound, PolylineEditPlugin, RIGHT, RelationManage, ScaleData, ShiftData, TransformPoints, UP, VectorGraphicUtil, VectorText, ViewportMovePlugin, WsMsgCli, addBezierWayPoint, addLineWayPoint, addPolygonSegmentingPoint, addWayPoint, angleOfIncludedAngle, angleToAxisx, assertBezierPoints, calculateBezierPoints, calculateDistanceFromPointToLine, calculateFootPointFromPointToLine, calculateIntersectionPointOfCircleAndLine, calculateIntersectionPointOfCircleAndPoint, calculateLineMidpoint, calculateLineSegmentingPoint, calculateMirrorPoint, calculateMirrorPointBasedOnAxis, calculateOneBezierPoints, circlePoint, circlePoint2, clearWayPoint, convertLineToPolygonPoints, convertRectangleToPolygonPoints, convertToBezierParams, debounce, deserializeTransformInto, distance, distance2, epsilon, floatEquals, getCenterOfTwoRectangle, getIntersectionPoint, getNormalVector, getParallelOfPolyline, getRectangleCenter, getWayLineIndex, getWaypointRangeIndex, isLineContainOther, isParallelLines, isPointOnLine, isZero, lineBox, lineLine, linePoint, linePolygon, movePointAlongNormal, newDrawApp, newGraphicApp, pointBox, pointPoint, pointPoint2, pointPolygon, polylineBox, polylinePoint, polylinePolygon, recursiveChildren, recursiveFindChild, recursiveFindParent, recursiveParents, removeBezierWayPoint, removeLineWayPoint, removeWayPoint, serializeTransform, splitLineEvenly, splitPolyline };
|
||||
|
@ -64,10 +64,9 @@ AbsorbablePointGraphic.endFill();
|
||||
/**
|
||||
* 可吸附点
|
||||
*/
|
||||
export default class AbsorbablePoint
|
||||
export class AbsorbablePoint
|
||||
extends Graphics
|
||||
implements AbsorbablePosition, VectorGraphic
|
||||
{
|
||||
implements AbsorbablePosition, VectorGraphic {
|
||||
_point: Point;
|
||||
absorbRange: number;
|
||||
scaledListenerOn = false;
|
||||
|
Loading…
Reference in New Issue
Block a user