Skip to content

Sliders

Syyrion edited this page Apr 9, 2022 · 5 revisions

A description of every slider type class.

Sliders provide a means to control values over time. They can also run functions like timers.

Wave Sliders

Wave sliders control a value as common waveforms. These include sine, sawtooth, square, and triangle waves. All wave sliders contain the common functions listed below. Functions unique to each slider are contained in their own sections

Common Functions

  • Slider[Sine/Sawtooth/Square/Triangle]:new(p, a, y, x, t, fn)
    Creates a new slider with period <p>, amplitude <a>, y-offset <y>, x-offset <x>, timescale <t> and function <fn>.

  • Slider[Sine/Sawtooth/Square/Triangle]:setPeriod(p)
    Sets the period in seconds.

  • Slider[Sine/Sawtooth/Square/Triangle]:getPeriod()
    Gets the period.

  • Slider[Sine/Sawtooth/Square/Triangle]:setAmplitude(a)
    Sets the amplitude. Note that the amplitude is half of the full height of the wave.

  • Slider[Sine/Sawtooth/Square/Triangle]:getAmplitude()
    Gets the amplitude.

  • Slider[Sine/Sawtooth/Square/Triangle]:setYOffset(y)
    Sets the y-offset. This value is directly added to the wave.

  • Slider[Sine/Sawtooth/Square/Triangle]:getYOffset()
    Gets the y-offset.

  • Slider[Sine/Sawtooth/Square/Triangle]:setXOffset(x)
    Sets the phase in seconds relative to the period.

  • Slider[Sine/Sawtooth/Square/Triangle]:getXOffset()
    Gets the phase in seconds relative to the period.

  • Slider[Sine/Sawtooth/Square/Triangle]:setPhase(x)
    Sets the phase in degrees.

  • Slider[Sine/Sawtooth/Square/Triangle]:getPhase()
    Gets the phase in degrees.

  • Slider[Sine/Sawtooth/Square/Triangle]:setRawOffset(x)
    Directly sets the internal phase value. Usually ranges from 0 to 1.

  • Slider[Sine/Sawtooth/Square/Triangle]:getRawOffset()
    Gets the raw phase value.

  • Slider[Sine/Sawtooth/Square/Triangle]:setTimescale(t)
    Sets the timescale. The timescale of a wave slider is allowed to be negative. This causes the slider to run backwards.

  • Slider[Sine/Sawtooth/Square/Triangle]:getTimescale()
    Gets the timescale.

  • Slider[Sine/Sawtooth/Square/Triangle]:setFunction(fn)
    Sets the function. This function is run after every completed period.

  • Slider[Sine/Sawtooth/Square/Triangle]:getFunction()
    Gets the function.

  • Slider[Sine/Sawtooth/Square/Triangle]:setValue(x)
    Sets the slider's value. Mostly useless as the step function takes care of setting this value.

  • Slider[Sine/Sawtooth/Square/Triangle]:getValue()
    Gets the slider's value.

  • Slider[Sine/Sawtooth/Square/Triangle]:advance(mFrameTime, ...)
    Internally advances the slider but does not update its value. Runs the slider's function when necessary.

  • Slider[Sine/Sawtooth/Square/Triangle]:step(mFrameTime, ...)
    Advances and updates the slider's value. Runs the slider's function when necessary.

Square Slider Functions

  • SliderSquare:setDutyCycle(d)
    Sets the duty cycle. Ranges from 0 to 1. Defaults to 0.5. (Desmos graph)

  • SliderSquare:getDutyCycle(d)
    Gets the duty cycle.

Triangle Slider Functions

  • SliderTriangle:setAsymmetry(d)
    Sets the triangle wave's asymmetry. Ranges from 0 to 1. Defaults to 0.5. An asymmetry of 1 is equivalent to sawtooth wave. An asymmetry of 0 is equivalent to a reversed sawtooth wave. (Desmos graph)

  • SliderTriangle:getAsymmetry(d)
    Gets the asymmetry.

Other Sliders

Target Slider

The target slider holds a value until instructed to target a new value. It will interpolate values between its start value and target value within a set period.

  • SliderTarget:new(p, ease, start, t, fn)
    Creates a new slider with period <p>, easing function <ease>, starting value <start>, timescale <t>, and function <fn>.

  • SliderTarget:newTarget(target)
    Starts the slider with target value <target>.

  • SliderTarget:stop()
    Stops the slider. The value remains at its current position.

  • SliderTarget:setPeriod(p)
    Sets the period in seconds. This is the amount of time the slider takes to reach a target value.

  • SliderTarget:getPeriod()
    Gets the period.

  • SliderTarget:setEaseFunction(ease)
    Sets the easing function. This is a function that has a numerical input ranging from 0 to 1 and an output ranging from 0 to 1. This function is used to interpolate values. Defaults to linear easing.

  • SliderTarget:getEaseFunction()
    Gets the easing function.

  • SliderTarget:setTimescale(t)
    Sets the timescale.

  • SliderTarget:getTimescale()
    Gets the timescale.

  • SliderTarget:setFunction(fn)
    Sets the function. This function is run when the slider reaches the target.

  • SliderTarget:getFunction()
    Gets the function.

  • SliderTarget:setValue(x)
    Sets the slider's value. This sets the starting position for the next target event. Also stops any currently running target events.

  • SliderTarget:getValue()
    Gets the slider's value.

  • SliderTarget:advance(mFrameTime, ...)
    Internally advances the slider but does not update its value. Runs the slider's function when necessary.

  • SliderTarget:step(mFrameTime, ...)
    Advances and updates the slider's value. Runs the slider's function when necessary.

Perlin Slider

The perlin slider generates a single octave of perlin noise. Each slider contains its own pseudo-random number generator.

  • SliderPerlin:new(p, a, y, t, s, fn)
    Creates a new slider with period <p>, amplitude <a>, y-offset <y>, timescale <t>, seed <s>, and function <fn>. The seed must be a number within the interval [0, 1).

  • SliderPerlin:setPeriod(p)
    Sets the period in seconds. This is the amount of time between critical points.

  • SliderPerlin:getPeriod()
    Gets the period.

  • SliderPerlin:setAmplitude(a)
    Sets the amplitude. This range in which the perlin noise can generate

  • SliderPerlin:getAmplitude()
    Gets the amplitude.

  • SliderPerlin:setYOffset(y)
    Sets the y-offset. This value is directly added to the wave.

  • SliderPerlin:getYOffset()
    Gets the y-offset.

  • SliderPerlin:setTimescale(t)
    Sets the timescale.

  • SliderPerlin:getTimescale()
    Gets the timescale.

  • SliderPerlin:setFunction(fn)
    Sets the function. This function is run after every completed period.

  • SliderPerlin:getFunction()
    Gets the function.

  • SliderPerlin:setValue(x)
    Sets the slider's value. Mostly useless as the step function takes care of setting this value.

  • SliderPerlin:getValue()
    Gets the slider's value.

  • SliderPerlin:advance(mFrameTime, ...)
    Internally advances the slider but does not update its value. Runs the slider's function when necessary.

  • SliderPerlin:step(mFrameTime, ...)
    Advances and updates the slider's value. Runs the slider's function when necessary.

  • SliderPerlin:randLCG()
    Returns a random value within the interval [0, 1) from the slider's linear congruential generator.

  • SliderPerlin:next()
    Generates the next critical point. Usually only used internally by the slider.

Clone this wiki locally