FULiveDefine.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. //
  2. // FULiveDefine.h
  3. // FULive
  4. //
  5. // Created by L on 2018/8/1.
  6. // Copyright © 2018年 L. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. #import "UIColor+FU.h"
  10. #import "FURenderKitManager.h"
  11. #pragma mark - 宏
  12. #define FUScreenWidth (CGRectGetWidth([UIScreen mainScreen].bounds))
  13. #define FUScreenHeight (CGRectGetHeight([UIScreen mainScreen].bounds))
  14. /// 状态栏高度
  15. #define FUStatusBarHeight (CGRectGetHeight([UIApplication sharedApplication].statusBarFrame))
  16. #define FUDocumentPath NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject
  17. #define FUColorFromHexString(aHex) [UIColor colorWithHexColorString:aHex]
  18. #define FUColorFromHexStringWithAlpha(aHex, aAlpha) [UIColor colorWithHexColorString:aHex alpha:aAlpha]
  19. #define FUColorFromHex(aHex) [UIColor colorWithHex:aHex]
  20. #define FUColorFromHexWithAlpha(aHex, aAlpha) [UIColor colorWithHex:aHex alpha:aAlpha]
  21. #define FULocalizedString(key) NSLocalizedString(key, nil)
  22. #define FUPicturePixelMaxSize ([FURenderKitManager sharedManager].devicePerformanceLevel == FUDevicePerformanceLevelHigh ? 12746752 : 5760000)
  23. #define FUStickersPath [FUDocumentPath stringByAppendingPathComponent:@"FUStickers"]
  24. #define FUStickerIconsPath [FUDocumentPath stringByAppendingPathComponent:@"FUStickerIcons"]
  25. #define FUStickerBundlesPath [FUDocumentPath stringByAppendingPathComponent:@"FUStickerBundles"]
  26. #pragma mark - 枚举
  27. /// 特效模块分组
  28. typedef NS_ENUM(NSUInteger, FUGroup) {
  29. FUGroupFace = 0,
  30. FUGroupBody,
  31. FUGroupContentService
  32. };
  33. /// 特效模块
  34. typedef NS_ENUM(NSUInteger, FUModule) {
  35. FUModuleBeauty = 0,
  36. FUModuleMakeup,
  37. FUModuleStyle,
  38. FUModuleSticker,
  39. FUModuleAnimoji,
  40. FUModuleHairBeauty,
  41. FUModuleLightMakeup,
  42. FUModuleARMask,
  43. FUModuleHilarious,
  44. FUModuleFaceFusion,
  45. FUModuleExpressionRecognition,
  46. FUModuleMusicFilter,
  47. FUModuleDistortingMirror,
  48. FUModuleBodyBeauty,
  49. FUModuleBodyAvatar,
  50. FUModuleSegmentation,
  51. FUModuleGestureRecognition,
  52. FUModuleGreenScreen,
  53. FUModuleQualityTicker
  54. };
  55. /// AI模型分类
  56. typedef NS_OPTIONS(NSUInteger, FUAIModelType) {
  57. FUAIModelTypeFace = 1 << 0, // 人脸
  58. FUAIModelTypeHuman = 1 << 1, // 人体
  59. FUAIModelTypeHand = 1 << 2 // 手势
  60. };
  61. /// 跟踪部位
  62. typedef NS_ENUM(NSInteger, FUDetectingParts) {
  63. FUDetectingPartsFace = 0, // 人脸
  64. FUDetectingPartsHuman, // 人体
  65. FUDetectingPartsHand, // 手势
  66. FUDetectingPartsNone // 不需要跟踪
  67. };
  68. /// 子妆容类型
  69. typedef NS_ENUM(NSUInteger, FUSingleMakeupType) {
  70. FUSingleMakeupTypeFoundation, // 粉底
  71. FUSingleMakeupTypeLip, // 口红
  72. FUSingleMakeupTypeBlusher, // 腮红
  73. FUSingleMakeupTypeEyebrow, // 眉毛
  74. FUSingleMakeupTypeEyeshadow, // 眼影
  75. FUSingleMakeupTypeEyeliner, // 眼线
  76. FUSingleMakeupTypeEyelash, // 睫毛
  77. FUSingleMakeupTypeHighlight, // 高光
  78. FUSingleMakeupTypeShadow, // 阴影
  79. FUSingleMakeupTypePupil // 美瞳
  80. };
  81. #pragma mark - 内联函数
  82. static inline BOOL FUDeviceIsiPhoneXStyle() {
  83. UIWindow *keyWindow = [UIApplication sharedApplication].delegate.window;
  84. if (@available(iOS 11.0, *)) {
  85. CGFloat bottomInsets = keyWindow.safeAreaInsets.bottom;
  86. if (bottomInsets > 0) {
  87. return YES;
  88. }
  89. }
  90. return NO;
  91. }
  92. static inline CGFloat FUHeightIncludeBottomSafeArea(CGFloat height) {
  93. if (@available(iOS 11.0, *)) {
  94. height += [UIApplication sharedApplication].delegate.window.safeAreaInsets.bottom;
  95. }
  96. return height;
  97. }
  98. static inline CGFloat FUHeightIncludeTopSafeArea(CGFloat height) {
  99. if (@available(iOS 11.0, *)) {
  100. height += [UIApplication sharedApplication].delegate.window.safeAreaInsets.top;
  101. }
  102. return height;
  103. }
  104. static inline NSString * FUCurrentDateString() {
  105. NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
  106. formatter.dateFormat = @"YYYYMMddhhmmssSS";
  107. NSDate *date = [NSDate date];
  108. NSString *dateString = [formatter stringFromDate:date];
  109. return dateString;
  110. }