• 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: Rects and points...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Rects and points...


  • Subject: Re: Rects and points...
  • From: "John C. Randolph" <email@hidden>
  • Date: Tue, 20 Nov 2001 12:20:49 -0800

On Tuesday, November 20, 2001, at 07:16 AM, Riccardo Santato wrote:

> Hi there.
> I'd reaally like someone of you help me in making this code work.
> I'm just having fun with Bezier curves, but nothing is displayed... Can
> you tell me please where are the errors ?

1) You haven't implemented -drawRect:. The -drawRect: method that you
inherit from NSView doesn't do anything.

2) You create a path, but never draw it. Read the NSBezierPath
documentation for the -stroke and -fill methods.

3) You don't need the convertPoint:toView: calls. That method is
typically used for translating the location of mouse events (for
example) to your view's coordinate space.

Try it like this:

@implementation myView

- (id)initWithFrame:(NSRect)frame
{
[super initWithFrame:frameRect];
curve = [[NSBezierPath bezierPath] retain];
[curve moveToPoint:NSMakePoint(0.0, 0.0)];
[curve lineToPoint:NSMakePoint(100.0, 100.0)];
[curve lineToPoint:NSMakePoint(50.0,50.0)];
return self;
}

- (void) drawRect:(NSRect) rect
{
[[NSColor whiteColor] set];
NSRectFill(rect);
[[NSColor blackColor] set];
[curve stroke];
}

- (void) dealloc
{
if (curve)
[curve release];
[super dealloc];
}

@end
I almost had a psychic girlfriend, but she left me before we met. --
Steven Wright


References: 
 >Rects and points... (From: Riccardo Santato <email@hidden>)

  • Prev by Date: ANN: Text Wielder beta 1
  • Next by Date: Re: Laggy live scrolling in Cocoa
  • Previous by thread: Rects and points...
  • Next by thread: Re: Rects and points...
  • Index(es):
    • Date
    • Thread