Re: Banding/smoothing problem with drawing angled gradients.
Re: Banding/smoothing problem with drawing angled gradients.
- Subject: Re: Banding/smoothing problem with drawing angled gradients.
- From: mm w <email@hidden>
- Date: Thu, 19 Mar 2009 21:41:22 -0700
seriously you should think to use a GLView,
you also have to think to lock your context...
2009/3/19 Phi Le <email@hidden>:
> 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 (email@hidden)
>
> 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:
>
> This email sent to email@hidden
>
--
-mmw
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden