Interface for classes that can snap coordinates of items of a specific type to a grid.
Inheritance Hierarchy
Remarks
Type Parameters
T
- The type of the items this class can snap
Examples
Enabling grid snapping
const snapContext = new GraphSnapContext()
const gridInfo = new GridInfo(50, 50)
snapContext.nodeGridConstraintProvider = new GridConstraintProvider(
gridInfo,
)
snapContext.bendGridConstraintProvider = new GridConstraintProvider(
gridInfo,
)
snapContext.portGridConstraintProvider = new GridConstraintProvider(
gridInfo,
)
snapContext.gridSnapType = GridSnapTypes.GRID_POINTS
graphEditorInputMode.snapContext = snapContextNote that the grid visualization has to be enabled separately
graphComponent.renderTree.createElement(
graphComponent.renderTree.backgroundGroup,
gridInfo,
new GridRenderer(),
)See Also
Members
No filters for this type
Properties
Gets the canonical origin of the grid.
Gets the canonical origin of the grid.
readonlyabstract
Implemented in
GridConstraintProvider.gridOriginreadonlyabstract
Implemented in
GridConstraintProvider.horizontalGridWidthreadonlyabstract
Implemented in
GridConstraintProvider.verticalGridWidthMethods
abstract
Parameters
- context: IInputModeContext
- The context in which the snapping should occur.
- item: T
- The item of which the coordinates should be snapped.
- location: IMutablePoint
- The coordinates to snap.
- xSnapPolicy: SnapPolicy
- The policy for the x-coordinate.
- ySnapPolicy: SnapPolicy
- The policy for the y-coordinate.
Return Value
- boolean
- Whether the point has been snapped.
Implemented in
GridConstraintProvider.snapToGridStatic Methods
Creates an implementation of the interface IGridConstraintProvider<T> from the given definition.
Creates an implementation of the interface IGridConstraintProvider<T> from the given definition.
The given object must contain exactly the abstract members of the IGridConstraintProvider<T> interface. No member may be omitted and no additional members can be added. While additional custom members can later be added directly on the instance, this is discouraged.
static
Parameters
Return Value
- IGridConstraintProvider<T>
- An instance of the IGridConstraintProvider<T> interface based on the given definition.