18 # You should have received a copy of the GNU General Public License |
18 # You should have received a copy of the GNU General Public License |
19 # along with GNU Emacs; see the file COPYING. If not, write to the |
19 # along with GNU Emacs; see the file COPYING. If not, write to the |
20 # Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 # Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
21 # Boston, MA 02111-1307, USA. |
21 # Boston, MA 02111-1307, USA. |
22 |
22 |
23 _version_ = "$Id: immsview 1704 2004-02-07 00:53:02Z fabien $" |
23 _version_ = "$Id: immsview 1706 2004-02-07 01:18:41Z fabien $" |
24 |
24 |
25 # $Log$ |
25 # $Log$ |
|
26 # Revision 1.24 2004/02/07 01:18:41 fabien |
|
27 # Better like a four colors gradient. |
|
28 # |
26 # Revision 1.23 2004/02/07 00:53:02 fabien |
29 # Revision 1.23 2004/02/07 00:53:02 fabien |
27 # Make a gradient of color instead... |
30 # Make a gradient of color instead... |
28 # I'm not sure which one I prefer however. |
31 # I'm not sure which one I prefer however. |
29 # |
32 # |
30 # Revision 1.22 2004/02/06 06:10:49 fabien |
33 # Revision 1.22 2004/02/06 06:10:49 fabien |
234 print tune[2] |
237 print tune[2] |
235 tune = cu.fetchone() |
238 tune = cu.fetchone() |
236 return results |
239 return results |
237 |
240 |
238 _gdk_colors = [] |
241 _gdk_colors = [] |
239 for i in range(150-75+1): |
242 for i in range(76): |
240 med = (150-75+1)/2 |
243 if i <= 25: |
241 if i > med: |
244 red = 255 |
|
245 green = i * 255 / med |
|
246 blue = 0 |
|
247 elif i <= 50: |
|
248 red = (50-i) * 255 / 25 |
242 green = 255 |
249 green = 255 |
243 red = (2*med-i) * 255 / med |
250 blue = 0 |
244 else: |
251 else: |
245 green = i * 255 / med |
252 green = 0 |
246 red = 255 |
253 green = 255 |
247 blue = 0 |
254 blue = (i-50) * 255 / 25 |
248 _gdk_colors.append("#%02X%02X%02X" % (red, green, blue)) |
255 _gdk_colors.append("#%02X%02X%02X" % (red, green, blue)) |
249 |
256 |
250 def rating_to_color(rate): |
257 def rating_to_color(rate): |
251 rate = min(max(rate,75),150) |
258 rate = min(max(rate,75),150) |
252 return _gdk_colors[rate-75] |
259 return _gdk_colors[rate-75] |