Re: drawing and setting pixels
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