ReferenceattractToGrid

<attractToGrid/>

Attracts a graphical component's position to grid lines when nearby

<attractToGrid> is a Graphical component that is used within a <point> to attract it to a specified grid.

Attributes and Properties

Attributes for <attractToGrid>

Other (10)

number. Default value: 1. Horizontal grid spacing.

number. Default value: 1. Vertical grid spacing.

dz

number. Default value: 1. Depth-wise grid spacing.

includeGridlines

boolean. Default value: false. Whether to attract to entire grid lines (in addition to grid intersection points).

number. Default value: 0. Horizontal offset of the grid origin.

number. Default value: 0.2. Horizontal distance within which the position attracts to a grid line.

number. Default value: 0. Vertical offset of the grid origin.

number. Default value: 0.2. Vertical distance within which the position attracts to a grid line.

zoffset

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

zthreshold

number. Default value: 0.2. Depth-wise distance within which the position attracts to a grid line.

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 <attractToGrid name="a">

Other (14)
$a.disabled

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

$a.dx

number. Horizontal grid spacing.

$a.dy

number. Vertical grid spacing.

$a.dz

number. Depth-wise grid spacing.

$a.fixed

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

$a.fixLocation

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

$a.hidden

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

$a.includeGridlines

boolean. Whether to attract to entire grid lines (in addition to grid intersection points).

$a.xoffset

number. Horizontal offset of the grid origin.

$a.xthreshold

number. Horizontal distance within which the position attracts to a grid line.

$a.yoffset

number. Vertical offset of the grid origin.

$a.ythreshold

number. Vertical distance within which the position attracts to a grid line.

$a.zoffset

number. Depth-wise offset of the grid origin.

$a.zthreshold

number. Depth-wise distance within which the position attracts to a grid line.

Common to all components (4)
$a.doenetML

text. The DoenetML source code that produced this component.

$a.hide

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

$a.isResponse

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

$a.styleNumber

integer. The style number used to select this component's visual styling from the available style definitions.

Examples

Example: Attract <point> to a grid, default behavior

The default grid spacing for attraction for a <point> with the <attractToGrid> constraint is 1.

Attribute Examples

Attribute Example: dx, dy

The dx and dy attributes allow for customization of the attraction grid. Note that it is not required to display the grid in the graph; this is done for illustration.


Attribute Example: xOffset, yOffset

With the xOffset and yOffset attributes, the spacing of attraction gridlines can be adjusted to a specific offset of the specified dx and dy.

The grey points are included as an illustration of where the offset attraction grids occur.


Attribute Example: xThreshold, yThreshold

The xThreshold and yThreshold attributes can be used to control how close the <point> must be to a grid for attraction to take effect. Notice the different behavior above when dragging the point close to the xx gridlines and yy gridlines.

Property Examples

Property Example: Attributes as properties

The attributes of <attractToGrid/> shown in the example above are also available as properties.