<constrainToGrid/>
<constrainToGrid> is a Graphical
component that is used to constrain a <point> to a grid. The grid can be the default grid,
or a custom grid defined by the dx and dy attributes, or by the xOffset and yOffset attributes.
<constrainToGrid/> forces points to snap to gridline locations.
Attributes and Properties
Attributes for <constrainToGrid>
Other (6)
number. Default value: 1. Horizontal grid spacing.
number. Default value: 1. Vertical grid spacing.
dznumber. Default value: 1. Depth-wise grid spacing.
number. Default value: 0. Horizontal offset of the grid origin.
number. Default value: 0. Vertical offset of the grid origin.
zoffsetnumber. Default value: 0. Depth-wise offset of the grid origin.
Common to all components (9)
copyreference. Create an independent copy of another component by reference. Enter a references a $name.
disabledboolean. Default value: false. Whether this component is disabled and cannot be interacted with.
extendreference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.
fixedboolean. Default value: false. Whether this component's value is fixed and cannot be modified.
fixLocationboolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
hideboolean. Default value: false. Whether to hide this component from the rendered output.
isResponseboolean. Default value: false. Whether this component is treated as a response for the purposes of assessment.
nametext. The name used to reference this component from elsewhere in the document.
styleNumberinteger. Default value: 1. The style number used to select this component's visual styling from the available style definitions.
Properties for <constrainToGrid name="c">
Other (10)
$c.disabledboolean. Whether this component is disabled and cannot be interacted with.
$c.dxnumber. Horizontal grid spacing.
$c.dynumber. Vertical grid spacing.
$c.dznumber. Depth-wise grid spacing.
$c.fixedboolean. Whether this component's value is fixed and cannot be modified.
$c.fixLocationboolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
$c.xoffsetnumber. Horizontal offset of the grid origin.
$c.yoffsetnumber. Vertical offset of the grid origin.
$c.zoffsetnumber. Depth-wise offset of the grid origin.
Common to all components (4)
$c.doenetMLtext. The DoenetML source code that produced this component.
$c.hideboolean. Whether to hide this component from the rendered output.
$c.isResponseboolean. Whether this component is treated as a response for the purposes of assessment.
$c.styleNumberinteger. The style number used to select this component's visual styling from the available style definitions.
Examples
Example: Constrain a <point> to the default grid
The <point> is constrained to the default grid.
Example: Constrain a <circle> to the default grid
To constrain geometric objects other than points, first define a named <point> with the desired constraint, and then reference that point within the definition of the geometric object. The original <point> can be hidden using the hide attribute.
Example: Constrain a <point> to a custom grid
The <point> is constrained to a custom grid.
Attribute Examples
Attribute Example: dx, dy
The <point> is constrained to a custom grid using the dx and dy components. The grid specified for the <graph> does not affect the constraint grid, it is merely adjusted to match in this example for illustration.
Attribute Example: xOffset, yOffset
The <point> is constrained to the default grid with a specified xOffset and yOffset of .