File: color.html

package info (click to toggle)
pygame 1.9.1release%2Bdfsg-10
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 7,280 kB
  • ctags: 6,685
  • sloc: ansic: 41,205; python: 21,987; cpp: 537; objc: 196; php: 92; sh: 77; makefile: 41
file content (179 lines) | stat: -rw-r--r-- 10,602 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179

<html>
<title>color - Pygame Documentation</title>
<body bgcolor=#aaeebb text=#000000 link=#331111 vlink=#331111>


<table cellpadding=0 cellspacing=0 border=0 style='border: 3px solid black;' width='100%'>
<tr>
<td bgcolor='#c2fc20' style='padding: 6px;' align=center valign=center><a href='http://www.pygame.org/'><img src='../pygame_tiny.gif' border=0 width=200 height=60></a><br><b>pygame documentation</b></td>
<td bgcolor='#6aee28' style='border-left: 3px solid black; padding: 6px;' align=center valign=center>
	||&nbsp;
	<a href=http://www.pygame.org>Pygame Home</a> &nbsp;||&nbsp;
	<a href=../index.html>Help Contents</a> &nbsp;||
	<a href=index.html>Reference Index</a> &nbsp;||
	<br>&nbsp;<br>
	
<a href="camera.html">Camera</a>&nbsp;||&nbsp;
<a href="cdrom.html">Cdrom</a>&nbsp;||&nbsp;
<a href="color.html">Color</a>&nbsp;||&nbsp;
<a href="cursors.html">Cursors</a>&nbsp;||&nbsp;
<a href="display.html">Display</a>&nbsp;||&nbsp;
<a href="draw.html">Draw</a>&nbsp;||&nbsp;
<a href="event.html">Event</a>&nbsp;||&nbsp;
<a href="examples.html">Examples</a>&nbsp;||&nbsp;
<a href="font.html">Font</a>&nbsp;||&nbsp;
<a href="gfxdraw.html">Gfxdraw</a>&nbsp;||&nbsp;
<a href="image.html">Image</a>&nbsp;||&nbsp;
<a href="joystick.html">Joystick</a>&nbsp;||&nbsp;
<a href="key.html">Key</a>&nbsp;||&nbsp;
<a href="locals.html">Locals</a>&nbsp;||&nbsp;
<a href="mask.html">Mask</a>&nbsp;||&nbsp;
<a href="midi.html">Midi</a>&nbsp;||&nbsp;
<a href="mixer.html">Mixer</a>&nbsp;||&nbsp;
<a href="mouse.html">Mouse</a>&nbsp;||&nbsp;
<a href="movie.html">Movie</a>&nbsp;||&nbsp;
<a href="music.html">Music</a>&nbsp;||&nbsp;
<a href="overlay.html">Overlay</a>&nbsp;||&nbsp;
<a href="pixelarray.html">Pixelarray</a>&nbsp;||&nbsp;
<a href="pygame.html">Pygame</a>&nbsp;||&nbsp;
<a href="rect.html">Rect</a>&nbsp;||&nbsp;
<a href="scrap.html">Scrap</a>&nbsp;||&nbsp;
<a href="sndarray.html">Sndarray</a>&nbsp;||&nbsp;
<a href="sprite.html">Sprite</a>&nbsp;||&nbsp;
<a href="surface.html">Surface</a>&nbsp;||&nbsp;
<a href="surfarray.html">Surfarray</a>&nbsp;||&nbsp;
<a href="tests.html">Tests</a>&nbsp;||&nbsp;
<a href="time.html">Time</a>&nbsp;||&nbsp;
<a href="transform.html">Transform</a>
</td></tr></table>
<br>


<a name="pygame.Color">
<big><b>pygame.Color</big></b><br><ul>
  <i>pygame object for color representations</i><br>
  <tt>pygame.Color(name): Return Color</tt><br>
  <tt>pygame.Color(r, g, b, a): Return Color</tt><br>
  <tt>pygame.Color(rgbvalue): Return Color</tt><br>
<ul><small><table>
  <tr><td><a href="color.html#Color.r">Color.r</a> - <font size=-1>Gets or sets the red value of the Color.</font></td><td>Gets or sets the red value of the Color.</td></tr>
  <tr><td><a href="color.html#Color.g">Color.g</a> - <font size=-1>Gets or sets the green value of the Color.</font></td><td>Gets or sets the green value of the Color.</td></tr>
  <tr><td><a href="color.html#Color.b">Color.b</a> - <font size=-1>Gets or sets the blue value of the Color.</font></td><td>Gets or sets the blue value of the Color.</td></tr>
  <tr><td><a href="color.html#Color.a">Color.a</a> - <font size=-1>Gets or sets the alpha value of the Color.</font></td><td>Gets or sets the alpha value of the Color.</td></tr>
  <tr><td><a href="color.html#Color.cmy">Color.cmy</a> - <font size=-1>Gets or sets the CMY representation of the Color.</font></td><td>Gets or sets the CMY representation of the Color.</td></tr>
  <tr><td><a href="color.html#Color.hsva">Color.hsva</a> - <font size=-1>Gets or sets the HSVA representation of the Color.</font></td><td>Gets or sets the HSVA representation of the Color.</td></tr>
  <tr><td><a href="color.html#Color.hsla">Color.hsla</a> - <font size=-1>Gets or sets the HSLA representation of the Color.</font></td><td>Gets or sets the HSLA representation of the Color.</td></tr>
  <tr><td><a href="color.html#Color.i1i2i3">Color.i1i2i3</a> - <font size=-1>Gets or sets the I1I2I3 representation of the Color.</font></td><td>Gets or sets the I1I2I3 representation of the Color.</td></tr>
  <tr><td><a href="color.html#Color.normalize">Color.normalize</a> - <font size=-1>Returns the normalized RGBA values of the Color.</font></td><td>Returns the normalized RGBA values of the Color.</td></tr>
  <tr><td><a href="color.html#Color.correct_gamma">Color.correct_gamma</a> - <font size=-1>Applies a certain gamma value to the Color.</font></td><td>Applies a certain gamma value to the Color.</td></tr>
  <tr><td><a href="color.html#Color.set_length">Color.set_length</a> - <font size=-1>Set the number of elements in the Color to 1,2,3, or 4.</font></td><td>Set the number of elements in the Color to 1,2,3, or 4.</td></tr>
</table></small></ul>
<p>The Color class represents <tt>RGBA</tt> color values using a value range of 0-255. It allows basic arithmetic operations to create new colors, supports conversions to other color spaces such as <tt>HSV</tt> or <tt>HSL</tt> and lets you adjust single color channels. Alpha defaults to 255 when not given. </p>
<p>'rgbvalue' can be either a color name, an <tt>HTML</tt> color format string, a hex number string, or an integer pixel value. The <tt>HTML</tt> format is '#rrggbbaa', where rr, gg, bb, and aa are 2 digit hex numbers. The alpha aa is optional. <tt>A</tt> hex number string has the form '0xrrggbbaa', where aa is optional. </p>
<p>Color objects support equality comparison with other color objects and 3 or 4 element tuples of integers (New in <tt>1.9.0)</tt>. There was a bug in pygame <tt>1.8.1</tt> where the default alpha was 0, not 255 like previously. </p>
<p>New implementation of Color was done in pygame <tt>1.8.1</tt>. </p>
<!--COMMENTS:pygame.Color--> &nbsp;<br> 


<a name="Color.r">
<big><b>Color.r</big></b><br><ul>
  <i>Gets or sets the red value of the Color.</i><br>
  <tt>Color.r: Return int</tt><br>
<p>The red value of the Color. </p>
<!--COMMENTS:Color.r--> &nbsp;<br> 
<br></ul>


<a name="Color.g">
<big><b>Color.g</big></b><br><ul>
  <i>Gets or sets the green value of the Color.</i><br>
  <tt>Color.g: Return int</tt><br>
<p>The green value of the Color. </p>
<!--COMMENTS:Color.g--> &nbsp;<br> 
<br></ul>


<a name="Color.b">
<big><b>Color.b</big></b><br><ul>
  <i>Gets or sets the blue value of the Color.</i><br>
  <tt>Color.b: Return int</tt><br>
<p>The blue value of the Color. </p>
<!--COMMENTS:Color.b--> &nbsp;<br> 
<br></ul>


<a name="Color.a">
<big><b>Color.a</big></b><br><ul>
  <i>Gets or sets the alpha value of the Color.</i><br>
  <tt>Color.a: Return int</tt><br>
<p>The alpha value of the Color. </p>
<!--COMMENTS:Color.a--> &nbsp;<br> 
<br></ul>


<a name="Color.cmy">
<big><b>Color.cmy</big></b><br><ul>
  <i>Gets or sets the CMY representation of the Color.</i><br>
  <tt>Color.cmy: Return tuple</tt><br>
<p>The <tt>CMY</tt> representation of the Color. The <tt>CMY</tt> components are in the ranges <tt>C</tt> = [0, 1], <tt>M</tt> = [0, 1], <tt>Y</tt> = [0, 1]. Note that this will not return the absolutely exact <tt>CMY</tt> values for the set <tt>RGB</tt> values in all cases. Due to the <tt>RGB</tt> mapping from 0-255 and the <tt>CMY</tt> mapping from 0-1 rounding errors may cause the <tt>CMY</tt> values to differ slightly from what you might expect. </p>
<!--COMMENTS:Color.cmy--> &nbsp;<br> 
<br></ul>


<a name="Color.hsva">
<big><b>Color.hsva</big></b><br><ul>
  <i>Gets or sets the HSVA representation of the Color.</i><br>
  <tt>Color.hsva: Return tuple</tt><br>
<p>The <tt>HSVA</tt> representation of the Color. The <tt>HSVA</tt> components are in the ranges <tt>H</tt> = [0, 360], <tt>S</tt> = [0, 100], <tt>V</tt> = [0, 100], <tt>A</tt> = [0, 100]. Note that this will not return the absolutely exact <tt>HSV</tt> values for the set <tt>RGB</tt> values in all cases. Due to the <tt>RGB</tt> mapping from 0-255 and the <tt>HSV</tt> mapping from 0-100 and 0-360 rounding errors may cause the <tt>HSV</tt> values to differ slightly from what you might expect. </p>
<!--COMMENTS:Color.hsva--> &nbsp;<br> 
<br></ul>


<a name="Color.hsla">
<big><b>Color.hsla</big></b><br><ul>
  <i>Gets or sets the HSLA representation of the Color.</i><br>
  <tt>Color.hsla: Return tuple</tt><br>
<p>The <tt>HSLA</tt> representation of the Color. The <tt>HSLA</tt> components are in the ranges <tt>H</tt> = [0, 360], <tt>S</tt> = [0, 100], <tt>V</tt> = [0, 100], <tt>A</tt> = [0, 100]. Note that this will not return the absolutely exact <tt>HSL</tt> values for the set <tt>RGB</tt> values in all cases. Due to the <tt>RGB</tt> mapping from 0-255 and the <tt>HSL</tt> mapping from 0-100 and 0-360 rounding errors may cause the <tt>HSL</tt> values to differ slightly from what you might expect. </p>
<!--COMMENTS:Color.hsla--> &nbsp;<br> 
<br></ul>


<a name="Color.i1i2i3">
<big><b>Color.i1i2i3</big></b><br><ul>
  <i>Gets or sets the I1I2I3 representation of the Color.</i><br>
  <tt>Color.i1i2i3: Return tuple</tt><br>
<p>The <tt>I1I2I3</tt> representation of the Color. The <tt>I1I2I3</tt> components are in the ranges <tt>I1</tt> = [0, 1], <tt>I2</tt> = <tt>[-0.5</tt>, <tt>0.5]</tt>, <tt>I3</tt> = <tt>[-0.5</tt>, <tt>0.5]</tt>. Note that this will not return the absolutely exact <tt>I1I2I3</tt> values for the set <tt>RGB</tt> values in all cases. Due to the <tt>RGB</tt> mapping from 0-255 and the <tt>I1I2I3</tt> mapping from 0-1 rounding errors may cause the <tt>I1I2I3</tt> values to differ slightly from what you might expect. </p>
<!--COMMENTS:Color.i1i2i3--> &nbsp;<br> 
<br></ul>


<a name="Color.normalize">
<big><b>Color.normalize</big></b><br><ul>
  <i>Returns the normalized RGBA values of the Color.</i><br>
  <tt>Color.normalize(): Return tuple</tt><br>
<p>Returns the normalized <tt>RGBA</tt> values of the Color as floating point values. </p>
<!--COMMENTS:Color.normalize--> &nbsp;<br> 
<br></ul>


<a name="Color.correct_gamma">
<big><b>Color.correct_gamma</big></b><br><ul>
  <i>Applies a certain gamma value to the Color.</i><br>
  <tt>Color.correct_gamma (gamma): Return Color</tt><br>
<p>Applies a certain gamma value to the Color and returns a new Color with the adjusted <tt>RGBA</tt> values. </p>
<!--COMMENTS:Color.correct_gamma--> &nbsp;<br> 
<br></ul>


<a name="Color.set_length">
<big><b>Color.set_length</big></b><br><ul>
  <i>Set the number of elements in the Color to 1,2,3, or 4.</i><br>
  <tt>Color.set_length(len)</tt><br>
<p>The default Color length is 4. Colors can have lengths 1,2,3 or 4. This is useful if you want to unpack to r,g,b and not r,g,b,a. If you want to get the length of a Color do len(acolor). </p>
<p>New in pygame <tt>1.9.0</tt>. </p>
<!--COMMENTS:Color.set_length--> &nbsp;<br> 
<br></ul>
<br></ul>

</body></html>