SceneKit+Snapshot.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // SceneKit+Snapshot.h
  3. // FLEX
  4. //
  5. // Created by Tanner Bennett on 1/8/20.
  6. //
  7. #import <SceneKit/SceneKit.h>
  8. #import "FHSViewSnapshot.h"
  9. @class FHSSnapshotNodes;
  10. extern CGFloat const kFHSSmallZOffset;
  11. #pragma mark SCNNode
  12. @interface SCNNode (Snapshot)
  13. /// @return the nearest ancestor snapshot node starting at this node
  14. @property (nonatomic, readonly) SCNNode *nearestAncestorSnapshot;
  15. /// @return a node that renders a highlight overlay over a specified snapshot
  16. + (instancetype)highlight:(FHSViewSnapshot *)view color:(UIColor *)color;
  17. /// @return a node that renders a snapshot image
  18. + (instancetype)snapshot:(FHSViewSnapshot *)view;
  19. /// @return a node that draws a line between two vertices
  20. + (instancetype)lineFrom:(SCNVector3)v1 to:(SCNVector3)v2 color:(UIColor *)lineColor;
  21. /// @return a node that can be used to render a colored border around the specified node
  22. - (instancetype)borderWithColor:(UIColor *)color;
  23. /// @return a node that renders a header above a snapshot node
  24. /// using the title text from the view, if specified
  25. + (instancetype)header:(FHSViewSnapshot *)view;
  26. /// @return a SceneKit node that recursively renders a hierarchy
  27. /// of UI elements starting at the specified snapshot
  28. + (instancetype)snapshot:(FHSViewSnapshot *)view
  29. parent:(FHSViewSnapshot *)parentView
  30. parentNode:(SCNNode *)parentNode
  31. root:(SCNNode *)rootNode
  32. depth:(NSInteger *)depthOut
  33. nodesMap:(NSMutableDictionary<NSString *, FHSSnapshotNodes *> *)nodesMap
  34. hideHeaders:(BOOL)hideHeaders;
  35. @end
  36. #pragma mark SCNShape
  37. @interface SCNShape (Snapshot)
  38. /// @return a shape with the given path, 0 extrusion depth, and a double-sided
  39. /// material with the given diffuse contents inserted at index 0
  40. + (instancetype)shapeWithPath:(UIBezierPath *)path materialDiffuse:(id)contents;
  41. /// @return a shape that is used to render the background of the snapshot header
  42. + (instancetype)nameHeader:(UIColor *)color frame:(CGRect)frame corners:(CGFloat)cornerRadius;
  43. @end
  44. #pragma mark SCNText
  45. @interface SCNText (Snapshot)
  46. /// @return text geometry used to render text inside the snapshot header
  47. + (instancetype)labelGeometry:(NSString *)text font:(UIFont *)font;
  48. @end