<regularPolygon>
<regularPolygon> is a Graphical
component that renders a regular polygon on a <graph>.
Attributes and Properties
Attributes for <regularPolygon>
Number display (5)
avoidScientificNotationboolean. Default value: false. Whether to render numbers in full decimal form rather than scientific notation.
displayDecimalsinteger. Default value: 2. Number of decimal places to display when rendering this number.
displayDigitsinteger. Default value: 3. Number of significant digits to display when rendering this number.
displaySmallAsZeronumber. Default value: 1e-14. Threshold below which numbers are displayed as zero.
padZerosboolean. Default value: false. Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.
Labels (1)
labelIsNameboolean. Default value: false. Whether to use this component's name as its rendered label.
Other (32)
addControlskeyword. Whether to render interactive control handles.
| Value | Description |
|---|---|
center | Show a control handle for moving the polygon's center. |
radius | Show a control handle for resizing the polygon's radius. |
centerAndRadius (default) | Show control handles for both moving the center and resizing the radius. |
none | Show no control handles. |
allowDilationboolean. Default value: true. Whether the shape can be dilated (scaled) under drag.
allowReflectionboolean. Default value: true. Whether the polyline can be reflected under drag.
allowRotationboolean. Default value: true. Whether the polyline can be rotated under drag.
allowTranslationboolean. Default value: true. Whether the polyline can be translated under drag.
number. Alias for inradius.
applyStyleToLabelboolean. Default value: false. Whether to apply this component's selected style to its label.
number. Total area enclosed by the regular polygon.
[ point ]. Center of the regular polygon.
number. Distance from center to a vertex (circumscribed-circle radius).
controlOrderinteger. Default value: 0. Slot order for graph controls (1-indexed; 0 means no explicit slot request).
draggableboolean. Default value: true. Whether the polyline can be dragged on a graph.
filledboolean. Default value: false. Whether to fill the interior of the polygon.
fillOpacitynumber. Opacity of fills, 0 to 1.
number. Distance from center to the midpoint of a side (inscribed-circle radius).
layerinteger. Default value: 0. Z-order layer index used to stack graphical components (higher values render on top).
lineStylekeyword. Stroke style for lines.
| Value | Description |
|---|---|
solid | Continuous, unbroken stroke. |
dashed | Stroke composed of evenly-spaced dashes. |
dotted | Stroke composed of evenly-spaced dots. |
lineWidthnumber. Stroke width for lines, in pixels.
minShrinknumber. Default value: 0.1. Minimum scaling factor allowed when dilating.
integer. Number of sides in the regular polygon (alias for numVertices).
integer. Default value: 3. Number of vertices in the regular polygon.
number. Total perimeter of the regular polygon.
number. Alias for circumradius.
rigidboolean. Default value: false. Whether the polyline is treated as rigid (preserves shape under drag).
rotateAroundkeyword. What point to rotate the shape around.
| Value | Description |
|---|---|
centroid (default) | Rotate around the centroid of the shape. |
vertex | Rotate around the vertex specified by rotationVertex. |
point | Rotate around the explicit point given by rotationCenter. |
rotationCenterpoint. The point to rotate around when rotateAround is 'point'.
rotationHandleVerticesnumberList. Default value: [1]. Vertex indices that should display rotation handles when the shape is rigid or preserves similarity.
rotationVertexinteger. Default value: 1. The vertex index to rotate around when rotateAround is 'vertex'.
showCoordsWhenDraggingboolean. Default value: true. Whether to show coordinate labels while dragging.
number. Length of each side of the regular polygon.
[ pointList ]. The list of vertex points that define the shape.
boolean. Whether individual vertices may be dragged independently.
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.
boolean. Default value: false. Whether this component's value is fixed and cannot be modified.
boolean. 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 <regularPolygon name="r">
Number display (5)
$r.avoidScientificNotationboolean. Whether to render numbers in full decimal form rather than scientific notation.
$r.displayDecimalsinteger. Number of decimal places to display when rendering this number.
$r.displayDigitsinteger. Number of significant digits to display when rendering this number.
$r.displaySmallAsZeronumber. Threshold below which numbers are displayed as zero.
$r.padZerosboolean. Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.
Labels (2)
$r.labellabel. The label rendered with this component.
$r.labelIsNameboolean. Whether to use this component's name as its rendered label.
Other (34)
$r.addControlstext. Whether to render interactive control handles.
$r.allowDilationboolean. Whether the polyline can be dilated under drag.
$r.allowReflectionboolean. Whether the polyline can be reflected under drag.
$r.allowRotationboolean. Whether the polyline can be rotated under drag.
$r.allowTranslationboolean. Whether the polyline can be translated under drag.
$r.apothemnumber. Distance from center to the midpoint of a side (alias for inradius).
$r.applyStyleToLabelboolean. Whether to apply this component's selected style to its label.
$r.areanumber. The area enclosed by the polygon.
$r.borderStyleDescriptiontext. A textual description of the polygon's border style.
$r.center[ math ]. The center coordinates of the regular polygon.
$r.circumradiusnumber. The radius of the circumscribed circle.
$r.controlOrderinteger. Slot order for graph controls (1-indexed; 0 means no explicit slot request).
$r.disabledboolean. Whether this component is disabled and cannot be interacted with.
$r.draggableboolean. Whether the polyline can be dragged on a graph.
$r.filledboolean. Whether to fill the interior of the polygon.
$r.fillStyleDescriptiontext. A textual description of the polygon's fill style.
$r.fixedboolean. Whether this component's value is fixed and cannot be modified.
$r.fixLocationboolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
$r.inradiusnumber. The radius of the inscribed circle.
$r.layerinteger. Z-order layer index used to stack graphical components (higher values render on top).
$r.numDimensionsnumber. The number of dimensions the polyline lives in.
$r.numSidesinteger. The number of sides of the regular polygon.
$r.numVerticesinteger. The number of vertices (sides) of the regular polygon.
$r.perimeternumber. The perimeter of the polygon.
$r.preserveSimilarityboolean. Whether to preserve similarity when dragging.
$r.radiusnumber. Distance from center to a vertex (alias for circumradius).
$r.rigidboolean. Whether the polyline is treated as rigid (preserves shape under drag).
$r.showCoordsWhenDraggingboolean. Whether to show coordinate labels while dragging.
$r.sideLengthnumber. The length of each side.
$r.styleDescriptiontext. A textual description of the polygon's style.
$r.styleDescriptionWithNountext. Style description including the word "polygon".
$r.vertices[ math ]. The vertices of the polyline.
$r.verticesDraggableboolean. Whether each vertex can be dragged independently.
Common to all components (4)
$r.doenetMLtext. The DoenetML source code that produced this component.
$r.hideboolean. Whether to hide this component from the rendered output.
$r.isResponseboolean. Whether this component is treated as a response for the purposes of assessment.
$r.styleNumberinteger. The style number used to select this component's visual styling from the available style definitions.
Examples Page 1
Example: Default <regularPolygon>
The default shape for a <regularPolygon> without any attributes specified
is a triangle with radius 1 (where radius implies circumradius in this case),
centered at the origin.
Example: <regularPolygon> with user-specified sides
In this example, the number of sides and side length are specified by the user
with a <mathInput/> and a <slider/> component, respectively. These
values are then referenced by the numSides and sideLength attributes of
the <regularPolygon>. Note that the prefill attributes
are required in this case; the values for these attributes cannot be null.
Example: Filled, colored <regularPolygon>
The filled attribute renders the polygon with default shading to match the styleNumber.
Example: Construct a polygon on a given line segment
Two vertices only of a <regularPolygon> are specified in the vertices attribute by
referencing the endpoints of a defined <lineSegment>. Try tinkering with the
number of sides in this example, or dragging the endpoints of the line segment.
Attribute Examples
Attribute Example: numVertices
The number of vertices of a regular polygon can be specified with the numVertices attribute.
Attribute Example: numSides
The number of sides of a regular polygon can be specified with the numSides attribute.
Attribute Example: center
The center of a regular polygon can be specified with the center attribute.
Note on precedence: the vertices and center attributes take precedence over the
following attributes (in the event of overconstraint): radius / circumRadius,
inRadius / apothem, sideLength, perimeter, and area.
Attribute Example: vertices
The endpoints of a known side can be specified with the vertices attribute, and Doenet will construct the resulting regular polygon (given a specified number of sides).
Note on precedence: the vertices and center attributes take precedence over the following attributes (in the event of overconstraint): radius / circumRadius, inRadius / apothem, sideLength, perimeter, and area.
Attribute Example: radius / circumRadius
The radius and circumRadius attributes are an interchangeable way to specify the distance from the center of a regular polygon to any of its vertices. (Note that the vertices attribute takes precedence in the case of overconstraint.)
Attribute Example: inRadius / apothem
The inRadius and apothem attributes are an interchangeable way to specify the distance from the center of a regular polygon to the midpoint of any of its sides. (Note that the vertices attribute takes precedence in the case of overconstraint.)
Attribute Example: sideLength
The sideLength attribute can be used to adjust the size of the regular polygon. (Note that the vertices attribute takes precedence in the case of overconstraint.)
Attribute Example: perimeter
The perimeter attribute can be used to adjust the size of the regular polygon. (Note that the vertices attribute takes precedence in the case of overconstraint.)