SVGRect.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. http://www.w3.org/TR/SVG/types.html#InterfaceSVGRect
  3. interface SVGRect {
  4. attribute float x setraises(DOMException);
  5. attribute float y setraises(DOMException);
  6. attribute float width setraises(DOMException);
  7. attribute float height setraises(DOMException);
  8. };
  9. */
  10. #import <Foundation/Foundation.h>
  11. #import <CoreGraphics/CoreGraphics.h>
  12. typedef struct
  13. {
  14. float x;
  15. float y;
  16. float width;
  17. float height;
  18. } SVGRect;
  19. #pragma mark - utility methods that are NOT in the SVG Spec, bu which we need to implement it in ObjectiveC
  20. /** C has no way of detecting if an SVGRect is deliberately 0 width (has special meaning in SVG), or accidentally (because it was
  21. never initialized).
  22. Unfortunately, the SVG Spec authors defined "uninitialized" and "values of zero" to mean differnet things, so we MUST preserve
  23. that difference! */
  24. SVGRect SVGRectUninitialized(void);
  25. /** c.f. note about SVGRectUninitialized() -- this method checks if a Rect is identical to the output of that method */
  26. BOOL SVGRectIsInitialized( SVGRect rect );
  27. SVGRect SVGRectMake( float x, float y, float width, float height );
  28. /** Convenience method to convert to ObjectiveC's kind of rect */
  29. CGRect CGRectFromSVGRect( SVGRect rect );
  30. /** Convenience method to convert to ObjectiveC's kind of size - ONLY the width and height of this rect */
  31. CGSize CGSizeFromSVGRect( SVGRect rect );
  32. NSString * _Nonnull NSStringFromSVGRect( SVGRect rect );