Flow - Now with Lottie & Animated SVGs - Ship beautiful UI Animations. | Product Hunt Embed


Extension

CAMediaTimingFunction

This extension adds a convenient variables to CAMediaTimingFunction.


Declaration

public extension CAMediaTimingFunction

Overview

This extension defines conveniently accessible variables for standard media timing functions. It also defined a variable for accessing the reversed version of a timing function, as well as its control points.

Topics

Properties

linear

A static definition of the linear timing function.

static let linear = CAMediaTimingFunction(name: CAMediaTimingFunctionName.linear)

easeIn

A static definition of the easeIn timing function.

static let easeIn = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeIn)

easeOut

A static definition of the easeOut timing function.

static let easeOut = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeOut)

easeInEaseOut

A static definition of the easeInEaseOut timing function.

static let easeInEaseOut = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut)

reversed

Returns a new CAMediaTimingFunction with reversed set of control points for the current timing function.

var reversed: CAMediaTimingFunction {
    let (c1, c2) = controlPoints
    let x1 = Float(1 - c2.x)
    let y1 = Float(1 - c2.y)
    let x2 = Float(1 - c1.x)
    let y2 = Float(1 - c1.y)
    return CAMediaTimingFunction(controlPoints: x1, y1, x2, y2)
}

controlPoints

Returns the control points for the current timing function.

var controlPoints: (CGPoint, CGPoint) {
    var c1: [Float] = [0, 0]
    var c2: [Float] = [0, 0]
    getControlPoint(at: 1, values: &c1)
    getControlPoint(at: 2, values: &c2)

    let c1x = CGFloat(c1[0])
    let c1y = CGFloat(c1[1])
    let c2x = CGFloat(c2[0])
    let c2y = CGFloat(c2[1])

    return (CGPoint(x: c1x, y: c1y), CGPoint(x: c2x, y: c2y))
}
background Made with Flow.
underscore Made with Flow.
line2 Made with Flow.
line1 Made with Flow.
circle Made with Flow.
hit Made with Flow.

result(s) found for “”.