Skip to content

About

Simple view modifier to warp perspective of any SwiftUI view.

Resources

Stars

55 stars

Watchers

1 watching

Forks

Latest commit

 

History

12 Commits

Folders and files

Repository files navigation

Perspective

Simple view modifier to warp perspective of any SwiftUI view.

High performance, real-time distortion filter powered by Metal.

Platforms

  • iOS 17.0+
  • macOS 14.0+
  • tvOS 17.0+

Usage

You can use warpPerspectiveEffect(topLeftPoint:bottomLeftPoint:bottomRightPoint:topRightPoint:) on any SwiftUI view.

@State private var topLeft: CGPoint = CGPoint(x: 0, y: 0)
@State private var bottomLeft: CGPoint = CGPoint(x: 0, y: 1)
@State private var bottomRight: CGPoint = CGPoint(x: 1, y: 1)
@State private var topRight: CGPoint = CGPoint(x: 1, y: 0)

ContentView()
    .warpPerspectiveEffect(
        topLeftPoint: topLeft,
        bottomLeftPoint: bottomLeft,
        bottomRightPoint: bottomRight,
        topRightPoint: topRight
    )

It can also be used as an image filter, equivalent to CIPerspectiveCorrection from Core Image.

Here is an example:

Credits

The calculation part of this package uses the algorithm from:

Credits has been included in the source file.

About

Simple view modifier to warp perspective of any SwiftUI view.

Resources

Stars

55 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages