Git Product home page Git Product logo

monotween's Introduction

MonoTween

A nifty tween library for MonoGame and XNA.

Usage

Interpolators

Interpolators are generalized smoothing functions from 0 to 1 across a time-step from 0 to 1. They are the building blocks for more complex animations.

Interpolators are easy to define:

class MyInterpolator : IInterpolator
{
    public float Evaluate(float t)
    {
        if (t < 0.5f)
        {
            return 0f;
        }
        else
        {
            return 1f;
        }
    }
}

Interpolators can be easily composed:

var i = new LinearInterpolator().Sequence(a, 0.5f).Average(b);

Interpolators can be built in an ad-hoc manner:

var i = new CustomInterpolator(x => x * x * (3f - 2f * x));

Movements

Movements are predefined transitions between values over time.

A linear movement from 0 to 100, in 3 time-steps:

var m = MovementFactory.CreateMovement(0f, 100f, 3f, new LinearInterpolator());

Movements can be sequenced:

var i = j.Then(k);

Movements can be repeated:

var i = j.Repeat(3);

Movements can be delayed:

var i = j.Wait(3f).Then(k);

Movements can be reversed:

var i = j.Reverse();

Movements can be rewound:

var i = j.ThenReverse();

Movements can be stretched:

var i = j.Stretch(2f); // Takes 2x as long; moves at 1/2 speed

Movements can be blended:

var i = j.Min(k); // Take the minimum of j and k
i = j.Max(k); // Take the maximum of j and k
i = j.Average(k); // Take the mean of j and k
i = j.Add(k); // Take the sum of j and k
i = j.Subtract(k); // Take j minus k
i = j.Blend(k, (x, y) => x * 0.1f + y * 0.9f); // Whatever you like!

monotween's People

Contributors

njlr avatar

Stargazers

Jean-David Moisan avatar Luke Hutscal avatar  avatar

Watchers

James Cloos avatar  avatar

Forkers

randomcrab

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.