Skip navigation.
 
mlRe: Drawing gradients in views
FROM : Ian G. Gillespie
DATE : Tue Jan 28 18:11:27 2003

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_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

Related mailsAuthorDate
mlDrawing gradients in views Ian G. Gillespie Jan 28, 03:52
mlRe: Drawing gradients in views Matt Gemmell Jan 28, 04:26
mlRe: Drawing gradients in views Joseph Jones Jan 28, 04:42
mlRe: Drawing gradients in views Christopher Hollan… Jan 28, 10:33
mlRe: Drawing gradients in views Brock Brandenberg Jan 28, 15:27
mlRe: Drawing gradients in views Ian G. Gillespie Jan 28, 18:11
mlRe: Drawing gradients in views Joseph Jones Jan 28, 19:47
mlRe: Drawing gradients in views Erik M. Buck Jan 28, 20:04
mlRe: Drawing gradients in views Erik M. Buck Jan 28, 20:51
mlRe: Drawing gradients in views Ian G. Gillespie Jan 28, 21:14
mlRe: Drawing gradients in views John C. Randolph Jan 28, 21:58
mlRe: Drawing gradients in views Ian G. Gillespie Jan 28, 23:17
mlRe: Drawing gradients in views Matt Gemmell Jan 29, 03:01
mlRe: Drawing gradients in views Christopher Hollan… Jan 29, 04:19