GithubHelp home page GithubHelp logo

eyeem / shnunitbezier Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shnhrrsn/shnunitbezier

0.0 11.0 0.0 86 KB

C based Unit Bezier solver/interpolator ported from WebKit for use on iOS and OS X

License: GNU General Public License v2.0

C 91.06% Ruby 8.94%

shnunitbezier's Introduction

SHNUnitBezier

C based Unit Bezier solver/interpolator ported from WebKit for use on iOS/OS X

Usage

// Setup some predefined values
const double from = 0.0;
const double to = 10.0;

double duration = 1.0;
double time = 0.3;

double current;

// Using predefined bezier curves:
current = SHNUnitBezierInterpolate(SHNUnitBezierEaseInOut, time / duration, duration, from, to);
NSLog(@"Ease in/out: %.03f", current); // Ease in/out: 1.872

current = SHNUnitBezierInterpolate(SHNUnitBezierEaseIn, time / duration, duration, from, to);
NSLog(@"Ease in: %.03f", current); // Ease in: 1.290

current = SHNUnitBezierInterpolate(SHNUnitBezierEaseOut, time / duration, duration, from, to);
NSLog(@"Ease out: %.03f", current); // Ease out: 4.460

// Using a linear curve:
current = SHNUnitBezierInterpolate(SHNUnitBezierLinear, time / duration, duration, from, to);
NSLog(@"Linear: %.03f", current); // Linear: 3.047

// Or, using a custom bezier curve:
current = SHNUnitBezierInterpolate(SHNUnitBezierMake(0.4, 0.01, 0.16, 1.0), time / duration, duration, from, to);
NSLog(@"Custom: %.03f", current); // Custom: 3.992

License

GNU General Public License (inherited from WebKit)

shnunitbezier's People

Contributors

shnhrrsn avatar

Watchers

 avatar Markus Spiering avatar Rino Montiel avatar Jonathan Crooke avatar  avatar James Cloos avatar Isac Petruzzi avatar  avatar Miruna Popa 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.