Compare commits

...

8 Commits

Author SHA1 Message Date
Curtis Hard 204b516e77 Fixes width and height not working correctly 2020-02-12 22:32:52 +00:00
Curtis Hard a832a986fd Swaps back to CATransaction 2020-01-16 20:37:48 +00:00
Curtis Hard f875714609 FOrmatting 2020-01-14 21:12:38 +00:00
Curtis Hard b8f166f4c1 Uses NSAnimationContext over CATransaction for safety 2020-01-14 21:12:33 +00:00
Curtis Hard 7901c9eafe Possible fixes for main thread 2020-01-14 20:41:59 +00:00
Curtis Hard 5de88cb1d7 #oopsie 2020-01-14 16:38:08 +00:00
Curtis Hard 6216b61c19 Fixes compat for 10.13 with CGPath block applying 2020-01-14 16:34:52 +00:00
Curtis Hard e05f5a0884 Fixes compatibility issues for 10.9 2020-01-14 15:51:15 +00:00
18 changed files with 282 additions and 39 deletions
@@ -7,10 +7,16 @@
objects = {
/* Begin PBXBuildFile section */
5919E65723F47FF60051873A /* IJSVGUnitRect.h in Headers */ = {isa = PBXBuildFile; fileRef = 5919E65523F47FF60051873A /* IJSVGUnitRect.h */; settings = {ATTRIBUTES = (Public, ); }; };
5919E65823F47FF60051873A /* IJSVGUnitRect.m in Sources */ = {isa = PBXBuildFile; fileRef = 5919E65623F47FF60051873A /* IJSVGUnitRect.m */; };
5919E65B23F480330051873A /* IJSVGUnitPoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 5919E65923F480330051873A /* IJSVGUnitPoint.h */; settings = {ATTRIBUTES = (Public, ); }; };
5919E65C23F480330051873A /* IJSVGUnitPoint.m in Sources */ = {isa = PBXBuildFile; fileRef = 5919E65A23F480330051873A /* IJSVGUnitPoint.m */; };
594CF55F238FF462009B251B /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 594CF55E238FF462009B251B /* AppKit.framework */; };
594CF561238FF46C009B251B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 594CF560238FF46C009B251B /* Foundation.framework */; };
594CF563238FF473009B251B /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 594CF562238FF473009B251B /* QuartzCore.framework */; };
599EB4D3238FF570004CB6BC /* libobjc.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 599EB4D2238FF535004CB6BC /* libobjc.tbd */; };
59A24EBC23F480EA0090C374 /* IJSVGUnitSize.h in Headers */ = {isa = PBXBuildFile; fileRef = 59A24EBA23F480EA0090C374 /* IJSVGUnitSize.h */; settings = {ATTRIBUTES = (Public, ); }; };
59A24EBD23F480EA0090C374 /* IJSVGUnitSize.m in Sources */ = {isa = PBXBuildFile; fileRef = 59A24EBB23F480EA0090C374 /* IJSVGUnitSize.m */; };
59E7CFAF23B148600077D599 /* IJSVGCommandParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 59E7CFAD23B148600077D599 /* IJSVGCommandParser.h */; settings = {ATTRIBUTES = (Public, ); }; };
59E7CFB023B148600077D599 /* IJSVGCommandParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 59E7CFAE23B148600077D599 /* IJSVGCommandParser.m */; };
59EB75D623905F7300F5AE63 /* IJSVGLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 59EB756523905F6B00F5AE63 /* IJSVGLayer.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -127,12 +133,18 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
5919E65523F47FF60051873A /* IJSVGUnitRect.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IJSVGUnitRect.h; sourceTree = "<group>"; };
5919E65623F47FF60051873A /* IJSVGUnitRect.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IJSVGUnitRect.m; sourceTree = "<group>"; };
5919E65923F480330051873A /* IJSVGUnitPoint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IJSVGUnitPoint.h; sourceTree = "<group>"; };
5919E65A23F480330051873A /* IJSVGUnitPoint.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IJSVGUnitPoint.m; sourceTree = "<group>"; };
594CF46F238FF38E009B251B /* IJSVG.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = IJSVG.framework; sourceTree = BUILT_PRODUCTS_DIR; };
594CF473238FF38E009B251B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
594CF55E238FF462009B251B /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
594CF560238FF46C009B251B /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
594CF562238FF473009B251B /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
599EB4D2238FF535004CB6BC /* libobjc.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libobjc.tbd; path = usr/lib/libobjc.tbd; sourceTree = SDKROOT; };
59A24EBA23F480EA0090C374 /* IJSVGUnitSize.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IJSVGUnitSize.h; sourceTree = "<group>"; };
59A24EBB23F480EA0090C374 /* IJSVGUnitSize.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IJSVGUnitSize.m; sourceTree = "<group>"; };
59E7CFAD23B148600077D599 /* IJSVGCommandParser.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = IJSVGCommandParser.h; path = IJSVG/Source/Parsing/IJSVGCommandParser.h; sourceTree = SOURCE_ROOT; };
59E7CFAE23B148600077D599 /* IJSVGCommandParser.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = IJSVGCommandParser.m; path = IJSVG/Source/Parsing/IJSVGCommandParser.m; sourceTree = SOURCE_ROOT; };
59EB756523905F6B00F5AE63 /* IJSVGLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IJSVGLayer.h; sourceTree = "<group>"; };
@@ -396,6 +408,12 @@
59EB75BA23905F7000F5AE63 /* IJSVGUnitLength.m */,
59EB759423905F6D00F5AE63 /* IJSVGUtils.h */,
59EB758023905F6C00F5AE63 /* IJSVGUtils.m */,
5919E65523F47FF60051873A /* IJSVGUnitRect.h */,
5919E65623F47FF60051873A /* IJSVGUnitRect.m */,
5919E65923F480330051873A /* IJSVGUnitPoint.h */,
5919E65A23F480330051873A /* IJSVGUnitPoint.m */,
59A24EBA23F480EA0090C374 /* IJSVGUnitSize.h */,
59A24EBB23F480EA0090C374 /* IJSVGUnitSize.m */,
);
path = Utils;
sourceTree = "<group>";
@@ -566,6 +584,9 @@
59EB761823905F7300F5AE63 /* IJSVGParser.h in Headers */,
59EB761E23905F7300F5AE63 /* IJSVGGroupLayer.h in Headers */,
59EB761D23905F7300F5AE63 /* IJSVGStyle.h in Headers */,
5919E65723F47FF60051873A /* IJSVGUnitRect.h in Headers */,
5919E65B23F480330051873A /* IJSVGUnitPoint.h in Headers */,
59A24EBC23F480EA0090C374 /* IJSVGUnitSize.h in Headers */,
59EB764523905F7300F5AE63 /* IJSVGExporter.h in Headers */,
59E7CFAF23B148600077D599 /* IJSVGCommandParser.h in Headers */,
59EB762823905F7300F5AE63 /* IJSVGCommandClose.h in Headers */,
@@ -644,6 +665,7 @@
buildActionMask = 2147483647;
files = (
59EB763123905F7300F5AE63 /* IJSVGText.m in Sources */,
59A24EBD23F480EA0090C374 /* IJSVGUnitSize.m in Sources */,
59EB760223905F7300F5AE63 /* IJSVGCommandVerticalLine.m in Sources */,
59EB75FD23905F7300F5AE63 /* IJSVGPatternLayer.m in Sources */,
59EB763923905F7300F5AE63 /* IJSVGCommandSmoothQuadraticCurve.m in Sources */,
@@ -663,6 +685,7 @@
59EB763523905F7300F5AE63 /* IJSVGStyleSheetSelector.m in Sources */,
59E7CFB023B148600077D599 /* IJSVGCommandParser.m in Sources */,
59EB760723905F7300F5AE63 /* IJSVGNode.m in Sources */,
5919E65C23F480330051873A /* IJSVGUnitPoint.m in Sources */,
59EB75E923905F7300F5AE63 /* IJSVGStringAdditions.m in Sources */,
59EB761723905F7300F5AE63 /* IJSVGRadialGradient.m in Sources */,
59EB75E223905F7300F5AE63 /* IJSVGColorList.m in Sources */,
@@ -674,6 +697,7 @@
59EB75EB23905F7300F5AE63 /* IJSVGShapeLayer.m in Sources */,
59EB75F623905F7300F5AE63 /* IJSVGColor.m in Sources */,
59EB75F323905F7300F5AE63 /* IJSVGGroupLayer.m in Sources */,
5919E65823F47FF60051873A /* IJSVGUnitRect.m in Sources */,
59EB762523905F7300F5AE63 /* IJSVGTransform.m in Sources */,
59EB760023905F7300F5AE63 /* IJSVGGradientLayer.m in Sources */,
59EB762B23905F7300F5AE63 /* IJSVGUnitLength.m in Sources */,
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1130"
LastUpgradeVersion = "1140"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
+1 -1
View File
@@ -44,7 +44,6 @@
id<IJSVGDelegate> _delegate;
IJSVGLayer* _layerTree;
CGRect _viewBox;
CGSize _proposedViewSize;
CGFloat _backingScaleFactor;
CGFloat _lastProposedBackingScale;
IJSVGRenderQuality _lastProposedRenderQuality;
@@ -154,4 +153,5 @@
// colors
- (IJSVGColorList*)computedColorList:(BOOL*)hasPatternFills;
- (void)performBlock:(dispatch_block_t)block;
@end
+56 -13
View File
@@ -20,6 +20,7 @@
- (void)dealloc
{
// this can all be called on the background thread to be released
BOOL hasTransaction = IJSVGBeginTransaction();
(void)([renderingBackingScaleHelper release]),
renderingBackingScaleHelper = nil;
(void)([_replacementColors release]), _replacementColors = nil;
@@ -29,6 +30,9 @@
// kill any memory that has been around
(void)([_layerTree release]), _layerTree = nil;
[super dealloc];
if (hasTransaction == YES) {
IJSVGEndTransaction();
}
}
+ (id)svgNamed:(NSString*)string
@@ -79,10 +83,14 @@
__block IJSVGImageLayer* imageLayer = nil;
// create the layers we require
BOOL hasTransaction = IJSVGBeginTransaction();
layer = [[[IJSVGGroupLayer alloc] init] autorelease];
imageLayer =
[[[IJSVGImageLayer alloc] initWithImage:image] autorelease];
[layer addSublayer:imageLayer];
if (hasTransaction == YES) {
IJSVGEndTransaction();
}
// return the initialized SVG
return [self initWithSVGLayer:layer
@@ -238,6 +246,15 @@
return self;
}
- (void)performBlock:(dispatch_block_t)block
{
BOOL hasTransaction = IJSVGBeginTransaction();
block();
if (hasTransaction == YES) {
IJSVGEndTransaction();
}
}
- (void)discardDOM
{
// if we discard, we can no longer create a tree, so lets create tree
@@ -250,9 +267,7 @@
- (void)_setupBasicInfoFromGroup
{
// store the viewbox
_viewBox = _group.viewBox;
_proposedViewSize = _group.proposedViewSize;
}
- (void)_setupBasicsFromAnyInitializer
@@ -340,11 +355,19 @@
error:nil];
}
- (NSSize)computeSVGSizeWithRenderSize:(NSSize)size
{
IJSVGUnitSize* svgSize = _group.intrinsicSize;
return NSMakeSize([svgSize.width computeValue:size.width],
[svgSize.height computeValue:size.height]);
}
- (NSRect)computeOriginalDrawingFrameWithSize:(NSSize)aSize
{
NSSize propSize = [self computeSVGSizeWithRenderSize:aSize];
[self _beginDraw:(NSRect){ .origin = CGPointZero, .size = aSize }];
return NSMakeRect(0.f, 0.f, _proposedViewSize.width * _clipScale,
_proposedViewSize.height * _clipScale);
return NSMakeRect(0.f, 0.f, propSize.width * _clipScale,
propSize.height * _clipScale);
}
- (CGImageRef)newCGImageRefWithSize:(CGSize)size
@@ -540,8 +563,14 @@
- (BOOL)drawInRect:(NSRect)rect
error:(NSError**)error
{
CGContextRef currentCGContext;
if (@available(macOS 10.10, *)) {
currentCGContext = NSGraphicsContext.currentContext.CGContext;
} else {
currentCGContext = NSGraphicsContext.currentContext.graphicsPort;
}
return [self _drawInRect:rect
context:[[NSGraphicsContext currentContext] CGContext]
context:currentCGContext
error:error];
}
@@ -557,11 +586,12 @@
// we also need to calculate the viewport so we can clip
// the drawing if needed
NSRect viewPort = NSZeroRect;
viewPort.origin.x = round((rect.size.width / 2 - (_proposedViewSize.width / 2) * _clipScale) + rect.origin.x);
NSSize propSize = [self computeSVGSizeWithRenderSize:rect.size];
viewPort.origin.x = round((rect.size.width / 2 - (propSize.width / 2) * _clipScale) + rect.origin.x);
viewPort.origin.y = round(
(rect.size.height / 2 - (_proposedViewSize.height / 2) * _clipScale) + rect.origin.y);
viewPort.size.width = _proposedViewSize.width * _clipScale;
viewPort.size.height = _proposedViewSize.height * _clipScale;
(rect.size.height / 2 - (propSize.height / 2) * _clipScale) + rect.origin.y);
viewPort.size.width = propSize.width * _clipScale;
viewPort.size.height = propSize.height * _clipScale;
// check the viewport
if (NSEqualRects(_viewBox, NSZeroRect) || _viewBox.size.width <= 0 || _viewBox.size.height <= 0 || NSEqualRects(NSZeroRect, viewPort) || CGRectIsEmpty(viewPort) || CGRectIsNull(viewPort) || viewPort.size.width <= 0 || viewPort.size.height <= 0) {
@@ -634,7 +664,11 @@
}
}
CGContextSetInterpolationQuality(ref, quality);
BOOL hasTransaction = IJSVGBeginTransaction();
[self.layer renderInContext:ref];
if (hasTransaction == YES) {
IJSVGEndTransaction();
}
}
} @catch (NSException* exception) {
// just catch and give back a drawing error to the caller
@@ -684,19 +718,27 @@
};
// gogogo
BOOL hasTransaction = IJSVGBeginTransaction();
[IJSVGLayer recursivelyWalkLayer:self.layer withBlock:block];
if (hasTransaction == YES) {
IJSVGEndTransaction();
}
return _backingScaleFactor;
}
- (IJSVGLayer*)layerWithTree:(IJSVGLayerTree*)tree
{
// clear memory
BOOL hasTransaction = IJSVGBeginTransaction();
if (_layerTree != nil) {
(void)([_layerTree release]), _layerTree = nil;
}
// force rebuild of the tree
_layerTree = [[tree layerForNode:_group] retain];
if (hasTransaction == YES) {
IJSVGEndTransaction();
}
return _layerTree;
}
@@ -800,12 +842,13 @@
// to transform the paths into our viewbox
NSSize dest = rect.size;
NSSize source = _viewBox.size;
_clipScale = MIN(dest.width / _proposedViewSize.width,
dest.height / _proposedViewSize.height);
NSSize propSize = [self computeSVGSizeWithRenderSize:rect.size];
_clipScale = MIN(dest.width / propSize.width,
dest.height / propSize.height);
// work out the actual scale based on the clip scale
CGFloat w = _proposedViewSize.width * _clipScale;
CGFloat h = _proposedViewSize.height * _clipScale;
CGFloat w = propSize.width * _clipScale;
CGFloat h = propSize.height * _clipScale;
_scale = MIN(w / source.width, h / source.height);
}
@@ -25,12 +25,20 @@
+ (NSArray<NSString*>*)imageTypes
{
return @[ (NSString*)kUTTypeScalableVectorGraphics, @"svg" ];
if (@available(macOS 10.10, *)) {
return @[ (NSString*)kUTTypeScalableVectorGraphics, @"svg" ];
} else {
return @[ @"public.svg-image", @"svg" ];
}
}
+ (NSArray<NSString*>*)imageUnfilteredTypes
{
return @[ (NSString*)kUTTypeScalableVectorGraphics, @"svg" ];
if (@available(macOS 10.10, *)) {
return @[ (NSString*)kUTTypeScalableVectorGraphics, @"svg" ];
} else {
return @[ @"public.svg-image", @"svg" ];
}
}
+ (NSArray<NSImageRep*>*)imageRepsWithData:(NSData*)data
@@ -1446,7 +1446,7 @@ void IJSVGExporterPathCaller(void* info, const CGPathElement* pathElement)
void IJSVGEnumerateCGPathElements(CGPathRef path, IJSVGPathElementEnumerationBlock enumBlock)
{
__block CGPoint currentPoint = CGPointZero;
CGPathApplyWithBlock(path, ^(const CGPathElement* _Nonnull element) {
IJSVGCGPathHandler callback = ^(const CGPathElement* _Nonnull element) {
switch (element->type) {
case kCGPathElementMoveToPoint: {
enumBlock(element, currentPoint);
@@ -1473,7 +1473,12 @@ void IJSVGEnumerateCGPathElements(CGPathRef path, IJSVGPathElementEnumerationBlo
break;
}
}
});
};
if(@available(macOS 10.13, *)) {
CGPathApplyWithBlock(path, callback);
} else {
CGPathApply(path, (__bridge void*)callback, IJSVGExporterPathCaller);
}
};
- (void)sortAttributesOnElement:(NSXMLElement*)element
@@ -25,7 +25,6 @@
- (void)dealloc
{
self.contents = nil;
(void)([_maskingLayer release]), _maskingLayer = nil;
[super dealloc];
}
@@ -26,7 +26,6 @@
- (void)dealloc
{
self.contents = nil;
(void)([_maskingLayer release]), _maskingLayer = nil;
[super dealloc];
}
@@ -20,6 +20,7 @@
#import "IJSVGStyleSheet.h"
#import "IJSVGText.h"
#import "IJSVGTransform.h"
#import "IJSVGUnitRect.h"
#import "IJSVGUtils.h"
#import <AppKit/AppKit.h>
#import <Foundation/Foundation.h>
@@ -85,7 +86,7 @@ static NSString const* IJSVGAttributePoints = @"points";
@interface IJSVGParser : IJSVGGroup {
NSRect viewBox;
NSSize proposedViewSize;
IJSVGUnitSize* intrinsicSize;
@private
id<IJSVGParserDelegate> _delegate;
@@ -107,7 +108,7 @@ static NSString const* IJSVGAttributePoints = @"points";
}
@property (nonatomic, readonly) NSRect viewBox;
@property (nonatomic, readonly) NSSize proposedViewSize;
@property (nonatomic, readonly) IJSVGUnitSize* intrinsicSize;
+ (BOOL)isDataSVG:(NSData*)data;
@@ -12,7 +12,7 @@
@implementation IJSVGParser
@synthesize viewBox;
@synthesize proposedViewSize;
@synthesize intrinsicSize = _intrinsicSize;
+ (IJSVGParser*)groupForFileURL:(NSURL*)aURL
{
@@ -46,6 +46,7 @@
(void)([_defNodes release]), _defNodes = nil;
(void)([_baseDefNodes release]), _baseDefNodes = nil;
(void)([_svgs release]), _svgs = nil;
(void)([_intrinsicSize release]), _intrinsicSize = nil;
if (_commandDataStream != NULL) {
(void)IJSVGPathDataStreamRelease(_commandDataStream), _commandDataStream = nil;
}
@@ -213,17 +214,19 @@
}
// parse the width and height....
CGFloat w = [svgElement attributeForName:(NSString*)IJSVGAttributeWidth].stringValue.floatValue;
CGFloat h = [svgElement attributeForName:(NSString*)IJSVGAttributeHeight].stringValue.floatValue;
if (w == 0.f && h == 0.f) {
w = viewBox.size.width;
h = viewBox.size.height;
} else if (w == 0 && h != 0.f) {
w = viewBox.size.width;
} else if (h == 0 && w != 0.f) {
h = viewBox.size.height;
NSString* w = [svgElement attributeForName:(NSString*)IJSVGAttributeWidth].stringValue;
NSString* h = [svgElement attributeForName:(NSString*)IJSVGAttributeHeight].stringValue;
IJSVGUnitLength* wl = [IJSVGUnitLength unitWithPercentageFloat:100.f];
IJSVGUnitLength* hl = [IJSVGUnitLength unitWithPercentageFloat:100.f];
if (w != nil) {
wl = [IJSVGUnitLength unitWithString:w];
}
proposedViewSize = NSMakeSize(w, h);
if (h != nil) {
hl = [IJSVGUnitLength unitWithString:h];
}
// store the width and height
_intrinsicSize = [IJSVGUnitSize sizeWithWidth:wl height:hl].retain;
// the root element is SVG, so iterate over its children
// recursively
@@ -1116,7 +1119,7 @@
NSUInteger len = command.length;
NSUInteger lastIndex = len - 1;
const char* buffer = command.UTF8String;
// make sure we plus 1 for the null byte
char* charBuffer = (char*)malloc(sizeof(char) * (len + 1));
@@ -10,5 +10,5 @@
#import <QuartzCore/QuartzCore.h>
BOOL IJSVGIsMainThread(void);
void IJSVGBeginTransactionLock(void);
void IJSVGEndTransactionLock(void);
BOOL IJSVGBeginTransaction(void);
void IJSVGEndTransaction(void);
@@ -7,16 +7,23 @@
//
#import "IJSVGTransaction.h"
#import <AppKit/AppKit.h>
BOOL IJSVGIsMainThread(void) { return NSThread.isMainThread; };
void IJSVGBeginTransactionLock(void)
BOOL IJSVGBeginTransaction(void)
{
if(IJSVGIsMainThread() == YES) {
return NO;
}
// use nsanimationcontext as this sets a private flag of 0x4
// of the catransaction for background composites
[CATransaction begin];
[CATransaction setDisableActions:YES];
return YES;
};
void IJSVGEndTransactionLock(void)
void IJSVGEndTransaction(void)
{
[CATransaction commit];
};
@@ -0,0 +1,17 @@
//
// IJSVGUnitPoint.h
// IJSVG
//
// Created by Curtis Hard on 12/02/2020.
// Copyright © 2020 Curtis Hard. All rights reserved.
//
#import "IJSVGUnitLength.h"
#import <Foundation/Foundation.h>
@interface IJSVGUnitPoint : NSObject
@property (nonatomic, retain) IJSVGUnitLength* x;
@property (nonatomic, retain) IJSVGUnitLength* y;
@end
@@ -0,0 +1,32 @@
//
// IJSVGUnitPoint.m
// IJSVG
//
// Created by Curtis Hard on 12/02/2020.
// Copyright © 2020 Curtis Hard. All rights reserved.
//
#import "IJSVGUnitPoint.h"
@implementation IJSVGUnitPoint
@synthesize x = _x;
@synthesize y = _y;
- (void)dealloc
{
(void)[_x release], _x = nil;
(void)[_y release], _y = nil;
[super dealloc];
}
+ (IJSVGUnitPoint*)pointWithX:(IJSVGUnitLength*)x
y:(IJSVGUnitLength*)y
{
IJSVGUnitPoint* point = [[[self alloc] init] autorelease];
point.x = x;
point.y = y;
return point;
}
@end
@@ -0,0 +1,21 @@
//
// IJSVGUnitRect.h
// IJSVG
//
// Created by Curtis Hard on 12/02/2020.
// Copyright © 2020 Curtis Hard. All rights reserved.
//
#import "IJSVGUnitPoint.h"
#import "IJSVGUnitSize.h"
#import <Foundation/Foundation.h>
@interface IJSVGUnitRect : NSObject
@property (nonatomic, retain) IJSVGUnitSize* size;
@property (nonatomic, retain) IJSVGUnitPoint* origin;
+ (IJSVGUnitRect*)rectWithOrigin:(IJSVGUnitPoint*)origin
size:(IJSVGUnitSize*)size;
@end
@@ -0,0 +1,32 @@
//
// IJSVGUnitRect.m
// IJSVG
//
// Created by Curtis Hard on 12/02/2020.
// Copyright © 2020 Curtis Hard. All rights reserved.
//
#import "IJSVGUnitRect.h"
@implementation IJSVGUnitRect
@synthesize size = _size;
@synthesize origin = _origin;
- (void)dealloc
{
(void)[_size release], _size = nil;
(void)[_origin release], _origin = nil;
[super dealloc];
}
+ (IJSVGUnitRect*)rectWithOrigin:(IJSVGUnitPoint*)origin
size:(IJSVGUnitSize*)size
{
IJSVGUnitRect* rect = [[[self alloc] init] autorelease];
rect.origin = origin;
rect.size = size;
return rect;
}
@end
@@ -0,0 +1,20 @@
//
// IJSVGUnitSize.h
// IJSVG
//
// Created by Curtis Hard on 12/02/2020.
// Copyright © 2020 Curtis Hard. All rights reserved.
//
#import "IJSVGUnitLength.h"
#import <Foundation/Foundation.h>
@interface IJSVGUnitSize : NSObject
@property (nonatomic, retain) IJSVGUnitLength* width;
@property (nonatomic, retain) IJSVGUnitLength* height;
+ (IJSVGUnitSize*)sizeWithWidth:(IJSVGUnitLength*)width
height:(IJSVGUnitLength*)height;
@end
@@ -0,0 +1,32 @@
//
// IJSVGUnitSize.m
// IJSVG
//
// Created by Curtis Hard on 12/02/2020.
// Copyright © 2020 Curtis Hard. All rights reserved.
//
#import "IJSVGUnitSize.h"
@implementation IJSVGUnitSize
@synthesize width = _width;
@synthesize height = _height;
- (void)dealloc
{
(void)[_width release], _width = nil;
(void)[_height release], _height = nil;
[super dealloc];
}
+ (IJSVGUnitSize*)sizeWithWidth:(IJSVGUnitLength*)width
height:(IJSVGUnitLength*)height
{
IJSVGUnitSize* size = [[[self alloc] init] autorelease];
size.width = width;
size.height = height;
return size;
}
@end