Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

Commit

Permalink
Add a linear curve constant. (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
jverkoey committed Nov 2, 2017
1 parent f5a7f3b commit 0aa4f8c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/MDMMotionCurve.h
Expand Up @@ -141,6 +141,11 @@ typedef NS_ENUM(NSUInteger, MDMSpringMotionCurveDataIndex) {
friction } \
}

/**
A linear bezier motion curve.
*/
#define MDMLinearMotionCurve _MDMBezier(0, 0, 1, 1)

/**
Timing information for an iOS modal presentation slide animation.
*/
Expand Down
19 changes: 19 additions & 0 deletions tests/unit/MDMMotionCurveTests.m
Expand Up @@ -23,6 +23,25 @@ @interface MDMMotionCurveTests : XCTestCase

@implementation MDMMotionCurveTests

- (void)testLinearCurveConstantMatchesSystemLinearCurve {
MDMMotionCurve curve = MDMLinearMotionCurve;
CAMediaTimingFunction *linearTimingFunction =
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
MDMMotionCurve systemLinearCurve = MDMMotionCurveFromTimingFunction(linearTimingFunction);
XCTAssertEqualWithAccuracy(curve.data[MDMBezierMotionCurveDataIndexP1X],
systemLinearCurve.data[MDMBezierMotionCurveDataIndexP1X],
0.001);
XCTAssertEqualWithAccuracy(curve.data[MDMBezierMotionCurveDataIndexP1Y],
systemLinearCurve.data[MDMBezierMotionCurveDataIndexP1Y],
0.001);
XCTAssertEqualWithAccuracy(curve.data[MDMBezierMotionCurveDataIndexP2X],
systemLinearCurve.data[MDMBezierMotionCurveDataIndexP2X],
0.001);
XCTAssertEqualWithAccuracy(curve.data[MDMBezierMotionCurveDataIndexP2Y],
systemLinearCurve.data[MDMBezierMotionCurveDataIndexP2Y],
0.001);
}

- (void)testBezierCurveData {
MDMMotionCurve curve = MDMMotionCurveMakeBezier(0.1f, 0.2f, 0.3f, 0.4f);
XCTAssertEqualWithAccuracy(curve.data[MDMBezierMotionCurveDataIndexP1X], 0.1, 0.001);
Expand Down

0 comments on commit 0aa4f8c

Please sign in to comment.