Size2f.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. //
  2. // Size2f.h
  3. //
  4. // Created by Giles Payne on 2019/10/06.
  5. //
  6. #pragma once
  7. #ifdef __cplusplus
  8. #import "opencv2/core.hpp"
  9. #else
  10. #define CV_EXPORTS
  11. #endif
  12. @class Point2f;
  13. #import <Foundation/Foundation.h>
  14. NS_ASSUME_NONNULL_BEGIN
  15. /**
  16. * Represents the dimensions of a rectangle the values of which are of type `float`
  17. */
  18. CV_EXPORTS @interface Size2f : NSObject
  19. #pragma mark - Properties
  20. @property float width;
  21. @property float height;
  22. #ifdef __cplusplus
  23. @property(readonly) cv::Size2f& nativeRef;
  24. #endif
  25. #pragma mark - Constructors
  26. - (instancetype)init;
  27. - (instancetype)initWithWidth:(float)width height:(float)height;
  28. - (instancetype)initWithPoint:(Point2f*)point;
  29. - (instancetype)initWithVals:(NSArray<NSNumber*>*)vals;
  30. #ifdef __cplusplus
  31. + (instancetype)fromNative:(cv::Size2f&)size;
  32. #endif
  33. + (instancetype)width:(float)width height:(float)height;
  34. #pragma mark - Methods
  35. /**
  36. * Returns the area of a rectangle with corresponding dimensions
  37. */
  38. - (double)area;
  39. /**
  40. * Determines if a rectangle with corresponding dimensions has area of zero
  41. */
  42. - (BOOL)empty;
  43. /**
  44. * Set the dimensions from the values of an array
  45. * @param vals The array of values from which to set the dimensions
  46. */
  47. - (void)set:(NSArray<NSNumber*>*)vals NS_SWIFT_NAME(set(vals:));
  48. #pragma mark - Common Methods
  49. /**
  50. * Clone object
  51. */
  52. - (Size2f*)clone;
  53. /**
  54. * Compare for equality
  55. * @param other Object to compare
  56. */
  57. - (BOOL)isEqual:(nullable id)object;
  58. /**
  59. * Calculate hash value for this object
  60. */
  61. - (NSUInteger)hash;
  62. /**
  63. * Returns a string that describes the contents of the object
  64. */
  65. - (NSString*)description;
  66. @end
  67. NS_ASSUME_NONNULL_END