SVGGradientStop.m 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //
  2. // SVGGradientStop
  3. // SVGPad
  4. //
  5. // Created by Kevin Stich on 2/2/12.
  6. // Copyright (c) 2012 __MyCompanyName__. All rights reserved.
  7. //
  8. #import "SVGGradientStop.h"
  9. #import "SVGElement_ForParser.h"
  10. #import "SVGUtils.h"
  11. #import "SVGKParser.h"
  12. #import "SVGLength.h"
  13. @implementation SVGGradientStop
  14. @synthesize offset = _offset;
  15. @synthesize stopColor = _stopColor;
  16. @synthesize stopOpacity = _stopOpacity;
  17. //@synthesize style = _style;
  18. -(void)loadDefaults
  19. {
  20. _stopOpacity = 1.0f;
  21. }
  22. -(void)postProcessAttributesAddingErrorsTo:(SVGKParseResult *)parseResult
  23. {
  24. [super postProcessAttributesAddingErrorsTo:parseResult];
  25. if( [self getAttribute:@"offset"].length > 0 )
  26. _offset = [[SVGLength svgLengthFromNSString:[self getAttribute:@"offset"]] numberValue];
  27. /** Second, over-ride the style with any locally-specified values */
  28. NSString *stopColor = [self cascadedValueForStylableProperty:@"stop-color" inherit:NO];
  29. if( stopColor.length > 0 )
  30. _stopColor = SVGColorFromString( [stopColor UTF8String] );
  31. NSString *stopOpacity = [self cascadedValueForStylableProperty:@"stop-opacity" inherit:NO];
  32. if( stopOpacity.length > 0 )
  33. _stopOpacity = [stopOpacity floatValue];
  34. _stopColor.a = (_stopOpacity * 255);
  35. }
  36. //no memory allocated by this subclass
  37. //-(void)dealloc
  38. //{
  39. //
  40. //
  41. // [super dealloc];
  42. //}
  43. @end