Giter VIP home page Giter VIP logo

pyvectortween's Introduction

Vectortween

Some helper classes to generate vector graphics animations with tweening.

This library works wity python 3 only. It depends on the python libraries "pytweening", "numpy", "scipy" and "sympy"

While it can be used in combination with any other library, the examples are made using the libraries "gizeh" and "moviepy".

Documentation is mostly non-existing at the moment, but you can look at the examples to get some inspiration.

Basic concept

An animation is modeled as numbers that evolve over time from a starting point to an end point. Animation specifications do not include start and stop times or durations. These are specified only while realizing the animations. This makes it easy to compose animations into more complex animations.

Example

from vectortween.NumberAnimation import NumberAnimation

n = NumberAnimation(frm=0, to=100, tween=["easeOutBounce"])

for i in range(100):
   print (n.make_frame(frame=i/20, birthframe=0, startframe=0, 
                       stopframe=5, deathframe=5))

Discussion

The simplest animation is a NumberAnimation. The specification says that the animation will produce values between 0 and 100 and that, as the animation progresses towards the end, the numbers will bounce back and forth a bit.

When calling the make_frame method, we must specify a timeline. The animation is automatically stretched to fill the time between startframe and stopframe:

  • frame: the current frame or timestep for which we want to get a NumberAnimation value.
  • birthframe: for frames < birthframe, make_frame returns None (the animation is not yet "alive"). For birthframe <= frame < startframe, the animation returns the initial value.
  • startframe: for startframe <= frame <= stopframe, the animation returns values as specified in the NumberAnimation parameters.
  • stopframe: for stopframe < frame < deathframe, the animation returns the final animation value (the animation remains "alive", but doesn't evolve further).
  • deathframe: for frame >= deathframe, the animation returns None. The animation is "dead".

All frame arguments are floats. So it's perfectly possible to ask (and get, within machine precision) the animated value for frame 3.52634.

Not for real-time usage!

Although I try to get a reasonable performance, performance is not the first concern. The library is not intended for real-time usage. My current interest lies in offline generation/rendering of graphics. The library will happily sacrifice speed for accuracy when faced with the choice. As a result it can be arbitrarily slow (especially with heavy parametric equations).

Examples

I suggest to look at the examples to get an idea of how the different animation types work.

pyvectortween's People

Contributors

shimpe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.