NumberSequence

Overview

Description

NumberSequence is a structure that defines a sequence of numerical key points. It is commonly utilized in animations, effects, and other time-based transitions to represent values that interpolate over time.

Properties

KeyPoints

An array containing all key points within the NumberSequence. Each key point defines a time and a value, where the sequence interpolates between these points.

Code Samples

local sequence = NumberSequence.new(0, 10)
print(sequence.KeyPoints) -- Outputs the key points of the NumberSequence

Constructors

new

Creates a new NumberSequence using a single value. All key points will have the same value.

Parameters

number InValue

The numerical value for the sequence.

Return

NumberSequence

A constructed `NumberSequence` containing the specified value as all key points.

Code Samples

local sequence = NumberSequence.new(5)
-- Creates a sequence with a single value of 5

new

Creates a new NumberSequence using two values. A start and end key point will automatically be created.

Parameters

number InValue0

The value at the start of the sequence.

number InValue1

The value at the end of the sequence.

Return

NumberSequence

A constructed `NumberSequence` with the specified start and end values.

Code Samples

local sequence = NumberSequence.new(0, 10)
-- Creates a sequence with values interpolating from 0 to 10

new

Creates a new NumberSequence using an array of key points. Each key point determines a specific value at a certain time.

Parameters

array InArrayValue

An array of `NumberSequenceKeyPoint` objects representing the desired sequence.

Return

NumberSequence

A constructed `NumberSequence` from the provided array of key points.

Code Samples

local keypoints = {
    NumberSequenceKeyPoint.new(0, 0), -- time: 0, value: 0
    NumberSequenceKeyPoint.new(0.5, 5), -- time: 0.5, value: 5
    NumberSequenceKeyPoint.new(1, 10) -- time: 1, value: 10
}
local sequence = NumberSequence.new(keypoints)
-- Creates a sequence with multiple defined key points

Methods

GetKeyPoints

Retrieves all key points within the NumberSequence.

Parameters

Return

array

An array of `NumberSequenceKeyPoint` objects.

Code Samples

local sequence = NumberSequence.new(0, 10)
local keypoints = sequence:GetKeyPoints()
for _, keypoint in ipairs(keypoints) do
    print(keypoint.Time, keypoint.Value)
end
-- Outputs each key point's time and value

Interpolate

Interpolates the value of the NumberSequence at a specific time.

Parameters

number Time

The time (between 0 and 1) to retrieve the interpolated value.

Return

number

The interpolated value at the specified time.

Code Samples

local sequence = NumberSequence.new(0, 10)
local value = sequence:Interpolate(0.5)
print(value) -- Outputs 5, as it's halfway between 0 and 10

Last updated