Skip to content
/ bease Public

Bezier curve ease, Newton-Raphson-Iteration, Binary Subdivision

# chkt/bease

Switch branches/tags
Could not load branches
Nothing to show

# Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

## Files

Failed to load latest commit information.
Type
Name
Commit time

## readme.md

#bease

##Install

`\$ npm install bease`

##Use

```import Ease from 'ease/source/BezierEase';
import Interval from 'ease/source/Interval';

const ease = Ease.EaseIn();

const y = ease.yOfX(0.5);

const interval = new Interval(0.0, 60.0, 0.0, 100.0, ease);

const n = interval.nOfT(30.0);```

## BezierEase

Bezier easing curve

### constructor

Creates a new instance

Parameters

• `x0` number The x coordinate of the second control point
• `y0` number The y coordinate of the second control point
• `x1` number The x coordinate of the third control point
• `y1` number The y coordinate of the third control point

### define

Redefines the instance

Parameters

• `x1` number The x coordinate of the second control point
• `y1` number The y coordinate of the second control point
• `x2` number The x coordinate of the third control point
• `y2` number The y coordinate of the third control point

Returns BezierEase

### x1

The x coordinate of the second control point

### y1

The y coordinate of the second control point

### x2

The x coordinate of the third control point

### y2

The y coordinate of the third control point

### xOfT

Returns the x of t p(t) = (1-t)³p0 + 3t(1-t)²p1 + 3t²(1-t)p2 + t³p3 => 3t(1-t)²p1 + 3t²(1-t)p2 + t³ <=> (1-3p2+3p1)t³ + (3p2-6p1)t² + (3p1)t => at³ + bt² + ct

Parameters

• `t` number The time

Returns number

### yOfT

Returns the y of t p(t) = (1-t)³p0 + 3t(1-t)²p1 + 3t²(1-t)p2 + t³p3 => 3t(1-t)²p1 + 3t²(1-t)p2 + t³ <=> (1-3p2+3p1)t³ + (3p2-6p1)t² + (3p1)t => at³ + bt² + ct

Parameters

• `t` number The time

Returns number

### tOfX

Returns the t of x

Parameters

• `x` number The x coordinate

Returns number

### tOfY

Returns the t of y

Parameters

• `y` number The y coordinate

Returns number

### xOfY

Returns the x of y

Parameters

• `y` number The y coordinate

Returns number

### yOfX

Returns the y of x

Parameters

• `x` number The x coordinate

Returns number

### toString

Returns a string representation of the instance

Parameters

• `digits` int? The decimal places (optional, default `3`)

Returns string

### Define

Returns a defined instance

Parameters

• `x1` number The x coordinate of the second control point
• `y1` number The y coordinate of the second control point
• `x2` number The x coordinate of the third control point
• `y2` number The y coordinate of the third control point
• `target` BezierEase? The target instance

Returns BezierEase

### Linear

Returns a instance representing the (0.0,0.0,1.0,1.0) bezier curve

Parameters

• `target` BezierEase? The target instance

Returns BezierEase

### Ease

Returns a instance representing the (0.25,0.1,0.25,1.0) bezier curve

Parameters

• `target` BezierEase? The target instance

Returns BezierEase

### EaseIn

Returns a instance representing the (0.42,0.0,1.0,1.0) bezier curve

Parameters

• `target` BezierEase? The target instance

Returns BezierEase

### EaseOut

Returns a instance representing the (0.0,0.0,0.58,1.0) bezier curve

Parameters

• `target` BezierEase? The target instance

Returns BezierEase

### EaseInOut

Returns a instance representing the (0.42,0.0,0.58,1.0) bezier curve

Parameters

• `target` BezierEase? The target instance

Returns BezierEase

### isEQ

Returns true if a == b, false otherwise

Parameters

Returns boolean

## Interval

Transformation interval

### constructor

Creates a new instance

Parameters

• `t0` number The first interval offset
• `tDelta` number The interval duration
• `n0` number The first interval state
• `nDelta` number The interval magnitude
• `ease` BezierEase The interval easing

### t0

The first interval state

### tDelta

The interval duration

### n0

The first interval state

### nDelta

The interval magnitude

### ease

The interval easing

### define

Redefines the instance

Parameters

• `t0` number The first interval offset
• `tDelta` number The interval duration
• `n0` number The first interval state
• `nDelta` number The interval magnitude
• `ease` BezierEase The interval easing

Returns Interval

### tN

The last interval offset

### nN

The last interval state

### fOfT

Returns the unclamped interval duration fraction

Parameters

• `t` number The time

Returns number

### nOfT

Returns the clamped interval state

Parameters

• `t` number The time

Returns number

### nOfF

Returns the unclamped interval state

Parameters

• `f` number The interval duration fraction

Returns number

### toString

Returns a string representation of the instance

Parameters

• `digits` int? The representation digits (optional, default `3`)

Returns string

### Define

Returns a defined instance

Parameters

• `t0` number The first interval offset
• `tDelta` number The interval duration
• `n0` number The first interval state
• `nDelta` number The interval magnitude
• `ease` BezierEase? The interval easing
• `target` Interval? The target instance

Returns Interval

### Extremes

Returns an instance from interval extremes

Parameters

• `t0` number The first interval offset
• `tN` number The last interval offset
• `n0` number The first interval state
• `nN` number The last interval state
• `ease` BezierEase? The interval easing
• `target` Interval? The target instance

Returns Interval

## About

Bezier curve ease, Newton-Raphson-Iteration, Binary Subdivision

## Releases

No releases published

## Packages 0

No packages published