Jump to: Board index » General » Fusion

How do you create a counter over 5s running from 0 to n that

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

Artenis

  • Posts: 5
  • Joined: Thu Apr 04, 2024 3:32 pm
  • Real Name: Raphael KUHN

How do you create a counter over 5s running from 0 to n that

PostWed May 08, 2024 4:40 pm

Tille :
How do you create a counter over 5s running from 0 to n that stops and the final number is displayed until the end of the animation?

Hi,
I found lot of example to create a counter using text+ and expression but I'm looking for a specific version.

For a sport challenge I want to create a counter for number of repetition .
To the start of the animation until specific time (e.g: 5s) I must display a counter to 0 until 50.
Until number 50 is reached it must freeze until the end of animation.

If you can help me, thanks, If not, can you give me some links on how to do it?
I have no idea how to use the expression with the animation parameters.

I have these examples.

1) floor(time^2*40/comp.RenderEnd^2)

2)
: -- setup
startValue = 0;
endValue = 50;
thousandsSeperator = "."
prefix = " "
postfix = " Reps"
-- setup end
number = startValue + (endValue-startValue)*(time/comp.RenderEnd)
delimited = (string.format('%d', number)):reverse():gsub("(%d%d%d)","%1" .. thousandsSeperator):gsub(",(%-?)$","%1"):reverse()
return(prefix .. delimited .. postfix)

that's not what I want because the counter use all animation time and I have no control about the duration of the event.
Offline

Sander de Regt

  • Posts: 3637
  • Joined: Thu Nov 13, 2014 10:09 pm

Re: How do you create a counter over 5s running from 0 to n

PostWed May 08, 2024 6:55 pm

I think I've seen a question similar to this one before here on the forum.
I suggest you search for 'counter' in the archive and see if it comes up.

This is one of the first ones that I found. Maybe it's of use to you

viewtopic.php?f=22&t=159604&hilit=counter
Sander de Regt

ShadowMaker SdR
The Netherlands
Offline

Max Seredkin

  • Posts: 47
  • Joined: Sat Jul 29, 2017 11:00 am

Re: How do you create a counter over 5s running from 0 to n

PostWed May 08, 2024 9:04 pm

I think it's easier this way

Code: Select all
{
   Tools = ordered() {
      Text1 = TextPlus {
         CtrlWZoom = false,
         Inputs = {
            Width = Input { Value = 2048, },
            Height = Input { Value = 1080, },
            ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
            StyledText = Input { Expression = "math.floor(Background1.TopLeftRed)", },
            Font = Input { Value = "Open Sans", },
            Style = Input { Value = "Bold", },
            VerticalJustificationNew = Input { Value = 3, },
            HorizontalLeftCenterRight = Input { Value = -1, },
            HorizontalJustificationNew = Input { Value = 3, },
         },
         ViewInfo = OperatorInfo { Pos = { 1100, 49.5 } },
      },
      Background1 = Background {
         CtrlWZoom = false,
         Inputs = {
            Width = Input { Value = 2048, },
            Height = Input { Value = 1080, },
            ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
            TopLeftRed = Input {
               SourceOp = "Background1TopLeftRed",
               Source = "Value",
            },
         },
         ViewInfo = OperatorInfo { Pos = { 1100, 115.5 } },
      },
      Background1TopLeftRed = BezierSpline {
         SplineColor = { Red = 255, Green = 0, Blue = 0 },
         CtrlWZoom = false,
         NameSet = true,
         KeyFrames = {
            [0] = { 0, RH = { 49.6666666666667, 3333.33333333333 }, Flags = { Linear = true } },
            [149] = { 10000, LH = { 99.3333333333333, 6666.66666666667 }, Flags = { Linear = true } }
         }
      },
      Underlay1 = Underlay {
         ViewInfo = UnderlayInfo {
            Pos = { 1100, 49.5 },
            Size = { 172, 167.818 }
         },
      }
   }
}
Behance https://www.behance.net/max_seredkin
Vimeo https://vimeo.com/user66756392
https://www.mrpost.ru/en
Offline

Artenis

  • Posts: 5
  • Joined: Thu Apr 04, 2024 3:32 pm
  • Real Name: Raphael KUHN

Re: How do you create a counter over 5s running from 0 to n

PostWed May 08, 2024 10:37 pm

Thanks you Sander de Regt for finding this answer for me!

Knowing what question to ask is the hardest part. I'll try to look harder next time.

I'm learning Lua code but for the moment I can't figure out `time` function and use it with Lua conditions.
Where can I learn LUA for Davinci ?

This script looks very good but I can't find a solution to reduce or grow the time to reach "n" value!
If I want to reach number 40 in 2s or 6s I don't know if the 'iif' condition can do that or if another condition must be used as 'while' or 'for' .

I tried to use `time/25*2`
n=40;

For me the script looks like this but is incomplete :

Code: Select all
iif(time<0, (0), min(0+time,40))
Offline

Artenis

  • Posts: 5
  • Joined: Thu Apr 04, 2024 3:32 pm
  • Real Name: Raphael KUHN

Re: How do you create a counter over 5s running from 0 to n

PostWed May 08, 2024 10:46 pm

Hi Seredkin,
I'm really new with Davinci LUA and script , where must I used this script ?
Offline

Sander de Regt

  • Posts: 3637
  • Joined: Thu Nov 13, 2014 10:09 pm

Re: How do you create a counter over 5s running from 0 to n

PostThu May 09, 2024 6:28 am

Follow these instructions to get the code into Fusion

Sander de Regt

ShadowMaker SdR
The Netherlands
Offline

birdseye

  • Posts: 376
  • Joined: Fri Jun 12, 2020 2:36 pm
  • Real Name: Iain Fisher

Re: How do you create a counter over 5s running from 0 to n

PostThu May 09, 2024 8:47 am

There's a link to a video worth saving :D
Offline

Artenis

  • Posts: 5
  • Joined: Thu Apr 04, 2024 3:32 pm
  • Real Name: Raphael KUHN

Re: How do you create a counter over 5s running from 0 to n

PostThu May 09, 2024 3:23 pm

Thanks.

I really need help to understand Lua . Could you suggest me some website or tutorial ?
https://www.tutorialspoint.com/lua doesn't help me much.

Also I can't use variable inside expression despite all the examples on this forum.

I tried that but the variable isn't take in count ( even using colon before variable):
nbs=(25*n);
Code: Select all
 iif( time <= nbs ,min(time,40), 40)


I can't find a simply expression to do that (n = any number) :

"from 0 to 3s count from 0 to n then display n until end of animation"

I also tried that :
Code: Select all
iif( time <= 25*3 ,floor(time/1.875) ,40)

Its count to 40 in 3s (25f/s), but it seems the value of "time" took (25*3) value .
Tutorial and documentation doesn't explain how "iif" statement define and use "time" constant.

Does exist a simply expression to do what I want ?
It could be very useful If I had just to change second and frames properties .

Code: Select all
nb= n ; with (n = any number)
nbs=(25*n);

Is it possible to use a constant other than "time" to count from 0 to 40 ?

I'm thinking of something like this but the association of time with incrementation is missing :

Code: Select all
nb= 3 ; nbs=(25*n);
while time <= nbs
   for i=0 , 40 do
      i++

Return to Fusion

Who is online

Users browsing this forum: KrunoSmithy and 10 guests