Circle winding animation

If you have a design you're proud of, share the cfdg file here. It's also a good place to ask for feedback and collaborate.

Moderators: chris, MtnViewMark, MtnViewJohn

Post Reply
flembobs
Posts: 20
Joined: Tue Oct 09, 2012 3:00 pm

Circle winding animation

Post by flembobs » Thu Feb 07, 2019 3:23 pm

I made a little animation with context free:

https://twitter.com/GoshDarnGames/statu ... 8595888128

Here is the code:

Code: Select all

CF::MaxNatural = 10000000
CF::Time = [time 0 1]

startshape FRAME []

shape FRAME
{
    SQUARE [s 22]
    POLYGON ( 1000, 10, 30 ) [b 1]
}

sine(t,amp,freq,phase) = amp*sin( (freq*360*t) + phase )


path POLYGON ( natural n, number o, number speed )
{
   MOVETO ( o/2, 0 )

   loop i=n []
   {
      t = 1/n*(i+1)
      d = o/2+o*sine ( t, 0.5, ftime()*speed, 0 )
      LINETO ( d*cos (360*t), d*sin (360*t) )
   }

   CLOSEPOLY(CF::Align)

   STROKE () []
}
It would be neat if we could upload videos directly to the gallery. Something like the .webm format would work well.

flembobs
Posts: 20
Joined: Tue Oct 09, 2012 3:00 pm

Re: Circle winding animation

Post by flembobs » Sun Mar 03, 2019 11:11 am

Here's another using a similar technique with more variables:

https://twitter.com/GoshDarnGames/statu ... 8348982279

Code: Select all

startshape RINGS []

CF::Size = [ s 20 ] //Note:  important to set size for looping
CF::Time = [time 0 1]
CF::Background = [ b -1 ]

sine(t,amp,freq,phase) = amp*sin( (freq*360*t) + (360*phase) )


shape RINGS
{
    rings = 8
    n = 1+rings+sine ( ftime(), rings, 6, 0 )

    loop i=n [ r (360/n) ]
    {
        paths = sine ( ftime ()*i, 1, 2, 0 )
        t1 = sine ( ftime(), 8, 1, paths )

        t2 = 0.5+sine ( ftime (), 0.45, 2, (12/n)*i )

        col1 = 0.85+sine ( (1/n)*1, 0.25, 2, 0 )
        col2 = 320+sine ( (1/n)*i , 30, 2, 0)


        CIRCLE [ x t1 s t2 b 1 sat col1 h col2]

    }

}

flembobs
Posts: 20
Joined: Tue Oct 09, 2012 3:00 pm

Re: Circle winding animation

Post by flembobs » Tue Mar 05, 2019 1:32 pm

Here's another animation made with sine waves:

https://twitter.com/GoshDarnGames/statu ... 5580747777

Sine waves are great for making looping animations.

Code: Select all

startshape GRID (1000,1000)[] //( 640, 640 ) []

CF::Time = [time 0 1]
CF::Background = [ b -1 ]
CF::MinimumSize = 0.0001

sine(t,amp,freq,phase) = amp*sin( 360 * (freq*t + phase) )

dist ( n, o ) =  abs ( n - o ) 
inv2 ( n ) = 1/n^2

para ( n, o, p ) = n^2*o+p

st0 = sine ( ftime(), 1, 3, 0.2 )
st1 = sine ( ftime(), 1, 3, 0.5 )
st2 = sine ( ftime(), 1, 2, 0.9 )

shape GRID ( natural n, natural o )
{
    loop i=n []
    {
        si0 = sine ( i/n, 1, 1, 0 )
        si1 = sine ( i/n, 1, 2, 0.2 )
        si2 = sine ( i/n, 1, 3, 0.7 )

        s0 = sine ( (1/n)*i, o/3*si0, 3, ftime() )+st0
        s1 = sine ( (1/n)*i, o/3*si1, 2, ftime() )+st1
        s2 = sine ( (1/n)*i, o/3*si2, 1, ftime() )+st2

        X = i-(n/2)


        loop j=o []
        {
            
            Y = j-(o/2)

            BC = 0.02
            BN = 2/3
            BM = 1.4
            B0 = BN/para ( BC, dist ( Y, s0 )^2, BM ) 
            B1 = BN/para ( BC, dist ( Y, s1 )^2, BM ) 
            B2 = BN/para ( BC, dist ( Y, s2 )^2, BM ) 

            B =  B0+B1+B2
            S =  1.2-(B0+B1+B2)
            H =  st0*st1*st2*si0+190

            SQUARE  [ x X y Y b B sat S hue H]
        }
    }

}

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests