FROM : Joseph Jones
DATE : Tue Jan 28 19:47:19 2003
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_removed>>
> Date: Tue, 28 Jan 2003 09:11:27 -0800
> To: <email_removed>
> 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_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.
_______________________________________________
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.
DATE : Tue Jan 28 19:47:19 2003
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_removed>>
> Date: Tue, 28 Jan 2003 09:11:27 -0800
> To: <email_removed>
> 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_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.
_______________________________________________
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 mails | Author | Date |
|---|---|---|
| Ian G. Gillespie | Jan 28, 03:52 | |
| Matt Gemmell | Jan 28, 04:26 | |
| Joseph Jones | Jan 28, 04:42 | |
| Christopher Hollan… | Jan 28, 10:33 | |
| Brock Brandenberg | Jan 28, 15:27 | |
| Ian G. Gillespie | Jan 28, 18:11 | |
| Joseph Jones | Jan 28, 19:47 | |
| Erik M. Buck | Jan 28, 20:04 | |
| Erik M. Buck | Jan 28, 20:51 | |
| Ian G. Gillespie | Jan 28, 21:14 | |
| John C. Randolph | Jan 28, 21:58 | |
| Ian G. Gillespie | Jan 28, 23:17 | |
| Matt Gemmell | Jan 29, 03:01 | |
| Christopher Hollan… | Jan 29, 04:19 |






Cocoa mail archive

