Skip to content

Commit 45dc330

Browse files
author
Cesar Vargas Casaseca
committed
add extension file
1 parent 702973a commit 45dc330

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

Warhol/Warhol.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
372C82FE24390777005115DB /* CoreGraphicsExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 372C82FD24390777005115DB /* CoreGraphicsExtensions.swift */; };
1011
377F6FFF242CB14C0043BA3C /* ImageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 377F6FFE242CB14C0043BA3C /* ImageViewController.swift */; };
1112
377F70132430FF770043BA3C /* FaceDetector.swift in Sources */ = {isa = PBXBuildFile; fileRef = 377F70122430FF770043BA3C /* FaceDetector.swift */; };
1213
377F7026243395060043BA3C /* UIView+Constraints.swift in Sources */ = {isa = PBXBuildFile; fileRef = 377F7025243395060043BA3C /* UIView+Constraints.swift */; };
@@ -17,7 +18,6 @@
1718
37FE0DF524280BC100B95287 /* Warhol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37FE0DF424280BC100B95287 /* Warhol.swift */; };
1819
37FE0DF724280BF800B95287 /* CameraFaceDetectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37FE0DF624280BF800B95287 /* CameraFaceDetectionViewController.swift */; };
1920
37FE0DFA2428BD5900B95287 /* FaceViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37FE0DF92428BD5900B95287 /* FaceViewModel.swift */; };
20-
37FE0DFD2428C10A00B95287 /* CoreGraphicsExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37FE0DFC2428C10A00B95287 /* CoreGraphicsExtensions.swift */; };
2121
37FE0DFF2428C50500B95287 /* AVCaptureVideoPreviewLayer+Landmarks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37FE0DFE2428C50500B95287 /* AVCaptureVideoPreviewLayer+Landmarks.swift */; };
2222
37FE0E0D2428C8CF00B95287 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37FE0E0C2428C8CF00B95287 /* AppDelegate.swift */; };
2323
37FE0E132428C8D100B95287 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 37FE0E122428C8D100B95287 /* Assets.xcassets */; };
@@ -52,6 +52,7 @@
5252
/* End PBXCopyFilesBuildPhase section */
5353

5454
/* Begin PBXFileReference section */
55+
372C82FD24390777005115DB /* CoreGraphicsExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoreGraphicsExtensions.swift; sourceTree = "<group>"; };
5556
377F6FFE242CB14C0043BA3C /* ImageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageViewController.swift; sourceTree = "<group>"; };
5657
377F70122430FF770043BA3C /* FaceDetector.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FaceDetector.swift; sourceTree = "<group>"; };
5758
377F7025243395060043BA3C /* UIView+Constraints.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+Constraints.swift"; sourceTree = "<group>"; };
@@ -62,7 +63,6 @@
6263
37FE0DF424280BC100B95287 /* Warhol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Warhol.swift; sourceTree = "<group>"; };
6364
37FE0DF624280BF800B95287 /* CameraFaceDetectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CameraFaceDetectionViewController.swift; sourceTree = "<group>"; };
6465
37FE0DF92428BD5900B95287 /* FaceViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FaceViewModel.swift; sourceTree = "<group>"; };
65-
37FE0DFC2428C10A00B95287 /* CoreGraphicsExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CoreGraphicsExtensions.swift; path = ../../../../Tutorials/FaceLasers/final/FaceLasers/Extensions/CoreGraphicsExtensions.swift; sourceTree = "<group>"; };
6666
37FE0DFE2428C50500B95287 /* AVCaptureVideoPreviewLayer+Landmarks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AVCaptureVideoPreviewLayer+Landmarks.swift"; sourceTree = "<group>"; };
6767
37FE0E0A2428C8CF00B95287 /* SampleApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SampleApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
6868
37FE0E0C2428C8CF00B95287 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
@@ -146,7 +146,7 @@
146146
37FE0DFB2428C0E500B95287 /* Extensions */ = {
147147
isa = PBXGroup;
148148
children = (
149-
37FE0DFC2428C10A00B95287 /* CoreGraphicsExtensions.swift */,
149+
372C82FD24390777005115DB /* CoreGraphicsExtensions.swift */,
150150
37FE0DFE2428C50500B95287 /* AVCaptureVideoPreviewLayer+Landmarks.swift */,
151151
377F7025243395060043BA3C /* UIView+Constraints.swift */,
152152
);
@@ -321,10 +321,10 @@
321321
buildActionMask = 2147483647;
322322
files = (
323323
37FE0DF724280BF800B95287 /* CameraFaceDetectionViewController.swift in Sources */,
324-
37FE0DFD2428C10A00B95287 /* CoreGraphicsExtensions.swift in Sources */,
325324
37FE0DFF2428C50500B95287 /* AVCaptureVideoPreviewLayer+Landmarks.swift in Sources */,
326325
377F7026243395060043BA3C /* UIView+Constraints.swift in Sources */,
327326
37FE0DFA2428BD5900B95287 /* FaceViewModel.swift in Sources */,
327+
372C82FE24390777005115DB /* CoreGraphicsExtensions.swift in Sources */,
328328
377F70132430FF770043BA3C /* FaceDetector.swift in Sources */,
329329
37FE0DF524280BC100B95287 /* Warhol.swift in Sources */,
330330
);
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import CoreGraphics
2+
3+
func + (left: CGPoint, right: CGPoint) -> CGPoint {
4+
return CGPoint(x: left.x + right.x, y: left.y + right.y)
5+
}
6+
7+
func - (left: CGPoint, right: CGPoint) -> CGPoint {
8+
return CGPoint(x: left.x - right.x, y: left.y - right.y)
9+
}
10+
11+
func * (left: CGPoint, right: CGFloat) -> CGPoint {
12+
return CGPoint(x: left.x * right, y: left.y * right)
13+
}
14+
15+
extension CGSize {
16+
var cgPoint: CGPoint {
17+
return CGPoint(x: width, y: height)
18+
}
19+
}
20+
21+
extension CGPoint {
22+
var cgSize: CGSize {
23+
return CGSize(width: x, height: y)
24+
}
25+
26+
func absolutePoint(in rect: CGRect) -> CGPoint {
27+
return CGPoint(x: x * rect.size.width, y: y * rect.size.height) + rect.origin
28+
}
29+
}

0 commit comments

Comments
 (0)