transmission/macosx/ProgressGradients.m

150 lines
5.2 KiB
Mathematica
Raw Normal View History

2007-09-16 01:02:06 +00:00
/******************************************************************************
* $Id$
*
2008-03-28 21:33:07 +00:00
* Copyright (c) 2007-2008 Transmission authors and contributors
2007-09-16 01:02:06 +00:00
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*****************************************************************************/
#import "ProgressGradients.h"
#import "CTGradient.h"
2007-09-16 01:02:06 +00:00
@implementation ProgressGradients
2007-09-16 01:02:06 +00:00
+ (CTGradient *) progressGradientForRed: (CGFloat) redComponent green: (CGFloat) greenComponent blue: (CGFloat) blueComponent
2007-09-16 01:02:06 +00:00
{
CTGradientElement color1;
color1.red = redComponent;
color1.green = greenComponent;
color1.blue = blueComponent;
2008-10-28 00:08:49 +00:00
color1.alpha = 1.0f;
color1.position = 0.0f;
2007-09-16 01:02:06 +00:00
CTGradientElement color2;
2008-10-28 00:08:49 +00:00
color2.red = redComponent * 0.95f;
color2.green = greenComponent * 0.95f;
color2.blue = blueComponent * 0.95f;
color2.alpha = 1.0f;
color2.position = 0.5f;
2007-09-16 01:02:06 +00:00
CTGradientElement color3;
2008-10-28 00:08:49 +00:00
color3.red = redComponent * 0.85f;
color3.green = greenComponent * 0.85f;
color3.blue = blueComponent * 0.85f;
color3.alpha = 1.0f;
color3.position = 0.5f;
2007-09-16 01:02:06 +00:00
CTGradientElement color4;
color4.red = redComponent;
color4.green = greenComponent;
color4.blue = blueComponent;
2008-10-28 00:08:49 +00:00
color4.alpha = 1.0f;
color4.position = 1.0f;
2007-09-16 01:02:06 +00:00
2008-10-31 00:27:20 +00:00
CTGradient * newInstance = [[CTGradient alloc] init];
[newInstance addElement: &color1];
[newInstance addElement: &color2];
[newInstance addElement: &color3];
[newInstance addElement: &color4];
2007-09-16 01:02:06 +00:00
return [newInstance autorelease];
}
CTGradient * fProgressWhiteGradient = nil;
+ (CTGradient *) progressWhiteGradient
{
if (!fProgressWhiteGradient)
2008-10-28 00:08:49 +00:00
fProgressWhiteGradient = [[[self class] progressGradientForRed: 0.95f green: 0.95f blue: 0.95f] retain];
return fProgressWhiteGradient;
}
CTGradient * fProgressGrayGradient = nil;
+ (CTGradient *) progressGrayGradient
2007-09-16 01:02:06 +00:00
{
if (!fProgressGrayGradient)
2008-10-28 00:08:49 +00:00
fProgressGrayGradient = [[[self class] progressGradientForRed: 0.7f green: 0.7f blue: 0.7f] retain];
return fProgressGrayGradient;
2007-09-16 01:02:06 +00:00
}
CTGradient * fProgressLightGrayGradient = nil;
+ (CTGradient *) progressLightGrayGradient
2007-09-16 01:02:06 +00:00
{
if (!fProgressLightGrayGradient)
2008-10-28 00:08:49 +00:00
fProgressLightGrayGradient = [[[self class] progressGradientForRed: 0.87f green: 0.87f blue: 0.87f] retain];
return fProgressLightGrayGradient;
2007-09-16 01:02:06 +00:00
}
CTGradient * fProgressBlueGradient = nil;
+ (CTGradient *) progressBlueGradient
2007-09-16 01:02:06 +00:00
{
if (!fProgressBlueGradient)
2008-10-28 00:08:49 +00:00
fProgressBlueGradient = [[[self class] progressGradientForRed: 0.35f green: 0.67f blue: 0.98f] retain];
return fProgressBlueGradient;
2007-09-16 01:02:06 +00:00
}
CTGradient * fProgressDarkBlueGradient = nil;
+ (CTGradient *) progressDarkBlueGradient
2007-09-16 01:02:06 +00:00
{
if (!fProgressDarkBlueGradient)
2008-10-28 00:08:49 +00:00
fProgressDarkBlueGradient = [[[self class] progressGradientForRed: 0.616f green: 0.722f blue: 0.776f] retain];
return fProgressDarkBlueGradient;
2007-09-16 01:02:06 +00:00
}
CTGradient * fProgressGreenGradient = nil;
+ (CTGradient *) progressGreenGradient
2007-09-16 01:02:06 +00:00
{
if (!fProgressGreenGradient)
2008-10-28 00:08:49 +00:00
fProgressGreenGradient = [[[self class] progressGradientForRed: 0.44f green: 0.89f blue: 0.40f] retain];
return fProgressGreenGradient;
2007-09-16 01:02:06 +00:00
}
CTGradient * fProgressLightGreenGradient = nil;
+ (CTGradient *) progressLightGreenGradient
2007-09-16 01:02:06 +00:00
{
if (!fProgressLightGreenGradient)
2008-10-28 00:08:49 +00:00
fProgressLightGreenGradient = [[[self class] progressGradientForRed: 0.62f green: 0.99f blue: 0.58f] retain];
return fProgressLightGreenGradient;
2007-09-16 01:02:06 +00:00
}
CTGradient * fProgressDarkGreenGradient = nil;
+ (CTGradient *) progressDarkGreenGradient
2007-09-16 01:02:06 +00:00
{
if (!fProgressDarkGreenGradient)
2008-10-28 00:08:49 +00:00
fProgressDarkGreenGradient = [[[self class] progressGradientForRed: 0.627f green: 0.714f blue: 0.639f] retain];
return fProgressDarkGreenGradient;
2007-09-16 01:02:06 +00:00
}
CTGradient * fProgressRedGradient = nil;
+ (CTGradient *) progressRedGradient
2007-11-11 21:45:27 +00:00
{
if (!fProgressRedGradient)
2008-10-28 00:08:49 +00:00
fProgressRedGradient = [[[self class] progressGradientForRed: 0.902f green: 0.439f blue: 0.451f] retain];
return fProgressRedGradient;
2007-11-11 21:45:27 +00:00
}
CTGradient * fProgressYellowGradient = nil;
+ (CTGradient *) progressYellowGradient
2007-09-16 01:02:06 +00:00
{
if (!fProgressYellowGradient)
2008-10-28 00:08:49 +00:00
fProgressYellowGradient = [[[self class] progressGradientForRed: 0.933f green: 0.890f blue: 0.243f] retain];
return fProgressYellowGradient;
2007-09-16 01:02:06 +00:00
}
@end