mirror of
https://github.com/zhigang1992/PerspectiveTransform.git
synced 2026-01-12 22:49:33 +08:00
add heredoc to perspective
This commit is contained in:
@@ -7,16 +7,40 @@
|
||||
//
|
||||
|
||||
public extension Perspective {
|
||||
/**
|
||||
Create Perspective based on 4 points
|
||||
|
||||
- parameter topLeft: top left corner
|
||||
- parameter topRight: top right corner
|
||||
- parameter bottomLeft: bottom left corner
|
||||
- parameter bottomRight: bottom right corner
|
||||
*/
|
||||
public convenience init(_ topLeft:CGPoint, _ topRight:CGPoint, _ bottomLeft:CGPoint, _ bottomRight:CGPoint) {
|
||||
self.init(Quadrilateral(topLeft, topRight, bottomLeft, bottomRight))
|
||||
}
|
||||
/**
|
||||
Create Perspective based on 4 points
|
||||
|
||||
- parameter points: corner points, must be size 4
|
||||
*/
|
||||
public convenience init(_ points:[CGPoint]) {
|
||||
self.init(Quadrilateral(points))
|
||||
}
|
||||
/**
|
||||
Create Perspective based on 4 corners of the rectangle
|
||||
|
||||
- parameter rect: defines the corners
|
||||
*/
|
||||
public convenience init(_ rect:CGRect) {
|
||||
self.init(Quadrilateral(rect))
|
||||
}
|
||||
|
||||
/**
|
||||
Calculate CATransform3D to another perspective
|
||||
|
||||
- parameter destination: perspective to transform to
|
||||
- returns: tranformation matrix from this perspective to destination
|
||||
*/
|
||||
public func projectiveTransform(destination:Perspective) -> CATransform3D {
|
||||
return CATransform3D(projection(to: destination).to3d())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user