Re: NSBezierPath Arc bug, intel.
Re: NSBezierPath Arc bug, intel.
- Subject: Re: NSBezierPath Arc bug, intel.
- From: Half Activist <email@hidden>
- Date: Wed, 21 Mar 2007 15:03:43 +0100
Yeah, there it goes:
PS: It works on PowerPCs, not on intel, the rectangles a normal, not
rounded.
Somewhere I created a category to extend NSBezierPath
@implementation NSBezierPath (RoundedRectCategory)
+ (NSBezierPath *) bezierPathWithRoundRectInRect:(NSRect)rect radius:
(float) radius
{
NSBezierPath *path;
NSRect inner_rect;
inner_rect = NSInsetRect(rect, radius, radius);
path = [NSBezierPath bezierPath];
[path moveToPoint:NSMakePoint(rect.origin.x+rect.size.width/2.0,
rect.origin.y+rect.size.height)];
[path appendBezierPathWithArcWithCenter:NSMakePoint
(inner_rect.origin.x, inner_rect.origin.y + inner_rect.size.height)
radius: radius startAngle: 90.0 endAngle: 180.0];
[path appendBezierPathWithArcWithCenter:inner_rect.origin radius:
radius startAngle: 180.0 endAngle:270.0];
[path appendBezierPathWithArcWithCenter:NSMakePoint
(inner_rect.origin.x + inner_rect.size.width, inner_rect.origin.y)
radius: radius startAngle: 270.0 endAngle:360.0];
[path appendBezierPathWithArcWithCenter:NSMakePoint
(inner_rect.origin.x + inner_rect.size.width, inner_rect.origin.y +
inner_rect.size.height) radius: radius startAngle: 0.0 endAngle:90.0];
[path closePath];
return path;
}
@end
Somewhere else, i draw a rectangle onto an nsimage
NSImage *imageRoundRect( NSColor *backgroundColor, NSColor
*strokeColor, NSSize size, float roundCornerRadius )
{
if( backgroundColor == nil || strokeColor == nil || NSEqualSizes
( size, NSZeroSize ) )
return nil;
NSRect frame;
frame.origin = NSZeroPoint;
frame.size = size;
frame = NSInsetRect( frame, 1.0, 1.0 );
if( (roundCornerRadius * 2.0) > frame.size.height )
roundCornerRadius = frame.size.height / 2.0;
if( (roundCornerRadius * 2.0) > frame.size.width )
roundCornerRadius = frame.size.width / 2.0;
NSImage *newImage = [ [ NSImage alloc ] initWithSize: size ];
[ newImage setBackgroundColor: [ NSColor clearColor ] ];
[ newImage lockFocus ];
// Drawing the image
NSBezierPath *p = [ NSBezierPath bezierPathWithRoundRectInRect:
frame radius: roundCornerRadius ];
[ backgroundColor setFill ];
[ p fill ];
[ strokeColor setStroke ];
[ p stroke ];
[ newImage unlockFocus ];
return [ newImage autorelease ];
}
On Mar 21, 2007, at 2:53 PM, Michael Watson wrote:
Can you post the code *you* use specifically to draw the path?
--
m-s
On 21 Mar, 2007, at 09:26, Half Activist wrote:
Hi All,
I'm currently drawing a round rectangle with arcs.
When drawing direclty to the screen, I get round rectangles.
When I lock the focus on an nsimage, the rectanlges aren't
rounded, but this only happens on intel macs,
powerpc macs have no problem.
I use the code that comes from this page:
http://www.cocoadev.com/index.pl?RoundedRectangles
Regards
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
40bungie.org
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden