Class: Dial

Dial()

new Dial()

The Dial class makes a circular interactive element that can be turned up or down by moving a marker round.

Methods

draw()

Draws the dial on the canvas.

pair(toneObj, toneObjProperty)

Pairs a dial with a Tone.js object and its property.

Parameters:
Name Type Description
toneObj Object

The Tone.js object to pair the dial with.

toneObjProperty string

The property of the Tone.js object to pair the dial with.

set_pair_val()

Method to set the value of a property on a Tone.js object based on the value of the dial.

set_val()

Map mouse position to dial value

This method maps the mouse position relative to the dial to a value between min and max properties. The value is also rounded to the nearest step if a step has been provided in the dial constructor. The value is stored in the val property and if a Tone.js object property has been paired with this dial, the value is also updated on the paired Tone.js object property.

toggle_moving()

Toggles the moving state of the dial.

touch_check() → {boolean}

Determines whether the current mouse position is within the radius of the dial's center point.

Returns:
  • True if the mouse position is within the dial's radius; false otherwise.
Type
boolean

Dial(_sketch, _id, _x, _y, _radius, _minopt, _maxopt, _valopt, _stepopt)

new Dial(_sketch, _id, _x, _y, _radius, _minopt, _maxopt, _valopt, _stepopt)

Constructor for the Dial class, representing a dial in a sketch.

Parameters:
Name Type Attributes Default Description
_sketch p5

The p5 instance that creates the dial.

_id number

A unique identifier for the dial.

_x number

The x-coordinate of the center of the dial.

_y number

The y-coordinate of the center of the dial.

_radius number

The radius of the dial.

_min number <optional>
0

The minimum value of the dial.

_max number <optional>
1

The maximum value of the dial.

_val number <optional>
0.5

The starting value of the dial.

_step number <optional>
null

The step size of the dial.

Methods

draw()

Draws the dial on the canvas.

pair(toneObj, toneObjProperty)

Pairs a dial with a Tone.js object and its property.

Parameters:
Name Type Description
toneObj Object

The Tone.js object to pair the dial with.

toneObjProperty string

The property of the Tone.js object to pair the dial with.

set_pair_val()

Method to set the value of a property on a Tone.js object based on the value of the dial.

set_val()

Map mouse position to dial value

This method maps the mouse position relative to the dial to a value between min and max properties. The value is also rounded to the nearest step if a step has been provided in the dial constructor. The value is stored in the val property and if a Tone.js object property has been paired with this dial, the value is also updated on the paired Tone.js object property.

toggle_moving()

Toggles the moving state of the dial.

touch_check() → {boolean}

Determines whether the current mouse position is within the radius of the dial's center point.

Returns:
  • True if the mouse position is within the dial's radius; false otherwise.
Type
boolean