Re: Drawing gradients in views
Re: Drawing gradients in views
- Subject: Re: Drawing gradients in views
- From: Joseph Jones <email@hidden>
- Date: Tue, 28 Jan 2003 10:47:19 -0800
Here is an example:
@interface NSBezierPath(MyCategory)
- (void) myInterfaceMethod;
@end
@implementation NSBezierPath(MyCategory)
- (void) myInterfaceMethod
{
//Some Code here
}
@end
Joe
>
From: "Ian G. Gillespie" <email@hidden>
>
Date: Tue, 28 Jan 2003 09:11:27 -0800
>
To: email@hidden
>
Subject: Re: Drawing gradients in views
>
>
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.
_______________________________________________
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.