seriously you should think to use a GLView, you also have to think to lock your context...
2009/3/19 Phi Le <iam...@gmail.com>: > Hello, > > I want to draw angled gradients with multiple sharp transitions using > NSGradient. I am not getting very smooth transitions between the > colors. Please take a look at my attachment to see the problem. Are > there solutions without having to use NSShading? > > Thanks, > > Phi > > > <code> > - (void) drawRect: (NSRect) rect { > [[NSGraphicsContext currentContext] setShouldAntialias:YES]; > float locs[8] = {0.0, 0.25, 0.3, 0.35, 0.5, 0.6, 0.7, 1.0 }; > NSMutableArray * colors = [[NSMutableArray alloc] init]; > > [colors addObject: [NSColor blackColor]]; > > [colors addObject: [NSColor blackColor]]; > [colors addObject: [NSColor greenColor]]; > [colors addObject: [NSColor blackColor]]; > > [colors addObject: [NSColor blackColor]]; > [colors addObject: [NSColor redColor]]; > [colors addObject: [NSColor blackColor]]; > > [colors addObject: [NSColor blackColor]]; > > NSColorSpace * space = [NSColorSpace genericRGBColorSpace]; > NSGradient * gradient = [[NSGradient alloc] initWithColors:colors > atLocations:&locs colorSpace: space]; > > float angle = 0; > for(int r = 0; r < 5; r++) { > for(int c = 0; c < 3; c++) { > [gradient drawInRect:NSMakeRect(c*200, r*90, > 180, 80) angle: angle]; > angle += 5; > } > } > } > </code> > > _______________________________________________ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please 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/openspecies%40gmail.com > > This email sent to openspec...@gmail.com > -- -mmw _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please 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/archive%40mail-archive.com This email sent to arch...@mail-archive.com