ColorSequence 데이터 유형은 색상 값의 그라데이션을 나타냅니다 0 에서 1 까지.색상 값은 ColorSequenceKeypoint 입력사용하여 표현됩니다.이 유형은 ParticleEmitter , Trail , Beam 및 색상 그라데이션을 사용하는 다른 개체에서 다양한 속성에서 사용됩니다.
평등
두 개의 개체는 비슷한 그라데이션이 발생할 경우에도 해당 값이 동일한 경우에만 동일합니다.
평가
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
요약
속성
순서대로 ColorSequenceKeypoint 값의 배열.