pythonverse

Python-based client for OpenVerse with extra features
git clone https://code.literati.org/pythonverse.git
Log | Files | Refs | README | LICENSE

commit 028597def35a20a62255be5710f6931f29491753
parent 3a694827f3b8807afdf6dbc5c6b5f5f427cb544a
Author: renze <renze>
Date:   Fri,  1 Feb 2002 00:09:09 +0000

Some functions for handling OpenVerse colors

Diffstat:
Acolor.py | 65+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 65 insertions(+), 0 deletions(-)

diff --git a/color.py b/color.py @@ -0,0 +1,65 @@ +# -*-Python-*- +# Copyright (c) 2002 Sean R. Lynch <seanl@chaosring.org> +# +# This file is part of PythonVerse. +# +# PythonVerse is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# PythonVerse is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with PythonVerse; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# vim:syntax=python + +def by_name(colorname): + if colorname == 'white': return (255, 255, 255) + if colorname == 'black': return (0, 0, 0) + if colorname == 'navy blue': return (0, 0, 128) + if colorname == 'dark green': return (0, 100, 0) + if colorname == 'red': return (255, 0, 0) + if colorname == 'brown': return (165, 42, 42) + if colorname == 'magenta': return (255, 0, 255) + if colorname == 'orange': return (255, 165, 0) + if colorname == 'yellow': return (255, 255, 0) + if colorname == 'green': return (0, 255, 0) + if colorname == 'teal': return (0, 127, 127) + if colorname == 'cyan': return (0, 255, 255) + if colorname == 'blue': return (0, 0, 255) + if colorname == 'hot pink': return (255, 105, 180) + if colorname == 'dark grey': return (169, 169, 169) + if colorname == 'light grey': return (211, 211, 211) + return (255, 255, 255) # if all else fails + +def by_hex(colorhex): + colorhex = colorhex[1:] # strip the leading hash sign + red = int(colorhex[0:2], 16) + green = int(colorhex[2:4], 16) + blue = int(colorhex[4:], 16) + return (red, green, blue) + +def by_number(colornumber): + if colornumber == 0 or colornumber == 99: return (255, 255, 255) + if colornumber == 1: return (0, 0, 0) + if colornumber == 2: return (0, 0, 128) + if colornumber == 3: return (0, 100, 0) + if colornumber == 4: return (255, 0, 0) + if colornumber == 5: return (165, 42, 42) + if colornumber == 6: return (255, 0, 255) + if colornumber == 7: return (255, 165, 0) + if colornumber == 8: return (255, 255, 0) + if colornumber == 9: return (0, 255, 0) + if colornumber == 10: return (0, 127, 127) + if colornumber == 11: return (0, 255, 255) + if colornumber == 12: return (0, 0, 255) + if colornumber == 13: return (255, 105, 180) + if colornumber == 14: return (169, 169, 169) + if colornumber == 15: return (211, 211, 211) + return (255, 255, 255) # if all else fails