ReferenceconstrainToGrid

<constrainToGrid/>

Constrains a graphical component's position to lie on a grid

<constrainToGrid> is a Graphical component that is used to constrain a <point> to a grid. The grid can be the default 1×11 \times 1 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.

dz

number. 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.

zoffset

number. Default value: 0. Depth-wise offset of the grid origin.

Common to all components (9)
copy

reference. Create an independent copy of another component by reference. Enter a references a $name.

disabled

boolean. Default value: false. Whether this component is disabled and cannot be interacted with.

extend

reference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.

fixed

boolean. Default value: false. Whether this component's value is fixed and cannot be modified.

fixLocation

boolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

hide

boolean. Default value: false. Whether to hide this component from the rendered output.

isResponse

boolean. Default value: false. Whether this component is treated as a response for the purposes of assessment.

name

text. The name used to reference this component from elsewhere in the document.

styleNumber

integer. 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.disabled

boolean. Whether this component is disabled and cannot be interacted with.

$c.dx

number. Horizontal grid spacing.

$c.dy

number. Vertical grid spacing.

$c.dz

number. Depth-wise grid spacing.

$c.fixed

boolean. Whether this component's value is fixed and cannot be modified.

$c.fixLocation

boolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

$c.hidden

boolean. Whether this component is hidden from the rendered output.

$c.xoffset

number. Horizontal offset of the grid origin.

$c.yoffset

number. Vertical offset of the grid origin.

$c.zoffset

number. Depth-wise offset of the grid origin.

Common to all components (4)
$c.doenetML

text. The DoenetML source code that produced this component.

$c.hide

boolean. Whether to hide this component from the rendered output.

$c.isResponse

boolean. Whether this component is treated as a response for the purposes of assessment.

$c.styleNumber

integer. 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 1×11 \times 1 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 0.5×0.50.5 \times 0.5 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 1×11 \times 1 grid with a specified xOffset and yOffset of 0.50.5.