Constructor
new RayControl(rac, value, length)
Creates a new RayControl instance with the starting value and the
interactive length.
Parameters:
| Name | Type | Description |
|---|---|---|
rac |
Rac
|
Instance to use for drawing and creating other objects |
value |
number
|
The initial value of the control, in the [0,1] range |
length |
number
|
The length of the |
Extends
Members
(nullable) anchor :Rac.Ray
Ray to which the control will be anchored. Defines the location
where the control is drawn.
Along with length defines the
segment available for user interaction.
The control cannot be drawn or selected until this property is set.
- Default Value:
- null
endLimit :number
Maximum value that can be selected through user interaction.
- Overrides:
- Default Value:
- 1
length :number
Length of the anchor ray available for user interaction.
markers :Array.<number>
Collection of values at which visual markers are drawn.
- Overrides:
- Default Value:
- []
projectionEnd :number
Projected value to use when
value is 1.
- Overrides:
- Default Value:
- 1
projectionStart :number
Projected value to use when
value is 0.
- Overrides:
- Default Value:
- 0
rac :Rac
Instance of Rac used for drawing and passed along to any created
object.
- Overrides:
startLimit :number
Minimum value that can be selected through user interaction.
- Overrides:
- Default Value:
- 0
style :Rac.Stroke|Rac.Fill|Rac.StyleContainer
Style to apply when drawing. This style gets applied after
rac.controller.controlStyle.
- Overrides:
- Default Value:
- null
value :number
Current selected value, in the range [0,1].
May be further constrained to [startLimit,endLimit].
- Overrides:
Methods
addMarkerAtCurrentValue()
Adds a marker at the current value.
- Overrides:
affixAnchor() → {Rac.Segment}
Returns a new Segment produced with the anchor ray with length,
to be persisted during user interaction.
An error is thrown if anchor is not set.
- Overrides:
distance() → {number}
Returns the distance between the anchor ray start and the control
knob.
Equivalent to the control value projected to the range [0,length].
drawSelection(pointerCenter, fixedAnchor, pointerToKnobOffset)
Draws the selection state along with pointer interaction visuals.
- Overrides:
Parameters:
| Name | Type | Description |
|---|---|---|
pointerCenter |
Rac.Point
|
The position of the user pointer |
fixedAnchor |
Rac.Segment
|
|
pointerToKnobOffset |
Rac.Segment
|
A |
isSelected() → {boolean}
Returns true when this control is the currently selected control.
- Overrides:
knob() → (nullable) {Rac.Point}
Returns a Point at the center of the control knob.
When anchor is not set, returns null instead.
- Overrides:
projectedValue() → {number}
Returns value projected into the range
[projectionStart,projectionEnd].
By default the projection range is [0,1], in which case value and
projectedValue() are equal.
Projection ranges with a negative direction (E.g. [50,30], when
projectionStart is greater that projectionEnd) are supported. As
value increases, the projection returned decreases from
projectionStart until reaching projectionEnd.
E.g.
For a control with a projection range of [100,200] + when value is 0, projectionValue() is 100 + when value is 0.5, projectionValue() is 150 + when value is 1, projectionValue() is 200 For a control with a projection range of [50,30] + when value is 0, projectionValue() is 50 + when value is 0.5, projectionValue() is 40 + when value is 1, projectionValue() is 30
- Overrides:
setLimitsWithInsets(startInset, endInset)
Sets both startLimit and endLimit with the given insets from 0
and 1, correspondingly.
E.g.
control.setLimitsWithInsets(0.1, 0.2) // sets startLimit as 0.1 // sets endLimit as 0.8
- Overrides:
Parameters:
| Name | Type | Description |
|---|---|---|
startInset |
number
|
The inset from |
endInset |
number
|
The inset from |
setLimitsWithLengthInsets(startInset, endInset)
Sets both startLimit and endLimit with the given insets from 0
and length, correspondingly, both projected in the [0,length]
range.
E.g.
// For a RayControl with length of 100 control.setLimitsWithLengthInsets(10, 20) // sets startLimit as 0.1 which is at length 10 // sets endLimit as 0.8 which is at length 80 from 100 // 10 inset from 0 = 10 // 20 inset from 100 = 80
Parameters:
| Name | Type | Description |
|---|---|---|
startInset |
number
|
The inset from |
endInset |
number
|
The inset from |
setValueWithLength(lengthValue)
Sets value using the projection of lengthValue in the [0,length]
range.
Parameters:
| Name | Type | Description |
|---|---|---|
lengthValue |
number
|
The length at which to set the current value |
updateWithPointer(pointerKnobCenter, fixedAnchor)
Updates value using pointerKnobCenter in relation to fixedAnchor.
value is always updated by this method to be within [0,1] and
[startLimit,endLimit].
- Overrides:
Parameters:
| Name | Type | Description |
|---|---|---|
pointerKnobCenter |
Rac.Point
|
The position of the knob center as interacted by the user pointer |
fixedAnchor |
Rac.Segment
|
|