darling-cocotron/AppKit/NSAffineTransform.m
2020-05-12 17:04:15 -04:00

47 lines
1.2 KiB
Objective-C

#import <AppKit/NSAffineTransform.h>
#import <AppKit/NSBezierPath.h>
#import <AppKit/NSGraphicsContext.h>
#import <ApplicationServices/ApplicationServices.h>
@implementation NSAffineTransform (AppKit)
- (void) concat {
NSAffineTransformStruct atStruct = [self transformStruct];
CGAffineTransform cgMatrix;
cgMatrix.a = atStruct.m11;
cgMatrix.b = atStruct.m12;
cgMatrix.c = atStruct.m21;
cgMatrix.d = atStruct.m22;
cgMatrix.tx = atStruct.tX;
cgMatrix.ty = atStruct.tY;
CGContextConcatCTM([[NSGraphicsContext currentContext] graphicsPort],
cgMatrix);
}
- (void) set {
NSAffineTransformStruct atStruct = [self transformStruct];
CGAffineTransform cgMatrix;
cgMatrix.a = atStruct.m11;
cgMatrix.b = atStruct.m12;
cgMatrix.c = atStruct.m21;
cgMatrix.d = atStruct.m22;
cgMatrix.tx = atStruct.tX;
cgMatrix.ty = atStruct.tY;
CGContextSetCTM([[NSGraphicsContext currentContext] graphicsPort],
cgMatrix);
}
- (NSBezierPath *) transformBezierPath: (NSBezierPath *) bezierPath {
NSBezierPath *result = [[bezierPath copy] autorelease];
[result transformUsingAffineTransform: self];
return result;
}
@end