Trouble filling with holes

1 view
Skip to first unread message

Rick Mann

unread,
Mar 1, 2012, 11:17:55 PM3/1/12
to Quartz Dev List List
Hi. I'm drawing a shaded overlay over a set of cards. The overlay is 50% opaque black. It's built by adding the bounding rect of the UIView to the context path, then by adding three rounded rects, each built using the following code:

    // Get the state we need
    CGPoint topMiddle;
    topMiddle.x = inRect.midX();
    topMiddle.y = inRect.maxY();
    
    CGPoint topLeft;
    topLeft.x = inRect.minX();
    topLeft.y = inRect.maxY();
    
    CGPoint bottomLeft;
    bottomLeft.x = inRect.minX();
    bottomLeft.y = inRect.minY();
    
    CGPoint bottomRight;
    bottomRight.x = inRect.maxX();
    bottomRight.y = inRect.minY();
    
    CGPoint topRight;
    topRight.x = inRect.maxX();
    topRight.y = inRect.maxY();
    
    
    // Add the rect
    ::CGContextMoveToPoint(   getCGContext(),   topMiddle.x,        topMiddle.y);
    ::CGContextAddArcToPoint( getCGContext(),   topLeft.x,          topLeft.y,          bottomLeft.y,       bottomLeft.y,   inRadius);
    ::CGContextAddArcToPoint( getCGContext(),   bottomLeft.x,       bottomLeft.y,       bottomRight.x,      bottomRight.y,  inRadius);
    ::CGContextAddArcToPoint( getCGContext(),   bottomRight.x,      bottomRight.y,      topRight.x,         topRight.y,     inRadius);
    ::CGContextAddArcToPoint( getCGContext(),   topRight.x,         topRight.y,         topMiddle.x,        topMiddle.y,    inRadius);
    ::CGContextAddLineToPoint(getCGContext(),   topMiddle.x,        topMiddle.y);


I then do an EOFill operation with 50% black.

Notice the lower-left corner of each of the punched-out areas (with the green gradient). Depending on how close to the left of the screen, and to the bottom, the effect is more pronounced. The further away, you an actually see the bottom-left corner mutate in the opposite direction.

Any idea what's going on here? I'm successfully using the same code to draw and fill rounded rects all over the place.

Thanks,
Rick

Rick Mann

unread,
Mar 2, 2012, 12:09:52 AM3/2/12
to Quartz Dev List List
Found it. Tiny bug in the code never manifest until now. First AddArcToPoint() call passed the y coordinate twice.

---- 
Reply all
Reply to author
Forward
0 new messages