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 notifications@github.commailto:notifications@github.com
Antworten: MaddTheSane/SVGKit reply@reply.github.commailto:reply@reply.github.com
Datum: 17. Januar 2015 at 22:15:58
Empfänger: MaddTheSane/SVGKit svgkit@noreply.github.commailto:svgkit@noreply.github.com
CC: Andreas Zöllner andi@go-for-fun.demailto:andi@go-for-fun.de
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