• 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: drawing and setting pixels
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: drawing and setting pixels


  • Subject: Re: drawing and setting pixels
  • From: Robert Dell <email@hidden>
  • Date: Sat, 21 Jan 2006 00:31:55 -0500

Cameron Hayne wrote:
On 20-Jan-06, at 6:59 PM, Robert Dell wrote:

Ahhhh somebody willing to tell me the page to look at...


The docs on drawing:
http://developer.apple.com/documentation/Cocoa/Conceptual/DrawBasic/ index.html


But the above assumes that you already know the basics (like the fact that you need to subclass NSView and implement drawRect).
You'd be best buying a book - it's covered in almost any Cocoa book.
And have a look at the examples that are under /Developer/Examples/ AppKit
- e.g. DotView, CircleView, Sketch

The problem is i have those books and they ALL suggest me to use nib files which as a plugin i can't do. i need to change things myself rather than let the user change things for me.

for example, i can't rely on a user to open a window with the file menu or close it that way.  scripts do that automatically already now.  can you imagine a game you like to play requiring a user to file, new window when every game scene happens and requiring the user to close the window every time as well? makes it an unplayable game.

anyway, here's what i have for 2 of the 4 things i needed.  (I still need get pixel data and set pixel data)

-(void)initGraphicWindow;
{
  graphicwindow = [[NSWindow alloc] initWithContentRect: NSMakeRect(graphicwindowlocation.x,  graphicwindowlocation.y, 280, 192) styleMask: (NSTitledWindowMask)  backing: NSBackingStoreBuffered defer: NO];
  [graphicwindow setTitle: @"Turtlegraphics"];
  [graphicwindow setViewsNeedDisplay: YES];
  [graphicwindow makeKeyAndOrderFront: self];
  [graphicwindow display];
  mycontext = [NSGraphicsContext graphicsContextWithWindow: graphicwindow];
  context = (CGContextRef)[mycontext graphicsPort];
};

-(void)FillScreen: (NSColor *)theColor;
{
  CGContextSetRGBFillColor(context, [theColor redComponent], [theColor greenComponent], [theColor blueComponent], 1);
  CGContextBeginPath(context);
  CGContextFillRect(context, myCGRect);
  CGContextClosePath(context);
  CGContextFlush(context);
};

-(void)MoveTo: (NSPoint)Position;
{
  if (turtlePenMode)
    {
    // code a line here
    CGContextSetRGBStrokeColor(context, [penColor redComponent], [penColor greenComponent], [penColor blueComponent], 1);
    CGContextSetLineWidth(context, 1);
    CGContextBeginPath(context);
    CGContextMoveToPoint(context, turtlePosition.x - .5, turtlePosition.y - .5);
    CGContextAddLineToPoint(context, Position.x - .5, Position.y - .5);
    CGContextStrokePath(context);
    CGContextClosePath(context);
    CGContextFlush(context);
    };
  turtlePosition = Position;
};


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: drawing and setting pixels
      • From: j o a r <email@hidden>
References: 
 >drawing and setting pixels (From: Robert Dell <email@hidden>)
 >Re: drawing and setting pixels (From: Uli Kusterer <email@hidden>)
 >Re: drawing and setting pixels (From: Robert Dell <email@hidden>)
 >Re: drawing and setting pixels (From: Cameron Hayne <email@hidden>)

  • Prev by Date: NSTextField and NSLineBreakByTruncatingMiddle
  • Next by Date: Re: Cocoa Custom NSCell Binding Issue
  • Previous by thread: Re: drawing and setting pixels
  • Next by thread: Re: drawing and setting pixels
  • Index(es):
    • Date
    • Thread