RCTBorderDrawing.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. #import <UIKit/UIKit.h>
  8. #import <React/RCTBorderStyle.h>
  9. #import <React/RCTDefines.h>
  10. typedef struct {
  11. CGFloat topLeft;
  12. CGFloat topRight;
  13. CGFloat bottomLeft;
  14. CGFloat bottomRight;
  15. } RCTCornerRadii;
  16. typedef struct {
  17. CGSize topLeft;
  18. CGSize topRight;
  19. CGSize bottomLeft;
  20. CGSize bottomRight;
  21. } RCTCornerInsets;
  22. typedef struct {
  23. CGColorRef top;
  24. CGColorRef left;
  25. CGColorRef bottom;
  26. CGColorRef right;
  27. } RCTBorderColors;
  28. /**
  29. * Determine if the border widths, colors and radii are all equal.
  30. */
  31. RCT_EXTERN BOOL RCTBorderInsetsAreEqual(UIEdgeInsets borderInsets);
  32. RCT_EXTERN BOOL RCTCornerRadiiAreEqual(RCTCornerRadii cornerRadii);
  33. RCT_EXTERN BOOL RCTBorderColorsAreEqual(RCTBorderColors borderColors);
  34. /**
  35. * Convert RCTCornerRadii to RCTCornerInsets by applying border insets.
  36. * Effectively, returns radius - inset, with a lower bound of 0.0.
  37. */
  38. RCT_EXTERN RCTCornerInsets RCTGetCornerInsets(RCTCornerRadii cornerRadii, UIEdgeInsets borderInsets);
  39. /**
  40. * Create a CGPath representing a rounded rectangle with the specified bounds
  41. * and corner insets. Note that the CGPathRef must be released by the caller.
  42. */
  43. RCT_EXTERN CGPathRef
  44. RCTPathCreateWithRoundedRect(CGRect bounds, RCTCornerInsets cornerInsets, const CGAffineTransform *transform);
  45. /**
  46. * Draw a CSS-compliant border as an image. You can determine if it's scalable
  47. * by inspecting the image's `capInsets`.
  48. *
  49. * `borderInsets` defines the border widths for each edge.
  50. */
  51. RCT_EXTERN UIImage *RCTGetBorderImage(
  52. RCTBorderStyle borderStyle,
  53. CGSize viewSize,
  54. RCTCornerRadii cornerRadii,
  55. UIEdgeInsets borderInsets,
  56. RCTBorderColors borderColors,
  57. CGColorRef backgroundColor,
  58. BOOL drawToEdge);