Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CALayer coordinate system flipped #16

Open
azplanlos opened this issue Jan 17, 2015 · 2 comments
Open

CALayer coordinate system flipped #16

azplanlos opened this issue Jan 17, 2015 · 2 comments

Comments

@azplanlos
Copy link

When adding a CALayer for a single SVGElement the CALayer is rendered flipped.
I'm doing this in a NSView subclass:

SVGElement* elem = …;
CALayer* layer = [svgImage layerWithIdentifier:elem.identifier];
[self.layer addSublayer:layer];
@MaddTheSane
Copy link
Owner

The quick-and-dirty solution would probably have your NSView subclass be flipped:

- (BOOL)isFlipped {
    return YES;
}

I realize this might not be ideal if you want to do your own drawing on your own class, though.

@azplanlos
Copy link
Author

Thanks for your quick reply. I ended up using CALayer’s “geometryFlipped” property in combination with a custom category flipping coordinates on CALayer’s frame property in order to compose an image from multiple groups stored in a SVG file.

@implementation CALayer (flipPos)

-(void)flipCoordinatesForRect:(NSRect)frameRect {
self.frame = NSMakeRect(self.frame.origin.x, frameRect.size.height - (self.frame.origin.y + self.frame.size.height), self.frame.size.width, self.frame.size.height);
}

@EnD

Andreas Zöllner
Sent with Airmail

Absender: MaddTheSane [email protected]:[email protected]
Antworten: MaddTheSane/SVGKit [email protected]:[email protected]
Datum: 17. Januar 2015 at 22:15:58
Empfänger: MaddTheSane/SVGKit [email protected]:[email protected]
CC: Andreas Zöllner [email protected]:[email protected]
Betreff: Re: [SVGKit] CALayer coordinate system flipped (#16)

The quick-and-dirty solution would probably have your NSView subclass be flipped:

  • (BOOL)isFlipped {
    return YES;
    }

I realize this might not be ideal if you want to do your own drawing on your own class, though.


Reply to this email directly or view it on GitHubhttps://github.com//issues/16#issuecomment-70382522.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants