ReferencelineSegment

<lineSegment>

<lineSegment> is a Graphical component that renders a line segment when nested within a <graph> component.

Attributes and Properties

Attributes for <lineSegment>
AttributeTypeValues
applyStyleToLabel = "…"boolean"true" "false"
displayDecimals = "…"integer
displayDigits = "…"integer
displaySmallAsZero = "…"number
draggable = "…"boolean"true" "false"
endpoints = "…"[ math ]
endpointsDraggable = "…"boolean"true" "false"
labelIsName = "…"boolean"true" "false"
labelPosition = "…"text"upperright" "upperleft" "lowerright" "lowerleft"
layer = "…"integer
padZeros = "…"boolean"true" "false"
showCoordsWhenDragging = "…"boolean"true" "false"
Props for <lineSegment name="l">
PropertyType
$l.applyStyleToLabelboolean
$l.disabledboolean
$l.displayDecimalsinteger
$l.displayDigitsinteger
$l.displaySmallAsZeronumber
$l.draggableboolean
$l.endpoints[ math ]
$l.endpointsDraggableboolean
$l.fixedboolean
$l.fixLocationboolean
$l.hiddenboolean
$l.labellabel
$l.labelIsNameboolean
$l.labelPositiontext
$l.layerinteger
$l.lengthmath
$l.numDimensionsnumber
$l.padZerosboolean
$l.showCoordsWhenDraggingboolean
$l.slopenumber
$l.styleDescriptiontext
$l.styleDescriptionWithNountext

Example: Default <lineSegment>

Without any attributes, the default <lineSegment> has endpoints (0,0)(0,0) and (1,0)(1,0).


Example: <lineSegment> with rendered endpoints

The endpoints property of a named <lineSegment> can be rendered on a <graph> with the macro $name.property.


Example: <lineSegment> constrained to a grid

The endpoints of a <lineSegment> are predefined as constrained points, thereby constraining the segment to a grid as well.


Attribute Example: endpoints

The endpoints attribute takes as an input a list of two points.


Attribute Example: draggable

The draggable attribute determines whether the <lineSegment> can be dragged around the <graph>. All graphical objects are draggable by default.


Attribute Example: endpointsDraggable

Endpoints are draggable by default. Use the endpointsDraggable attribute set to false to disable users from changing the shape and length of the <lineSegment>. The segment as a whole can still be repositioned on the <graph>.


Attribute Example: showCoordsWhenDragging

By default, a light-grey set of coordinates is shown while the user drags the endpoints of the line segment. To turn off this default behavior, set the showCoordsWhenDragging attribute to false.


Attribute Example: Standard graphical attributes

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


Property Example: numDimensions

The numDimensions property returns the number of dimesions of the <lineSegment>.


Property Example: length

The length property returns the length of the <lineSegment>.


Property Example: slope

The slope property returns the slope of the <lineSegment>.