< Previous | Contents | Next >
This Example shows setting colors in a Color Gradient control
-- OnAddToFlow can be used to set parameters and other processing functions when the Tool is add to a comp
function OnAddToFlow() local grad = Gradient()
if InNewTool:GetSource(0).Value >= 0.5 then
-- There is no default attribute for gradients. It’s always black to white.
-- To have a different gradient for new tools, we’ll set one up here but
-- only once. The "NewTool" flag is cleared immediately afterwards so we
-- don’t overwrite gradients when the comp is reopened at a later time.
grad:AddColor(0.0, Pixel({R = 1.0, G = 0, B = 0, A = 1}))
grad:AddColor(0.5, Pixel({R = 0, G = 1.0, B = 0, A = 1}))
grad:AddColor(1.0, Pixel({R = 0, G = 0, B = 1.0, A = 1}))
InGradient:SetSource(grad, 0, 0)
InNewTool:SetSource(Number(0.0), 0, 0)
end
end