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

shape frames not set properly in setup{} #28

Closed
traviskirton opened this issue Mar 29, 2012 · 2 comments
Closed

shape frames not set properly in setup{} #28

traviskirton opened this issue Mar 29, 2012 · 2 comments

Comments

@traviskirton
Copy link
Collaborator

in the setup method, when a shape is created, it takes longer to build the path than to set its new center position...
so if i write

shape = [C4Shape rect:];
shape.center = CGPoint;

the shape stays in its original rect...

not sure how to get around this...

@traviskirton
Copy link
Collaborator Author

this is a general problem that i don't know yet how to get around...

a similar issue with initialization happens when you try to call [shape closeShape] right after initializing like the following:


[shape rect:...];
[shape closeShape];

@traviskirton
Copy link
Collaborator Author

Fixed this for most shapes...
Haven't fully tested with arcs and curves though...

The following works:

#import "C4WorkSpace.h"

@implementation C4WorkSpace {
    C4Shape *r1, *r2;
}

-(void)setup {
    CGPoint points[4] = {CGPointZero, CGPointMake(100, 0), CGPointMake(0, 100), CGPointMake(100, 100)};
    r1 = [C4Shape line:points];
    r1.center = self.canvas.center;
    [self.canvas addShape:r1];

    r2 = [C4Shape rect:CGRectMake(0, 0, 40,40)];
    r2.fillColor = [C4RED colorWithAlphaComponent:0.5];
    r2.lineWidth = 0.0;
    r2.center = self.canvas.center;
    [self.canvas addShape:r2];
}

@end

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

1 participant