Jump to: Board index » General » Fusion

Count up to number expression

Learn about 3D compositing, animation, broadcast design and VFX workflows.
  • Author
  • Message
Offline

acasonj

  • Posts: 38
  • Joined: Wed Jan 23, 2019 4:13 am
  • Location: Australia
  • Real Name: Joshua Acason

Count up to number expression

PostThu Dec 05, 2019 4:19 am

Hi Guys,

My maths isn't great but I'm wondering if someone can help me to count up to a particular number in an easing manner.

So far I have this

Code: Select all
math.floor(17500000+log(time/30))


which eases TO the number but not from, and it doesn't ease from much, only about 8 integers before hand.

If using this method I'd need it to start a lot sooner, preferably from 0, but it might work if it's just an arbitrary number like 40,000 as it'll count so quickly up from there you may not notice.
Builder / Creator
@JoshFromPerth
B.CompSci Ma. Networking
Offline

Okke Verbart

  • Posts: 181
  • Joined: Tue Jan 17, 2017 8:40 pm

Re: Count up to number expression

PostThu Dec 05, 2019 4:51 pm

Not sure if I understand it correctly, but if you mean counting up from say x to y in integers in an easing way in say z frames, 1st thing that comes to mind is using a sine function. For instance, in the below function it counts from 10 to 19 during 90 frames in an easing way:

Code: Select all
floor(10 + 10*(sin(rad(((time*180/90)%180)-90))+1)/2)


It then goes and repeat (but you could change that of course)
www.ablackbirdcalledsue.com
Offline

Okke Verbart

  • Posts: 181
  • Joined: Tue Jan 17, 2017 8:40 pm

Re: Count up to number expression

PostThu Dec 05, 2019 5:27 pm

Just thinking, and I'm unsure if it would fit your purposes, but an easier way even would be to just animate a variable and add an ease via the spline editor. And then basically, in the "final" value, just have a simple expression that applies a floor or ceil to the animated variable.

Quick example:

Code: Select all
{
   Tools = ordered() {
      Text2 = TextPlus {
         CtrlWZoom = false,
         Inputs = {
            Width = Input { Value = 1920, },
            Height = Input { Value = 1080, },
            ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
            Font = Input { Value = "Open Sans", },
            StyledText = Input {
               Value = "50",
               Expression = "floor(basevalue)",
            },
            Style = Input { Value = "Bold", },
            ManualFontKerningPlacement = Input {
               Value = StyledText {
                  Array = {
                  },
                  Value = ""
               },
            },
            basevalue = Input {
               SourceOp = "Text2basevalue",
               Source = "Value",
            },
         },
         ViewInfo = OperatorInfo { Pos = { 825, 247.5 } },
         UserControls = ordered() {
            basevalue = {
               LINKS_Name = "basevalue",
               LINKID_DataType = "Number",
               INPID_InputControl = "SliderControl",
               INP_Integer = false,
               ICS_ControlPage = "Text"
            }
         }
      },
      Text2basevalue = BezierSpline {
         SplineColor = { Red = 20, Green = 92, Blue = 230 },
         NameSet = true,
         KeyFrames = {
            [0] = { 25, RH = { 33.3333333333333, 25 } },
            [100] = { 50, LH = { 66.6666666666667, 50 } }
         }
      }
   },
   ActiveTool = "Text2"
}
www.ablackbirdcalledsue.com
Offline

acasonj

  • Posts: 38
  • Joined: Wed Jan 23, 2019 4:13 am
  • Location: Australia
  • Real Name: Joshua Acason

Re: Count up to number expression

PostFri Dec 06, 2019 5:26 am

You absolute gentleman, thanks very much for the help!
I'll try both of these solutions shortly.

After farrrr too long revisiting high-school maths, I came up with this ->

Code: Select all
math.floor((17.5*(1-exp(-time*0.2)))*100)/100


That reaches 17.5 from 0 with 2 decimal places, albeit with no smooth take off (need a bezier for this) but I can deal with it for now.

I use the number literally, in text, though as you've pointed out, I could animate something with it also - which I may well do, but elsewhere we can use splines and super handy curves for this - I needed to do this programmatically though and I can see loads of use cases for animating things based on an unknown clip-length for example - great for creating re-usable content which I'd like to do. The overhead of making a title per-video sucks at the moment.
Last edited by acasonj on Mon Dec 09, 2019 5:51 am, edited 1 time in total.
Builder / Creator
@JoshFromPerth
B.CompSci Ma. Networking
Offline

Okke Verbart

  • Posts: 181
  • Joined: Tue Jan 17, 2017 8:40 pm

Re: Count up to number expression

PostFri Dec 06, 2019 7:01 am

You may want to check out this:

https://www.steakunderwater.com/wesuckl ... f=6&t=2622

Some incredible work by Eric!
www.ablackbirdcalledsue.com
Offline

acasonj

  • Posts: 38
  • Joined: Wed Jan 23, 2019 4:13 am
  • Location: Australia
  • Real Name: Joshua Acason

Re: Count up to number expression

PostTue Dec 10, 2019 12:54 am

Thanks Okke! That's exactly what I'm after!
I'm away on holiday of the summer here (Perth, Australia) but I'll look into implementing this when I get back. It comes as a script - which I've not dealt with in Resolve before - but the options look awesome - pretty much can use that to animate anything and as you say!
Builder / Creator
@JoshFromPerth
B.CompSci Ma. Networking

Return to Fusion

Who is online

Users browsing this forum: No registered users and 5 guests