source: trunk/macosx/CTGradient/CTGradientAdditions.m @ 6974

Last change on this file since 6974 was 6974, checked in by livings124, 14 years ago

more trivial type changes

  • Property svn:keywords set to Date Rev Author Id
File size: 5.2 KB
Line 
1/******************************************************************************
2 * $Id: CTGradientAdditions.m 6974 2008-10-28 00:08:49Z livings124 $
3 *
4 * Copyright (c) 2007-2008 Transmission authors and contributors
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *****************************************************************************/
24
25#import "CTGradientAdditions.h"
26
27@implementation CTGradient (ProgressBar)
28
29+ (CTGradient *) progressGradientForRed: (CGFloat) redComponent green: (CGFloat) greenComponent blue: (CGFloat) blueComponent
30{
31    CTGradientElement color1;
32    color1.red = redComponent;
33    color1.green = greenComponent;
34    color1.blue = blueComponent;
35    color1.alpha = 1.0f;
36    color1.position = 0.0f;
37   
38    CTGradientElement color2;
39    color2.red = redComponent * 0.95f;
40    color2.green = greenComponent * 0.95f;
41    color2.blue = blueComponent * 0.95f;
42    color2.alpha = 1.0f;
43    color2.position = 0.5f;
44   
45    CTGradientElement color3;
46    color3.red = redComponent * 0.85f;
47    color3.green = greenComponent * 0.85f;
48    color3.blue = blueComponent * 0.85f;
49    color3.alpha = 1.0f;
50    color3.position = 0.5f;
51   
52    CTGradientElement color4;
53    color4.red = redComponent;
54    color4.green = greenComponent;
55    color4.blue = blueComponent;
56    color4.alpha = 1.0f;
57    color4.position = 1.0f;
58   
59    CTGradient * newInstance = [[[self class] alloc] init];
60    [newInstance addElement: &color1];
61    [newInstance addElement: &color2];
62    [newInstance addElement: &color3];
63    [newInstance addElement: &color4];
64   
65    return [newInstance autorelease];
66}
67
68CTGradient * fProgressWhiteGradient = nil;
69+ (CTGradient *) progressWhiteGradient
70{
71    if (!fProgressWhiteGradient)
72        fProgressWhiteGradient = [[[self class] progressGradientForRed: 0.95f green: 0.95f blue: 0.95f] retain];
73    return fProgressWhiteGradient;
74}
75
76CTGradient * fProgressGrayGradient = nil;
77+ (CTGradient *) progressGrayGradient
78{
79    if (!fProgressGrayGradient)
80        fProgressGrayGradient = [[[self class] progressGradientForRed: 0.7f green: 0.7f blue: 0.7f] retain];
81    return fProgressGrayGradient;
82}
83
84CTGradient * fProgressLightGrayGradient = nil;
85+ (CTGradient *) progressLightGrayGradient
86{
87    if (!fProgressLightGrayGradient)
88        fProgressLightGrayGradient = [[[self class] progressGradientForRed: 0.87f green: 0.87f blue: 0.87f] retain];
89    return fProgressLightGrayGradient;
90}
91
92CTGradient * fProgressBlueGradient = nil;
93+ (CTGradient *) progressBlueGradient
94{
95    if (!fProgressBlueGradient)
96        fProgressBlueGradient = [[[self class] progressGradientForRed: 0.35f green: 0.67f blue: 0.98f] retain];
97    return fProgressBlueGradient;
98}
99
100CTGradient * fProgressDarkBlueGradient = nil;
101+ (CTGradient *) progressDarkBlueGradient
102{
103    if (!fProgressDarkBlueGradient)
104        fProgressDarkBlueGradient = [[[self class] progressGradientForRed: 0.616f green: 0.722f blue: 0.776f] retain];
105    return fProgressDarkBlueGradient;
106}
107
108CTGradient * fProgressGreenGradient = nil;
109+ (CTGradient *) progressGreenGradient
110{
111    if (!fProgressGreenGradient)
112        fProgressGreenGradient = [[[self class] progressGradientForRed: 0.44f green: 0.89f blue: 0.40f] retain];
113    return fProgressGreenGradient;
114}
115
116CTGradient * fProgressLightGreenGradient = nil;
117+ (CTGradient *) progressLightGreenGradient
118{
119    if (!fProgressLightGreenGradient)
120        fProgressLightGreenGradient = [[[self class] progressGradientForRed: 0.62f green: 0.99f blue: 0.58f] retain];
121    return fProgressLightGreenGradient;
122}
123
124CTGradient * fProgressDarkGreenGradient = nil;
125+ (CTGradient *) progressDarkGreenGradient
126{
127    if (!fProgressDarkGreenGradient)
128        fProgressDarkGreenGradient = [[[self class] progressGradientForRed: 0.627f green: 0.714f blue: 0.639f] retain];
129    return fProgressDarkGreenGradient;
130}
131
132CTGradient * fProgressRedGradient = nil;
133+ (CTGradient *) progressRedGradient
134{
135    if (!fProgressRedGradient)
136        fProgressRedGradient = [[[self class] progressGradientForRed: 0.902f green: 0.439f blue: 0.451f] retain];
137    return fProgressRedGradient;
138}
139
140CTGradient * fProgressYellowGradient = nil;
141+ (CTGradient *) progressYellowGradient
142{
143    if (!fProgressYellowGradient)
144        fProgressYellowGradient = [[[self class] progressGradientForRed: 0.933f green: 0.890f blue: 0.243f] retain];
145    return fProgressYellowGradient;
146}
147
148@end
Note: See TracBrowser for help on using the repository browser.