Rac. ArcControl

Control that allows the selection of a value with a knob that slides through the section of an Arc.

Uses an Arc as anchor, which defines the position where the control is drawn.

angleDistance defines the section of the anchor arc which is available for user interaction. Within this section the user can slide the control knob to select a value.

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 anchor arc available for user interaction

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 :Rac.Angle

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].

draw()

Draws the current state.

Overrides:

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

Arc produced with affixAnchor when user interaction started

pointerToKnobOffset Rac.Segment

A Segment that represents the offset from pointerCenter to the control knob when user interaction started.

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.

Overrides:
Examples

For a control with a projection range of [100,200]

control.setProjectionRange(100, 200)
control.value = 0;   control.projectionValue() // returns 100
control.value = 0.5; control.projectionValue() // returns 150
control.value = 1;   control.projectionValue() // returns 200

For a control with a projection range of [50,30]

control.setProjectionRange(30, 50)
control.value = 0;   control.projectionValue() // returns 50
control.value = 0.5; control.projectionValue() // returns 40
control.value = 1;   control.projectionValue() // returns 30

setLimitsWithAngleDistanceInsets(startInset, endInset)

Sets both startLimit and endLimit with the given insets from 0 and angleDistance.turn, correspondingly, both projected in the [0, angleDistance.turn] range.

Parameters:
Name Type Description
startInset Rac.Angle | Number

The inset from 0 in the range [0,angleDistance.turn] to use for startLimit

endInset Rac.Angle | Number

The inset from angleDistance.turn in the range [0,angleDistance.turn] to use for endLimit

Example

For an ArcControl with angleDistance of 0.5 turn

let control = new Rac.ArcControl(rac, 0, rac.Angle(0.5))
// sets startLimit as 0.1, since   0 + 0.2 * 0.5 = 0.1
// sets endLimit   as 0.3, since 0.5 - 0.4 * 0.5 = 0.3
control.setLimitsWithAngleDistanceInsets(0.2, 0.4)

setLimitsWithInsets(startInset, endInset)

Sets both startLimit and endLimit with the given insets from 0 and 1, correspondingly.

Overrides:
Parameters:
Name Type Description
startInset Number

The inset from 0 to use for startLimit

endInset Number

The inset from 1 to use for endLimit

Example
control.setLimitsWithInsets(0.1, 0.2)
// returns 0.1, since 0 + 0.1 = 0.1
control.startLimit
// returns 0.8, since 1 - 0.2 = 0.8
control.endLimit

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 affixAnchor when user interaction started