Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Filling bezier path with the image



>> In the above code, the stroking of the bezier path works properly.  
>> Stroke appears as I am intended.
>> I was expecting the image to be drawn inside the stroked region,  
>> but the image is not drawn inside the path. Part of the image is  
>> drawn outside the clipping region.
>>
>> I have even tried the NSAffineTransform's "concat" API, but the  
>> result is same as above code!!!.
>> I am wondering. how stroke is working properly?
>>
>> Anything wrong in the above code?
>> Is there any easy way to draw NSImage in the clipping region of the  
>> NSBezierPath?
>
>  You're not clipping. -stroke and -fill just *draw* the *path*.  
>Affine transforms just change the *shape*/*position* of the bezier  
>path. All of that has nothing to do with clipping. You probably want  
>to call [graphicsPath setClip] somewhere to apply it for clipping.  
>You may also want to save the graphics state so you can restore the  
>clip area to what it was afterwards. Check out NSGraphicsContext for  
>that.
>

Thanks for pointing out that.
After clipping the path. Image is drawn inside the cliping region of the path. But the affine transform which I had applied to path is not applied to the image drawing.
i.e, path is rotated, but image is not rotated and drawn.

I got partial success, I have commented the code to scale X and Y for affinetransform. Then did the drawing like this,

[[NSColor redColor] set];
[path stroke];

[affineTransform concat];
[image drawAtPoint:NSZeroPoint fromRect:imageRect operation:NSCompositeSourceOver fraction:1];

This code works fine, i.e, image is also rotade along with the path. As soon as I scale the affine transform, Path stroking appears properly, but the image scales but the rotation is not applied properly.
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.