Referencerectangle

<rectangle>

A rectangle, potentially defined by width, height, center and/or corner vertices

<rectangle> is a Graphical component that renders a rectangle when nested inside a <graph> component.

Attributes and Properties

Attributes for <rectangle>

Number display (5)
avoidScientificNotation

boolean. Default value: false. Whether to render numbers in full decimal form rather than scientific notation.

displayDecimals

integer. Default value: 2. Number of decimal places to display when rendering this number.

displayDigits

integer. Default value: 3. Number of significant digits to display when rendering this number.

displaySmallAsZero

number. Default value: 1e-14. Threshold below which numbers are displayed as zero.

padZeros

boolean. Default value: false. Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.

Labels (1)
labelIsName

boolean. Default value: false. Whether to use this component's name as its rendered label.

Other (26)
addControls

keyword. Whether to render interactive control handles.

ValueDescription
centerShow a single control handle for moving the rectangle's center.
widthAndHeightShow control handles for resizing width and height.
centerWidthAndHeight (default)Show control handles for both moving the center and resizing.
noneShow no control handles.
allowDilation

boolean. Default value: true. Whether the shape can be dilated (scaled) under drag.

allowReflection

boolean. Default value: true. Whether the polyline can be reflected under drag.

allowRotation

boolean. Default value: true. Whether the polyline can be rotated under drag.

allowTranslation

boolean. Default value: true. Whether the polyline can be translated under drag.

applyStyleToLabel

boolean. Default value: false. Whether to apply this component's selected style to its label.

[ point ]. The rectangle's center point.

controlOrder

integer. Default value: 0. Slot order for graph controls (1-indexed; 0 means no explicit slot request).

draggable

boolean. Default value: true. Whether the polyline can be dragged on a graph.

filled

boolean. Default value: false. Whether to fill the interior of the polygon.

fillOpacity

number. Opacity of fills, 0 to 1.

number. The rectangle's height.

layer

integer. Default value: 0. Z-order layer index used to stack graphical components (higher values render on top).

lineStyle

keyword. Stroke style for lines.

ValueDescription
solidContinuous, unbroken stroke.
dashedStroke composed of evenly-spaced dashes.
dottedStroke composed of evenly-spaced dots.
lineWidth

number. Stroke width for lines, in pixels.

minShrink

number. Default value: 0.1. Minimum scaling factor allowed when dilating.

preserveSimilarity

boolean. Default value: false. Whether the shape is preserved up to similarity (uniform scaling) under drag.

rigid

boolean. Default value: false. Whether the polyline is treated as rigid (preserves shape under drag).

rotateAround

keyword. What point to rotate the shape around.

ValueDescription
centroid (default)Rotate around the centroid of the shape.
vertexRotate around the vertex specified by rotationVertex.
pointRotate around the explicit point given by rotationCenter.
rotationCenter

point. The point to rotate around when rotateAround is 'point'.

rotationHandleVertices

numberList. Default value: [1]. Vertex indices that should display rotation handles when the shape is rigid or preserves similarity.

rotationVertex

integer. Default value: 1. The vertex index to rotate around when rotateAround is 'vertex'.

showCoordsWhenDragging

boolean. Default value: true. Whether to show coordinate labels while dragging.

[ pointList ]. The list of vertex points that define the shape.

boolean. Whether individual vertices may be dragged independently.

number. The rectangle's width.

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 <rectangle name="r">

Number display (5)
$r.avoidScientificNotation

boolean. Whether to render numbers in full decimal form rather than scientific notation.

$r.displayDecimals

integer. Number of decimal places to display when rendering this number.

$r.displayDigits

integer. Number of significant digits to display when rendering this number.

$r.displaySmallAsZero

number. Threshold below which numbers are displayed as zero.

$r.padZeros

boolean. Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.

Labels (2)
$r.label

label. The label rendered with this component.

$r.labelIsName

boolean. Whether to use this component's name as its rendered label.

Other (31)
$r.addControls

