I would like to make an effect that would give the impression that a snake is wrapped around the syllables and that it progresses as the color of the syllable changes, like the one below:

So I used the Bezier function of pyointa2001 (thanks to him by the way) which I modify to obtain this:

But there are several problems :

- the curve does not start well at the edge of the video

- at the beginning the curve is not well "curve"

- but above all, at the end, the effect does not stop at the end of the syllable

Could someone please help me.

Below the code I used an modified:

- Code: Select all
`function Bezier_Move(s_time,e_time,aftimg_dur,x_blur,y_blur,acl,...) a = {...} if (j == 1) then t1 = s_time t2 = e_time dur = t2-t1 accel = acl n = #a/2 for i = 1,n*2-1,2 do x[(i+1)/2] = a[i] end for i = 2, n*2,2 do y[i/2] = a[i] end c_t = 0 maxloop(2) f_t = 1/(dur/frame_dur) end afterimage_dur = aftimg_dur if (afterimage_dur < 0 ) then afterimage_dur = 0 end pos_x, pos_y = Bezier(n,x,y,c_t) n_t = c_t + f_t n_x, n_y = Bezier(n,x,y,n_t) dist = math.sqrt(math.abs(n_x-pos_x)^2+math.abs(n_y-pos_y)^2) a_t =f_t*(max_space/dist) if (a_t > f_t) then a_t = f_t end n_t = c_t + a_t if (n_t < 1) then maxj = j + 1 end retime("presyl",t1+dur*(c_t^accel),afterimage_dur) t = c_t c_t = n_t return string.format("\\pos(%f,%f)",pos_x,pos_y) end`

- Code: Select all
`function Bezier(n,x,y,t) p_x = 0 p_y = 0 for i = 1, n, 1 do p_y = p_y + y[i] * set_temp("bern",bernstein(i-1,n-1,t)) p_x = p_x + x[i] * temp.bern end return p_x, p_y end`

- Code: Select all
`function bernstein(i,n,t) return (factk(n) / (factk(i)*factk(n-i))) * (t^i) * ((1-t)^(n-i)) end`

- Code: Select all
`function factk(n) k = 1 if (n > 1) then for i = 2, n, 1 do k = k * i end end return k end`

- Code: Select all
`{!Bezier_Move((syl.i==1) and -500 or -line.kara[syl.i-1].duration,0,line.end_time-line.start_time-syl.start_time+200,math.random(-10,10),math.random(-10,30),1,(syl.i==1) and 0 or recall.xx,(syl.i==1) and $middle/2 or $middle,(syl.i==1) and -10 or $center/2+recall.xx/2,(syl.i==1) and $middle+46 or $middle-((syl.i%2==0) and ($center-recall.xx) or -($center-recall.xx)),$center,$middle)!!remember("xx",$scenter)!!remember("yy",$smiddle)!\fad(0,200)\an5\be1\bord3\3a&HB1&\1a&HB1&\1c&H5ACF72&\3c&H00FFFF&\p1}m 0 0 l 2 0 l 2 2 l 0 2`