• 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 gradients in views
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Drawing gradients in views


  • Subject: Re: Drawing gradients in views
  • From: "Ian G. Gillespie" <email@hidden>
  • Date: Tue, 28 Jan 2003 09:11:27 -0800

Excuse my ignorance (I am still learning, that is for sure), but how do I add a method to the NSBezierPath "category"?

Thanks for all of the help,
Ian

On Tuesday, January 28, 2003, at 01:33 AM, Christopher Holland wrote:

and here is my implementation of a gradient draw rect function (which I
guess could be added to the NSBezierPath category as well??)

- (void)_drawRect:(NSRect)rect withGradientFrom:(NSColor*)colorStart
to:(NSColor*)colorEnd
{
NSRect t1, t2, t3;
float r, g, b,a;
float rdiff, gdiff, bdiff, adiff;
int i;
int index = rect.size.height;
t1 = rect;

r = [colorStart redComponent];
g = [colorStart greenComponent];
b = [colorStart blueComponent];
a = [colorStart alphaComponent];

rdiff = ([colorEnd redComponent] - r)/index;
gdiff = ([colorEnd greenComponent] - g)/index;
bdiff = ([colorEnd blueComponent] - b)/index;
adiff = ([colorEnd alphaComponent] - a)/index;

for ( i = 0; i < index; i++ )
{
NSDivideRect ( t1, &t2, &t3, 1.0, NSMinYEdge);
[[NSColor colorWithDeviceRed:r green:g blue:b alpha:a] set];
NSRectFillUsingOperation(t2, NSCompositeSourceOver);
r += rdiff;
g += gdiff;
b += bdiff;
a += adiff;
t1 = t3;
}
}


joe
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Drawing gradients in views
      • From: Joseph Jones <email@hidden>
References: 
 >Re: Drawing gradients in views (From: Christopher Holland <email@hidden>)

  • Prev by Date: Re: creating an input manager
  • Next by Date: Hierarchal Archiving
  • Previous by thread: Re: Drawing gradients in views
  • Next by thread: Re: Drawing gradients in views
  • Index(es):
    • Date
    • Thread