Whoops! The square brackets were meant to indicate that that was something that should be replaced in its entirety. My bad; I didn't explain that.
Try (cos((time*2*pi)/5))/2+0.5
You should get a 5-frame cycle.
To take it a step beyond, what I sometimes do is add a User Control to the tool that holds the variable. Suppose I used the Edit Controls feature to the node some new sliders called Duration, Min and Max (the latter two for defining the highest and lowest values of the cycle). Then the expression would look like this:
((cos((time*2*pi)/Duration))/2+0.5)*(Max-Min)+Min
So for instance, if we want a cycle that goes from 0.2 to 0.75, we get the normalized cycle as originally demonstrated, then we need to compress it to the value range—going from 0.2 to 0.75 is a range of 0.55, which we get by subtracting our desired Minimum from the desired Maximum. The number is now cycling from 0.0 to 0.55. Then we add Min to shift it all to where we want it.
Here's an example (the new controls are on the User page):
- Code: Select all
{
Tools = ordered() {
Background1 = Background {
CtrlWZoom = false,
Inputs = {
Width = Input { Value = 1920, },
Height = Input { Value = 1080, },
["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
TopLeftRed = Input { Value = 0.638, },
},
ViewInfo = OperatorInfo { Pos = { 158.667, 44.9394 } },
},
BrightnessContrast1 = BrightnessContrast {
Inputs = {
Alpha = Input { Value = 1, },
Gain = Input {
Value = 0.0954915028125213,
Expression = "((cos((time*2*pi)/Duration))/2+0.5)*(Max-Min)+Min ",
},
Input = Input {
SourceOp = "Background1",
Source = "Output",
},
},
ViewInfo = OperatorInfo { Pos = { 277.333, 49.1818 } },
UserControls = ordered() {
Duration = {
LINKS_Name = "Duration",
LINKID_DataType = "Number",
INPID_InputControl = "SliderControl",
INP_Default = 10,
INP_Integer = false,
INP_MinScale = 0.100000001490116,
INP_MaxScale = 60,
INP_MinAllowed = 9.99999974737875e-06,
INP_MaxAllowed = 1000000,
},
Min = {
LINKS_Name = "Min",
LINKID_DataType = "Number",
INPID_InputControl = "SliderControl",
INP_Default = 0,
INP_Integer = false,
INP_MinScale = 0,
INP_MaxScale = 1,
INP_MinAllowed = -1000000,
INP_MaxAllowed = 1000000,
},
Max = {
LINKS_Name = "Max",
LINKID_DataType = "Number",
INPID_InputControl = "SliderControl",
INP_Default = 1,
INP_Integer = false,
INP_MinScale = 0,
INP_MaxScale = 1,
INP_MinAllowed = -1000000,
INP_MaxAllowed = 1000000,
}
}
}
}
}
Oh, and one more thing: Putting the expression on Alpha alone in the Background tool probably wouldn't do what you want—it would only fade out that one channel, but RGB would remain. If you want the image to vanish entirely you'd also need to use an AlphaMultiply to multiply the RGB by A.