1 """
2 * Copyright 2008 Google Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy of
6 * the License at
7 *
8 * http:#www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
14 * the License.
15 """
16
17
18 """*
19 * Simple Wrapper specifying a color in RGB format.
20 * Provides various methods for converting to String representations
21 * of the specified color for easy compatibility with various APIs
22 """
24
25 """*
26 * Create a using a valid CSSString.
27 * We do not do any validation so be careful!
28 """
29 """*
30 * Create a object with the specified RGB
31 * values.
32 *
33 * @param r red value 0-255
34 * @param g green value 0-255
35 * @param b blue value 0-255
36 """
37 """*
38 * Create a object with the specified RGBA
39 * values.
40 *
41 * @param r red value 0-255
42 * @param g green value 0-255
43 * @param b blue value 0-255
44 * @param a alpha channel value 0-1
45 """
46 - def __init__(self, r, g=None, b=None, a=None):
47 if g is None and b is None and a is None:
48 self.colorStr = r
49 elif a is None:
50 self.colorStr = "rgb(%d,%d,%d)" % (r, g, b)
51 else:
52 self.colorStr = "rgba(%d,%d,%d,%d)" % (r, g, b, a)
53
56
57
58
59 """
60 * Some basic color strings that are often used for the web.
61 * Compiler should optimize these out if they are not used.
62 """
63 ALPHA_GREY = Color("rgba(0,0,0,0.3)")
64 ALPHA_RED = Color("rgba(255,0,0,0.3)")
65 BLACK = Color("#000000")
66 BLUE = Color("#318ce0")
67 BLUEVIOLET = Color("#8a2be2")
68 CYAN = Color("#5fa2e0")
69 GREEN = Color("#23ef24")
70 GREY = Color("#a9a9a9")
71 LIGHTGREY = Color("#eeeeee")
72 ORANGE = Color("#f88247")
73 PEACH = Color("#ffd393")
74 PINK = Color("#ff00ff")
75 RED = Color("#ff0000")
76 SKY_BLUE = Color("#c6defa")
77 WHITE = Color("#ffffff")
78 YELLOW = Color("yellow")
79 DARK_ORANGE = Color("#c44607")
80 BRIGHT_ORANGE = Color("#fb5c0c")
81 DARK_BLUE = Color("#0c6ac1")
82