Constructor
new ArcControl(rac, value, angleDistance)
Creates a new ArcControl
instance with the starting value
and the
interactive angleDistance
.
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 |
angleDistance |
Rac.Angle
|
The angleDistance of the |
Extends
Members
(nullable) anchor :Rac.Arc
Arc
to which the control will be anchored. Defines the location
where the control is drawn.
Along with angleDistance
defines the section available for user interaction.
The control cannot be drawn or selected until this property is set.
- Default Value:
- null
angleDistance :number
Angle distance of the anchor
arc available for user interaction.
endLimit :number
Maximum value
that can be selected through user interaction.
- Overrides:
- Default Value:
- 1
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.Arc}
Returns a new Arc
produced with the anchor
arc with
angleDistance
, to be persisted during user interaction.
An error is thrown if anchor
is not set.
- Overrides:
distance() → {Rac.Angle}
Returns the angle distance
between the
anchor
arc start
and the control knob.
The turn
of the returned Angle
is equivalent to the control value
projected to the range [0,angleDistance.turn]
.
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.Arc
|
|
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:
setLimitsWithAngleDistanceInsets(startInset, endInset)
Sets both startLimit
and endLimit
with the given insets from 0
and endInset.turn
, correspondingly, both projected in the
[0,angleDistance.turn]
range.
E.g.
// For an ArcControl with angle distance of 0.5 turn control.setLimitsWithAngleDistanceInsets(0.1, 0.3) // sets startLimit as 0.2 which is at angle distance 0.1 // sets endLimit as 0.4 which is at angle distance 0.2 // 0.1 inset from 0 = 0.1 // 0.3 inset from 0.5 = 0.2
Parameters:
Name | Type | Description |
---|---|---|
startInset |
Rac.Angle
|
number
|
The inset from |
endInset |
Rac.Angle
|
number
|
The inset from |
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 |
setValueWithAngleDistance(valueAngleDistance)
Sets value
using the projection of valueAngleDistance.turn
in the
[0,angleLength.turn]
range.
Parameters:
Name | Type | Description |
---|---|---|
valueAngleDistance |
Rac.Angle
|
number
|
The angle distance 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.Arc
|
Anchor produced with |