ColorSequence
*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。
ColorSequence データタイプは、0 から 1 の色値のグラデーションを表示します。色値は ColorSequenceKeypoint タイプを使用して表現されます。このタイプは、ParticleEmitter 、Trail 、Beam 、および色グラデーションを使用する他のオブジェクトで使用されます。
平等
2つの ColorSequence オブジェクトは、両方とも似たグラデーションになる場合でも、それらの ColorSequenceKeypoint の値が同等である場合にのみ同等です。
評価
ColorSequence タイプには、特定の時点/場所で値を取得する内蔵メソッドがありません。ただし、特定の時間に評価するために次の機能を使用できます。
local function evalColorSequence(sequence: ColorSequence, time: number)
-- 時間が 0 または 1 の場合、それぞれ最初または最後の値を返す
if time == 0 then
return sequence.Keypoints[1].Value
elseif time == 1 then
return sequence.Keypoints[#sequence.Keypoints].Value
end
-- そうでない場合、各シーケンシャルペアのキーポイントを通過する
for i = 1, #sequence.Keypoints - 1 do
local thisKeypoint = sequence.Keypoints[i]
local nextKeypoint = sequence.Keypoints[i + 1]
if time >= thisKeypoint.Time and time < nextKeypoint.Time then
-- ポイント間のアルファの距離を計算する
local alpha = (time - thisKeypoint.Time) / (nextKeypoint.Time - thisKeypoint.Time)
-- アルファを使用して、ポイント間の実際の値を評価する
return Color3.new(
(nextKeypoint.Value.R - thisKeypoint.Value.R) * alpha + thisKeypoint.Value.R,
(nextKeypoint.Value.G - thisKeypoint.Value.G) * alpha + thisKeypoint.Value.G,
(nextKeypoint.Value.B - thisKeypoint.Value.B) * alpha + thisKeypoint.Value.B
)
end
end
end
local colorSequence = ColorSequence.new{
ColorSequenceKeypoint.new(0, Color3.fromRGB(255, 0, 0)),
ColorSequenceKeypoint.new(0.5, Color3.fromRGB(0, 190, 200)),
ColorSequenceKeypoint.new(1, Color3.fromRGB(190, 0, 255))
}
print(evalColorSequence(colorSequence, 0.75)) --> 0.372549, 0.372549, 0.892157
概要
コンストラクタ
指定された色全体の新しい ColorSequence を返す
新しい ColorSequence を返し、開始値として c0 、終了値として c1 を返します。
配列の ColorSequence から新しい ColorSequenceKeypoints を返します。
プロパティ
上昇順の ColorSequenceKeypoint 値の配列。
コンストラクタ
new
開始値と終了値の両方に c を含む 2つのキーポイントのシーケンスを返します。
local colorSequence = ColorSequence.new(c)-- 同等のlocal colorSequence = ColorSequence.new{ColorSequenceKeypoint.new(0, c),ColorSequenceKeypoint.new(1, c)}
パラメータ
new
新しい ColorSequence を返し、開始値として c0 、終了値として c1 を返します。
local colorSequence = ColorSequence.new(c0, c1)-- 同等のlocal colorSequence = ColorSequence.new{ColorSequenceKeypoint.new(0, c0),ColorSequenceKeypoint.new(1, c1)}
new
配列の ColorSequence から新しい ColorSequenceKeypoints を返します。キーポイントは、非順次の時間値順序でなければなりません。少なくとも 2つのキーポイントが提供されなければならず、時間値は 0 (最初) と 1 (最後) がある必要があります。
local red = Color3.fromRGB(255, 0, 0)local cyan = Color3.fromRGB(0, 190, 200)local purple = Color3.fromRGB(190, 0, 255)local colorSequence = ColorSequence.new{ColorSequenceKeypoint.new(0, red),ColorSequenceKeypoint.new(0.5, cyan),ColorSequenceKeypoint.new(1, purple)}