1 | /****************************************************************************** |
---|
2 | * $Id: ProgressGradients.m 6995 2008-10-31 00:13:50Z 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 "ProgressGradients.h" |
---|
26 | #import "CTGradient.h" |
---|
27 | |
---|
28 | @implementation ProgressGradients |
---|
29 | |
---|
30 | + (CTGradient *) progressGradientForRed: (CGFloat) redComponent green: (CGFloat) greenComponent blue: (CGFloat) blueComponent |
---|
31 | { |
---|
32 | CTGradientElement color1; |
---|
33 | color1.red = redComponent; |
---|
34 | color1.green = greenComponent; |
---|
35 | color1.blue = blueComponent; |
---|
36 | color1.alpha = 1.0f; |
---|
37 | color1.position = 0.0f; |
---|
38 | |
---|
39 | CTGradientElement color2; |
---|
40 | color2.red = redComponent * 0.95f; |
---|
41 | color2.green = greenComponent * 0.95f; |
---|
42 | color2.blue = blueComponent * 0.95f; |
---|
43 | color2.alpha = 1.0f; |
---|
44 | color2.position = 0.5f; |
---|
45 | |
---|
46 | CTGradientElement color3; |
---|
47 | color3.red = redComponent * 0.85f; |
---|
48 | color3.green = greenComponent * 0.85f; |
---|
49 | color3.blue = blueComponent * 0.85f; |
---|
50 | color3.alpha = 1.0f; |
---|
51 | color3.position = 0.5f; |
---|
52 | |
---|
53 | CTGradientElement color4; |
---|
54 | color4.red = redComponent; |
---|
55 | color4.green = greenComponent; |
---|
56 | color4.blue = blueComponent; |
---|
57 | color4.alpha = 1.0f; |
---|
58 | color4.position = 1.0f; |
---|
59 | |
---|
60 | CTGradient * newInstance = [[[self class] alloc] init]; |
---|
61 | [newInstance addElement: &color1]; |
---|
62 | [newInstance addElement: &color2]; |
---|
63 | [newInstance addElement: &color3]; |
---|
64 | [newInstance addElement: &color4]; |
---|
65 | |
---|
66 | return [newInstance autorelease]; |
---|
67 | } |
---|
68 | |
---|
69 | CTGradient * fProgressWhiteGradient = nil; |
---|
70 | + (CTGradient *) progressWhiteGradient |
---|
71 | { |
---|
72 | if (!fProgressWhiteGradient) |
---|
73 | fProgressWhiteGradient = [[[self class] progressGradientForRed: 0.95f green: 0.95f blue: 0.95f] retain]; |
---|
74 | return fProgressWhiteGradient; |
---|
75 | } |
---|
76 | |
---|
77 | CTGradient * fProgressGrayGradient = nil; |
---|
78 | + (CTGradient *) progressGrayGradient |
---|
79 | { |
---|
80 | if (!fProgressGrayGradient) |
---|
81 | fProgressGrayGradient = [[[self class] progressGradientForRed: 0.7f green: 0.7f blue: 0.7f] retain]; |
---|
82 | return fProgressGrayGradient; |
---|
83 | } |
---|
84 | |
---|
85 | CTGradient * fProgressLightGrayGradient = nil; |
---|
86 | + (CTGradient *) progressLightGrayGradient |
---|
87 | { |
---|
88 | if (!fProgressLightGrayGradient) |
---|
89 | fProgressLightGrayGradient = [[[self class] progressGradientForRed: 0.87f green: 0.87f blue: 0.87f] retain]; |
---|
90 | return fProgressLightGrayGradient; |
---|
91 | } |
---|
92 | |
---|
93 | CTGradient * fProgressBlueGradient = nil; |
---|
94 | + (CTGradient *) progressBlueGradient |
---|
95 | { |
---|
96 | if (!fProgressBlueGradient) |
---|
97 | fProgressBlueGradient = [[[self class] progressGradientForRed: 0.35f green: 0.67f blue: 0.98f] retain]; |
---|
98 | return fProgressBlueGradient; |
---|
99 | } |
---|
100 | |
---|
101 | CTGradient * fProgressDarkBlueGradient = nil; |
---|
102 | + (CTGradient *) progressDarkBlueGradient |
---|
103 | { |
---|
104 | if (!fProgressDarkBlueGradient) |
---|
105 | fProgressDarkBlueGradient = [[[self class] progressGradientForRed: 0.616f green: 0.722f blue: 0.776f] retain]; |
---|
106 | return fProgressDarkBlueGradient; |
---|
107 | } |
---|
108 | |
---|
109 | CTGradient * fProgressGreenGradient = nil; |
---|
110 | + (CTGradient *) progressGreenGradient |
---|
111 | { |
---|
112 | if (!fProgressGreenGradient) |
---|
113 | fProgressGreenGradient = [[[self class] progressGradientForRed: 0.44f green: 0.89f blue: 0.40f] retain]; |
---|
114 | return fProgressGreenGradient; |
---|
115 | } |
---|
116 | |
---|
117 | CTGradient * fProgressLightGreenGradient = nil; |
---|
118 | + (CTGradient *) progressLightGreenGradient |
---|
119 | { |
---|
120 | if (!fProgressLightGreenGradient) |
---|
121 | fProgressLightGreenGradient = [[[self class] progressGradientForRed: 0.62f green: 0.99f blue: 0.58f] retain]; |
---|
122 | return fProgressLightGreenGradient; |
---|
123 | } |
---|
124 | |
---|
125 | CTGradient * fProgressDarkGreenGradient = nil; |
---|
126 | + (CTGradient *) progressDarkGreenGradient |
---|
127 | { |
---|
128 | if (!fProgressDarkGreenGradient) |
---|
129 | fProgressDarkGreenGradient = [[[self class] progressGradientForRed: 0.627f green: 0.714f blue: 0.639f] retain]; |
---|
130 | return fProgressDarkGreenGradient; |
---|
131 | } |
---|
132 | |
---|
133 | CTGradient * fProgressRedGradient = nil; |
---|
134 | + (CTGradient *) progressRedGradient |
---|
135 | { |
---|
136 | if (!fProgressRedGradient) |
---|
137 | fProgressRedGradient = [[[self class] progressGradientForRed: 0.902f green: 0.439f blue: 0.451f] retain]; |
---|
138 | return fProgressRedGradient; |
---|
139 | } |
---|
140 | |
---|
141 | CTGradient * fProgressYellowGradient = nil; |
---|
142 | + (CTGradient *) progressYellowGradient |
---|
143 | { |
---|
144 | if (!fProgressYellowGradient) |
---|
145 | fProgressYellowGradient = [[[self class] progressGradientForRed: 0.933f green: 0.890f blue: 0.243f] retain]; |
---|
146 | return fProgressYellowGradient; |
---|
147 | } |
---|
148 | |
---|
149 | @end |
---|