views:

34

answers:

1

I have a rectangular CPImage setup like so

    var img = [[CPImage alloc] initWithContentsOfFile:"Resources/img.jpg""];

I'd like to display that in my CPView subclass in a circle with the part of the image clipped (what lies outside the eclipse) remaining transparent. I tried this:

- (void)drawRect:(CGRect)aRect
{    
    var path = [CPBezierPath bezierPathWithOvalInRect:aRect];

    [[CPColor colorWithPatternImage:img] set];
    [path fill];
}

but I just get a black circle.

A: 

The problem here is that you can't use an image to fill with (yet) in Cappuccino. So it'll just turn out black like you discovered, even that the commands you're using are technically correct. I'm not aware of a work around but you could try posting to the Cappuccino user list and see if anyone is working on this feature right now.

Alexander Ljungberg
Regis Frey
That's understandable. I have actually run into this once myself. I look forward to the day when drawing operations in Cappuccino achieve the full Cocoa level of capabilities - that'll be a pleasure to work with compared to regular HTML/CSS.
Alexander Ljungberg
I filed a bug http://github.com/280north/cappuccino/issues/issue/811 and have a rough fix (Canvas only ATM) that works for me in a github fork: http://github.com/RegisFrey/cappuccino.
Regis Frey