text. Whether to render interactive control handles.

$r.allowDilation

boolean. Whether the polyline can be dilated under drag.

$r.allowReflection

boolean. Whether the polyline can be reflected under drag.

$r.allowRotation

boolean. Whether the polyline can be rotated under drag.

$r.allowTranslation

boolean. Whether the polyline can be translated under drag.

$r.applyStyleToLabel

boolean. Whether to apply this component's selected style to its label.

$r.area

number. The area enclosed by the polygon.

$r.borderStyleDescription

text. A textual description of the polygon's border style.

$r.center

[ math ]. The rectangle's center coordinates.

$r.controlOrder

integer. Slot order for graph controls (1-indexed; 0 means no explicit slot request).

$r.disabled

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

$r.draggable

boolean. Whether the polyline can be dragged on a graph.

$r.filled

boolean. Whether to fill the interior of the polygon.

$r.fillStyleDescription

text. A textual description of the polygon's fill style.

$r.fixed

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

$r.fixLocation

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

$r.height

number. The rectangle's height.

$r.hidden

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

$r.layer

integer. Z-order layer index used to stack graphical components (higher values render on top).

$r.numDimensions

number. The number of dimensions the polyline lives in.

$r.numSides

number. The number of sides of the polygon.

$r.numVertices

number. The number of vertices (always 4 for a rectangle).

$r.perimeter

number. The perimeter of the polygon.

$r.preserveSimilarity

boolean. Whether the polyline preserves its shape (up to similarity).

$r.rigid

boolean. Whether the polyline is treated as rigid (preserves shape under drag).

$r.showCoordsWhenDragging

boolean. Whether to show coordinate labels while dragging.

$r.styleDescription

text. A textual description of the polygon's style.

$r.styleDescriptionWithNoun

text. Style description including the word "polygon".

$r.vertices

[ math ]. The four corner vertices of the rectangle.

$r.verticesDraggable

boolean. Whether each vertex can be dragged independently.

$r.width

number. The rectangle's width.

Common to all components (4)
$r.doenetML

text. The DoenetML source code that produced this component.

$r.hide

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

$r.isResponse

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

$r.styleNumber

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

Examples

Example: Default <rectangle>

This is a default <rectangle> without additional attributes. The vertices can be dragged to change its shape, and the rectangle itself can be repositioned by clicking and dragging on any side.


Example: <rectangle> with center, width and height

A <rectangle> can be described by specifying its center, width and height with attributes. The vertices can be dragged to change its shape, and the rectangle itself can be repositioned by clicking and dragging on any side.


Example: Filled colored <rectangle>

The filled attribute renders the rectangle with default shading to match the styleNumber.


Example: <rectangle> from vertices

Use the vertices attribute to specify a list of the two opposite corner points of the rectangle (lower left and upper right); default: vertices=“(0,0) (1,1)“


Example: <rectangle> constrained to a grid

A rectangle is effectively constrained to an integer grid by referencing two constrained points in the vertices attribute.

Attribute Examples

Attribute Example: center

Use the center attribute to specify the center point of the rectangle. If not specified, the default center position is (0.5,0.5)(0.5, 0.5).


Attribute Example: width, height

Use the width and height attributes to specify the proportions of the <rectangle> directly. If not specified, the default values for width and height are both 11.


Attribute Example: vertices

Use the vertices attribute to specify a list of the two opposite corner points of the rectangle (lower left and upper right); default: vertices=“(0,0) (1,1)“


Attribute Example: verticesDraggable

Vertices are draggable by default. Use the verticesDraggable attribute set to false to disable users from changing the proportions of the <rectangle>. The rectangle as a whole can still be repositioned on the <graph>.


Attribute Example: Standard graphical attributes

The uses of the following standard graphical attributes are illustrated: hide, draggable, layer, styleNumber, applyStyleToLabel and labelIsName.

Property Examples

Property Example: Attributes as properties

The above listed attributes of a named <rectangle> are also available as properties.