• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSBezierPath Arc bug, intel.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSBezierPath Arc bug, intel.


  • Subject: Re: NSBezierPath Arc bug, intel.
  • From: Half Activist <email@hidden>
  • Date: Thu, 22 Mar 2007 09:18:37 +0100

Ken,
	I felt no answer would come, and was a bit despaired.
	God shall bless you for your knowledge! It worked!
	(Thank you) ^ 2 ^ 10.
;-)

Regards.

On Mar 22, 2007, at 5:02 AM, Ken Ferry wrote:

If you are calling one of these functions without importing the
declaration, the intel calling convention may result in seeing 0 for
the radius (if the compiler thinks it needs to pass a double).

Check the values in the debugger, and make sure you're importing a
declaration for imageRoundRect.  I think I've seen this kind of
mistake compile without warnings in a standard Xcode project, but if
you are getting warnings, don't ignore them.

-Ken

On 3/21/07, Half Activist <email@hidden> wrote:
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


_______________________________________________

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


References: 
 >Deleting data from NSMutableData (From: "R. Tyler Ballance" <email@hidden>)
 >Re: Deleting data from NSMutableData (From: Jim Correia <email@hidden>)
 >Re: Deleting data from NSMutableData (From: "R. Tyler Ballance" <email@hidden>)
 >Re: Deleting data from NSMutableData (From: Andy Lee <email@hidden>)
 >Re: Deleting data from NSMutableData (From: "Adam R. Maxwell" <email@hidden>)
 >Re: Deleting data from NSMutableData (From: Jim Correia <email@hidden>)
 >NSBezierPath Arc bug, intel. (From: Half Activist <email@hidden>)
 >Re: NSBezierPath Arc bug, intel. (From: Michael Watson <email@hidden>)
 >Re: NSBezierPath Arc bug, intel. (From: Half Activist <email@hidden>)
 >Re: NSBezierPath Arc bug, intel. (From: "Ken Ferry" <email@hidden>)

  • Prev by Date: Re: Retained ivars being set to 0x0
  • Next by Date: Re: Retained ivars being set to 0x0 (SOLVED)
  • Previous by thread: Re: NSBezierPath Arc bug, intel.
  • Next by thread: Cocoa Automator Action with Empty Input?
  • Index(es):
    • Date
    • Thread