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
Delivered-to: email@hidden
Delivered-to: email@hidden
Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:mime-version:in-reply-to:references:content-type:message-id:content-transfer-encoding:from:subject:date:to:x-mailer; b=Ogu2sVYXrpMsWE5oxQWpHgh+tila5TzGP3zusDHuXou38kFYky0HIg37j7Quo6NWn1tM0FG09CCRW9MFwWIcJCDCGIQGwYMcJH9FWJhBrzQ/3KowWZ8mMovrEDXGoi5FPyYuUghQlEV5cOr1+IA+NmSGLOU9k2qIyQL6n9Aq5I4=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:mime-version:in-reply-to:references:content-type:message-id:content-transfer-encoding:from:subject:date:to:x-mailer; b=IrlWHJlp4thcFVgLx0llASL/CqPKvTARoJxxeeBACU8C1uUnDl2Wq1RFN8/JYEf5+kRNo1is2GBNUxLTx2LYVYvjA3UYADIt8f5xsTVKPu1f4K2sP9NkxtuxQdSjuOPWwvD6P7wwGfNzg63Tham2BiFOpqH7kO8I0SFWwI6VHEw=
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:
http://lists.apple.com/mailman/options/cocoa-dev/mikey-san%
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:
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.