~ubuntu-branches/ubuntu/maverick/pygame/maverick

« back to all changes in this revision

Viewing changes to docs/ref/pixelarray.html

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2010-01-14 17:02:11 UTC
  • mfrom: (1.3.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100114170211-21eop2ja7mr9vdcr
Tags: 1.9.1release-0ubuntu1
* New upstream version (lp: #433304)
* debian/control:
  - build-depends on libportmidi-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
<html>
3
 
<title>pixelarray - Pygame Documentation</title>
4
 
<body bgcolor=#aaeebb text=#000000 link=#331111 vlink=#331111>
5
 
 
6
 
 
7
 
<table cellpadding=0 cellspacing=0 border=0 style='border: 3px solid black;' width='100%'>
8
 
<tr>
9
 
<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>
10
 
<td bgcolor='#6aee28' style='border-left: 3px solid black; padding: 6px;' align=center valign=center>
11
 
        ||&nbsp;
12
 
        <a href=http://www.pygame.org>Pygame Home</a> &nbsp;||&nbsp;
13
 
        <a href=../index.html>Help Contents</a> &nbsp;||
14
 
        <a href=index.html>Reference Index</a> &nbsp;||
15
 
        <br>&nbsp;<br>
16
 
        
17
 
<a href="cdrom.html">Cdrom</a>&nbsp;||&nbsp;
18
 
<a href="color.html">Color</a>&nbsp;||&nbsp;
19
 
<a href="cursors.html">Cursors</a>&nbsp;||&nbsp;
20
 
<a href="display.html">Display</a>&nbsp;||&nbsp;
21
 
<a href="draw.html">Draw</a>&nbsp;||&nbsp;
22
 
<a href="event.html">Event</a>&nbsp;||&nbsp;
23
 
<a href="font.html">Font</a>&nbsp;||&nbsp;
24
 
<a href="image.html">Image</a>&nbsp;||&nbsp;
25
 
<a href="joystick.html">Joystick</a>&nbsp;||&nbsp;
26
 
<a href="key.html">Key</a>&nbsp;||&nbsp;
27
 
<a href="mask.html">Mask</a>&nbsp;||&nbsp;
28
 
<a href="mixer.html">Mixer</a>&nbsp;||&nbsp;
29
 
<a href="mouse.html">Mouse</a>&nbsp;||&nbsp;
30
 
<a href="movie.html">Movie</a>&nbsp;||&nbsp;
31
 
<a href="music.html">Music</a>&nbsp;||&nbsp;
32
 
<a href="overlay.html">Overlay</a>&nbsp;||&nbsp;
33
 
<a href="pixelarray.html">Pixelarray</a>&nbsp;||&nbsp;
34
 
<a href="pygame.html">Pygame</a>&nbsp;||&nbsp;
35
 
<a href="rect.html">Rect</a>&nbsp;||&nbsp;
36
 
<a href="scrap.html">Scrap</a>&nbsp;||&nbsp;
37
 
<a href="sndarray.html">Sndarray</a>&nbsp;||&nbsp;
38
 
<a href="sprite.html">Sprite</a>&nbsp;||&nbsp;
39
 
<a href="surface.html">Surface</a>&nbsp;||&nbsp;
40
 
<a href="surfarray.html">Surfarray</a>&nbsp;||&nbsp;
41
 
<a href="time.html">Time</a>&nbsp;||&nbsp;
42
 
<a href="transform.html">Transform</a>
43
 
</td></tr></table>
44
 
<br>
45
 
 
46
 
 
47
 
<a name="pygame.PixelArray">
48
 
<big><b>pygame.PixelArray</big></b><br><ul>
49
 
  <i>pygame object for direct pixel access of surfaces</i><br>
50
 
  <tt>pygame.PixelArray(Surface): return PixelArray</tt><br>
51
 
<ul><small><table>
52
 
  <tr><td><a href="pixelarray.html#PixelArray.surface">PixelArray.surface</a> - <font size=-1>Gets the Surface the PixelArray uses.</font></td><td>Gets the Surface the PixelArray uses.</td></tr>
53
 
  <tr><td><a href="pixelarray.html#PixelArray.make_surface">PixelArray.make_surface</a> - <font size=-1>Creates a new Surface from the current PixelArray.</font></td><td>Creates a new Surface from the current PixelArray.</td></tr>
54
 
  <tr><td><a href="pixelarray.html#PixelArray.replace">PixelArray.replace</a> - <font size=-1>Replaces the passed color in the PixelArray with another one.</font></td><td>Replaces the passed color in the PixelArray with another one.</td></tr>
55
 
  <tr><td><a href="pixelarray.html#PixelArray.extract">PixelArray.extract</a> - <font size=-1>Extracts the passed color from the PixelArray.</font></td><td>Extracts the passed color from the PixelArray.</td></tr>
56
 
  <tr><td><a href="pixelarray.html#PixelArray.compare">PixelArray.compare</a> - <font size=-1>Compares the PixelArray with another one.</font></td><td>Compares the PixelArray with another one.</td></tr>
57
 
</table></small></ul>
58
 
<p>The PixelArray wraps up a Surface and provides a direct <tt>2D</tt> array access to its pixels using the surface its rows as first and its columns as second axis. It supports slicing, row and pixel manipluation, slicing and slice assignments while inplace operations such as addition, subtraction, multiplication, division and so forth are not allowed. </p>
59
 
<p>While it is possible to assign both, integer color values and <tt>RGB(A)</tt> color tuples, the PixelArray will only use integers for the color representation. Thus, checking for certain colors has to be done using the <tt><a href="surface.html#Surface.map_rgb">Surface.map_rgb</a> - <font size=-1>convert a color into a mapped color value</font></tt> method of the surface, the PixelArray was created for. </p>
60
 
<pre>  pxarray = pygame.PixelArray (surface)
61
 
  # Check, if the first pixel at the topleft corner is blue
62
 
  if pxarray[0][0] == surface.map_rgb ((0, 0, 255)):
63
 
      ...
64
 
</pre><p>Pixels can be manipulated using integer values or color tuples. </p>
65
 
<pre>  pxarray[x][y] = 0xFF00FF
66
 
  pxarray[x][y] = (255, 0, 255)
67
 
</pre><p>If you operate on a slice, you also can use arbitrary sequences or other PixelArray objects to modify the pixels. They have to match the size of the PixelArray however. </p>
68
 
<pre>  pxarray[a:b] = 0xFF00FF                   # set all pixels to 0xFF00FF
69
 
  pxarray[a:b] = (0xFF00FF, 0xAACCEE, ... ) # first pixel = 0xFF00FF,
70
 
                                            # second pixel  = 0xAACCEE, ...
71
 
  pxarray[a:b] = ((255, 0, 255), (170, 204, 238), ...) # same as above
72
 
  pxarray[a:b] = ((255, 0, 255), 0xAACCEE, ...)        # same as above
73
 
  pxarray[a:b] = otherarray[x:y]            # slice sizes must match
74
 
</pre><p>Note, that something like </p>
75
 
<pre>  pxarray[2:4][3:5] = ...
76
 
</pre><p>will not cause a rectangular manipulation. Instead it will be first sliced to a two-column array, which then shall be sliced by columns once more, which will fail due an IndexError. This is caused by the slicing mechanisms in python and an absolutely correct behaviour. Create a single columned slice first, which you can manipulate then: </p>
77
 
<pre>  pxarray[2][3:5] = ...
78
 
  pxarray[3][3:5] = ...
79
 
</pre><p>If you want to make a rectangular manipulation or create a view of a part of the PixelArray, you also can use the subscript abilities. You can easily create different view by creating 'subarrays' using the subscripts. </p>
80
 
<pre>  # Create some new PixelArray objects providing a different view
81
 
  # of the original array/surface.
82
 
  newarray = pxarray[2:4,3:5]
83
 
  otherarray = pxarray[::2,::2]
84
 
</pre><p>Subscripts also can be used to do fast rectangular pixel manipulations instead of iterating over the x or y axis as above. </p>
85
 
<pre>  pxarray[::2,:] = (0, 0, 0)                # Make each second column black.
86
 
</pre><p>During its lifetime, the PixelArray locks the surface, thus you explicitly have to delete it once its not used anymore and the surface should perform operations in the same scope. </p>
87
 
<p>New in pygame <tt>1.8</tt>. Subscript support is new in pygame <tt>1.8.1</tt>. </p>
88
 
<!--COMMENTS:pygame.PixelArray--> &nbsp;<br> 
89
 
 
90
 
 
91
 
<a name="PixelArray.surface">
92
 
<big><b>PixelArray.surface</big></b><br><ul>
93
 
  <i>Gets the Surface the PixelArray uses.</i><br>
94
 
  <tt>PixelArray.surface: Return Surface</tt><br>
95
 
<p>The Surface, the PixelArray was created for. </p>
96
 
<!--COMMENTS:PixelArray.surface--> &nbsp;<br> 
97
 
<br></ul>
98
 
 
99
 
 
100
 
<a name="PixelArray.make_surface">
101
 
<big><b>PixelArray.make_surface</big></b><br><ul>
102
 
  <i>Creates a new Surface from the current PixelArray.</i><br>
103
 
  <tt>PixelArray.make_surface (): Return Surface</tt><br>
104
 
<p>Creates a new Surface from the current PixelArray. Depending on the current PixelArray the size, pixel order etc. will be different from the original Surface. </p>
105
 
<pre>  # Create a new surface flipped around the vertical axis.
106
 
  sf = pxarray[:,::-1].make_surface ()
107
 
</pre><p>New in pygame <tt>1.8.1</tt>. </p>
108
 
<!--COMMENTS:PixelArray.make_surface--> &nbsp;<br> 
109
 
<br></ul>
110
 
 
111
 
 
112
 
<a name="PixelArray.replace">
113
 
<big><b>PixelArray.replace</big></b><br><ul>
114
 
  <i>Replaces the passed color in the PixelArray with another one.</i><br>
115
 
  <tt>PixelArray.replace (color, repcolor, distance=0, weights=(0.299, 0.587, 0.114)): Return None</tt><br>
116
 
<p>Replaces the pixels with the passed color in the PixelArray by changing them them to the passed replacement color. </p>
117
 
<p>It uses a simple weighted euclidian distance formula to calculate the distance between the colors. The distance space ranges from <tt>0.0</tt> to <tt>1.0</tt> and is used as threshold for the color detection. This causes the replacement to take pixels with a similar, but not exactly identical color, into account as well. </p>
118
 
<p>This is an in place operation that directly affects the pixels of the PixelArray. </p>
119
 
<p>New in pygame <tt>1.8.1</tt>. </p>
120
 
<!--COMMENTS:PixelArray.replace--> &nbsp;<br> 
121
 
<br></ul>
122
 
 
123
 
 
124
 
<a name="PixelArray.extract">
125
 
<big><b>PixelArray.extract</big></b><br><ul>
126
 
  <i>Extracts the passed color from the PixelArray.</i><br>
127
 
  <tt>PixelArray.extract (color, distance=0, weights=(0.299, 0.587, 0.114)): Return PixelArray</tt><br>
128
 
<p>Extracts the passed color by changing all matching pixels to white, while non-matching pixels are changed to black. This returns a new PixelArray with the black/white color mask. </p>
129
 
<p>It uses a simple weighted euclidian distance formula to calculate the distance between the colors. The distance space ranges from <tt>0.0</tt> to <tt>1.0</tt> and is used as threshold for the color detection. This causes the extraction to take pixels with a similar, but not exactly identical color, into account as well. </p>
130
 
<p>New in pygame <tt>1.8.1</tt>. </p>
131
 
<!--COMMENTS:PixelArray.extract--> &nbsp;<br> 
132
 
<br></ul>
133
 
 
134
 
 
135
 
<a name="PixelArray.compare">
136
 
<big><b>PixelArray.compare</big></b><br><ul>
137
 
  <i>Compares the PixelArray with another one.</i><br>
138
 
  <tt>PixelArray.compare (array, distance=0, weights=(0.299, 0.587, 0.114)): Return PixelArray</tt><br>
139
 
<p>Compares the contents of the PixelArray with those from the passed PixelArray. It returns a new PixelArray with a black/white color mask that indicates the differences (white) of both arrays. Both PixelArray objects must have indentical bit depths and dimensions. </p>
140
 
<p>It uses a simple weighted euclidian distance formula to calculate the distance between the colors. The distance space ranges from <tt>0.0</tt> to <tt>1.0</tt> and is used as threshold for the color detection. This causes the comparision to mark pixels with a similar, but not exactly identical color, as black. </p>
141
 
<p>New in pygame <tt>1.8.1</tt>. </p>
142
 
<!--COMMENTS:PixelArray.compare--> &nbsp;<br> 
143
 
<br></ul>
144
 
<br></ul>
145
 
 
146
 
</body></html>
 
1
 
 
2
<html>
 
3
<title>pixelarray - Pygame Documentation</title>
 
4
<body bgcolor=#aaeebb text=#000000 link=#331111 vlink=#331111>
 
5
 
 
6
 
 
7
<table cellpadding=0 cellspacing=0 border=0 style='border: 3px solid black;' width='100%'>
 
8
<tr>
 
9
<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>
 
10
<td bgcolor='#6aee28' style='border-left: 3px solid black; padding: 6px;' align=center valign=center>
 
11
        ||&nbsp;
 
12
        <a href=http://www.pygame.org>Pygame Home</a> &nbsp;||&nbsp;
 
13
        <a href=../index.html>Help Contents</a> &nbsp;||
 
14
        <a href=index.html>Reference Index</a> &nbsp;||
 
15
        <br>&nbsp;<br>
 
16
        
 
17
<a href="camera.html">Camera</a>&nbsp;||&nbsp;
 
18
<a href="cdrom.html">Cdrom</a>&nbsp;||&nbsp;
 
19
<a href="color.html">Color</a>&nbsp;||&nbsp;
 
20
<a href="cursors.html">Cursors</a>&nbsp;||&nbsp;
 
21
<a href="display.html">Display</a>&nbsp;||&nbsp;
 
22
<a href="draw.html">Draw</a>&nbsp;||&nbsp;
 
23
<a href="event.html">Event</a>&nbsp;||&nbsp;
 
24
<a href="examples.html">Examples</a>&nbsp;||&nbsp;
 
25
<a href="font.html">Font</a>&nbsp;||&nbsp;
 
26
<a href="gfxdraw.html">Gfxdraw</a>&nbsp;||&nbsp;
 
27
<a href="image.html">Image</a>&nbsp;||&nbsp;
 
28
<a href="joystick.html">Joystick</a>&nbsp;||&nbsp;
 
29
<a href="key.html">Key</a>&nbsp;||&nbsp;
 
30
<a href="locals.html">Locals</a>&nbsp;||&nbsp;
 
31
<a href="mask.html">Mask</a>&nbsp;||&nbsp;
 
32
<a href="midi.html">Midi</a>&nbsp;||&nbsp;
 
33
<a href="mixer.html">Mixer</a>&nbsp;||&nbsp;
 
34
<a href="mouse.html">Mouse</a>&nbsp;||&nbsp;
 
35
<a href="movie.html">Movie</a>&nbsp;||&nbsp;
 
36
<a href="music.html">Music</a>&nbsp;||&nbsp;
 
37
<a href="overlay.html">Overlay</a>&nbsp;||&nbsp;
 
38
<a href="pixelarray.html">Pixelarray</a>&nbsp;||&nbsp;
 
39
<a href="pygame.html">Pygame</a>&nbsp;||&nbsp;
 
40
<a href="rect.html">Rect</a>&nbsp;||&nbsp;
 
41
<a href="scrap.html">Scrap</a>&nbsp;||&nbsp;
 
42
<a href="sndarray.html">Sndarray</a>&nbsp;||&nbsp;
 
43
<a href="sprite.html">Sprite</a>&nbsp;||&nbsp;
 
44
<a href="surface.html">Surface</a>&nbsp;||&nbsp;
 
45
<a href="surfarray.html">Surfarray</a>&nbsp;||&nbsp;
 
46
<a href="tests.html">Tests</a>&nbsp;||&nbsp;
 
47
<a href="time.html">Time</a>&nbsp;||&nbsp;
 
48
<a href="transform.html">Transform</a>
 
49
</td></tr></table>
 
50
<br>
 
51
 
 
52
 
 
53
<a name="pygame.PixelArray">
 
54
<big><b>pygame.PixelArray</big></b><br><ul>
 
55
  <i>pygame object for direct pixel access of surfaces</i><br>
 
56
  <tt>pygame.PixelArray(Surface): return PixelArray</tt><br>
 
57
<ul><small><table>
 
58
  <tr><td><a href="pixelarray.html#PixelArray.surface">PixelArray.surface</a> - <font size=-1>Gets the Surface the PixelArray uses.</font></td><td>Gets the Surface the PixelArray uses.</td></tr>
 
59
  <tr><td><a href="pixelarray.html#PixelArray.make_surface">PixelArray.make_surface</a> - <font size=-1>Creates a new Surface from the current PixelArray.</font></td><td>Creates a new Surface from the current PixelArray.</td></tr>
 
60
  <tr><td><a href="pixelarray.html#PixelArray.replace">PixelArray.replace</a> - <font size=-1>Replaces the passed color in the PixelArray with another one.</font></td><td>Replaces the passed color in the PixelArray with another one.</td></tr>
 
61
  <tr><td><a href="pixelarray.html#PixelArray.extract">PixelArray.extract</a> - <font size=-1>Extracts the passed color from the PixelArray.</font></td><td>Extracts the passed color from the PixelArray.</td></tr>
 
62
  <tr><td><a href="pixelarray.html#PixelArray.compare">PixelArray.compare</a> - <font size=-1>Compares the PixelArray with another one.</font></td><td>Compares the PixelArray with another one.</td></tr>
 
63
</table></small></ul>
 
64
<p>The PixelArray wraps up a Surface and provides a direct <tt>2D</tt> array access to its pixels using the surface its rows as first and its columns as second axis. It supports slicing, row and pixel manipluation, slicing and slice assignments while inplace operations such as addition, subtraction, multiplication, division and so forth are not allowed. </p>
 
65
<p>While it is possible to assign both, integer color values and <tt>RGB(A)</tt> color tuples, the PixelArray will only use integers for the color representation. Thus, checking for certain colors has to be done using the <tt><a href="surface.html#Surface.map_rgb">Surface.map_rgb</a> - <font size=-1>convert a color into a mapped color value</font></tt> method of the surface, the PixelArray was created for. </p>
 
66
<pre>  pxarray = pygame.PixelArray (surface)
 
67
  # Check, if the first pixel at the topleft corner is blue
 
68
  if pxarray[0][0] == surface.map_rgb ((0, 0, 255)):
 
69
      ...
 
70
</pre><p>Pixels can be manipulated using integer values or color tuples. </p>
 
71
<pre>  pxarray[x][y] = 0xFF00FF
 
72
  pxarray[x][y] = (255, 0, 255)
 
73
</pre><p>If you operate on a slice, you also can use arbitrary sequences or other PixelArray objects to modify the pixels. They have to match the size of the PixelArray however. </p>
 
74
<pre>  pxarray[a:b] = 0xFF00FF                   # set all pixels to 0xFF00FF
 
75
  pxarray[a:b] = (0xFF00FF, 0xAACCEE, ... ) # first pixel = 0xFF00FF,
 
76
                                            # second pixel  = 0xAACCEE, ...
 
77
  pxarray[a:b] = ((255, 0, 255), (170, 204, 238), ...) # same as above
 
78
  pxarray[a:b] = ((255, 0, 255), 0xAACCEE, ...)        # same as above
 
79
  pxarray[a:b] = otherarray[x:y]            # slice sizes must match
 
80
</pre><p>Note, that something like </p>
 
81
<pre>  pxarray[2:4][3:5] = ...
 
82
</pre><p>will not cause a rectangular manipulation. Instead it will be first sliced to a two-column array, which then shall be sliced by columns once more, which will fail due an IndexError. This is caused by the slicing mechanisms in python and an absolutely correct behaviour. Create a single columned slice first, which you can manipulate then: </p>
 
83
<pre>  pxarray[2][3:5] = ...
 
84
  pxarray[3][3:5] = ...
 
85
</pre><p>If you want to make a rectangular manipulation or create a view of a part of the PixelArray, you also can use the subscript abilities. You can easily create different view by creating 'subarrays' using the subscripts. </p>
 
86
<pre>  # Create some new PixelArray objects providing a different view
 
87
  # of the original array/surface.
 
88
  newarray = pxarray[2:4,3:5]
 
89
  otherarray = pxarray[::2,::2]
 
90
</pre><p>Subscripts also can be used to do fast rectangular pixel manipulations instead of iterating over the x or y axis as above. </p>
 
91
<pre>  pxarray[::2,:] = (0, 0, 0)                # Make each second column black.
 
92
</pre><p>During its lifetime, the PixelArray locks the surface, thus you explicitly have to delete it once its not used anymore and the surface should perform operations in the same scope. </p>
 
93
<p>New in pygame <tt>1.8</tt>. Subscript support is new in pygame <tt>1.8.1</tt>. </p>
 
94
<!--COMMENTS:pygame.PixelArray--> &nbsp;<br> 
 
95
 
 
96
 
 
97
<a name="PixelArray.surface">
 
98
<big><b>PixelArray.surface</big></b><br><ul>
 
99
  <i>Gets the Surface the PixelArray uses.</i><br>
 
100
  <tt>PixelArray.surface: Return Surface</tt><br>
 
101
<p>The Surface, the PixelArray was created for. </p>
 
102
<!--COMMENTS:PixelArray.surface--> &nbsp;<br> 
 
103
<br></ul>
 
104
 
 
105
 
 
106
<a name="PixelArray.make_surface">
 
107
<big><b>PixelArray.make_surface</big></b><br><ul>
 
108
  <i>Creates a new Surface from the current PixelArray.</i><br>
 
109
  <tt>PixelArray.make_surface (): Return Surface</tt><br>
 
110
<p>Creates a new Surface from the current PixelArray. Depending on the current PixelArray the size, pixel order etc. will be different from the original Surface. </p>
 
111
<pre>  # Create a new surface flipped around the vertical axis.
 
112
  sf = pxarray[:,::-1].make_surface ()
 
113
</pre><p>New in pygame <tt>1.8.1</tt>. </p>
 
114
<!--COMMENTS:PixelArray.make_surface--> &nbsp;<br> 
 
115
<br></ul>
 
116
 
 
117
 
 
118
<a name="PixelArray.replace">
 
119
<big><b>PixelArray.replace</big></b><br><ul>
 
120
  <i>Replaces the passed color in the PixelArray with another one.</i><br>
 
121
  <tt>PixelArray.replace (color, repcolor, distance=0, weights=(0.299, 0.587, 0.114)): Return None</tt><br>
 
122
<p>Replaces the pixels with the passed color in the PixelArray by changing them them to the passed replacement color. </p>
 
123
<p>It uses a simple weighted euclidian distance formula to calculate the distance between the colors. The distance space ranges from <tt>0.0</tt> to <tt>1.0</tt> and is used as threshold for the color detection. This causes the replacement to take pixels with a similar, but not exactly identical color, into account as well. </p>
 
124
<p>This is an in place operation that directly affects the pixels of the PixelArray. </p>
 
125
<p>New in pygame <tt>1.8.1</tt>. </p>
 
126
<!--COMMENTS:PixelArray.replace--> &nbsp;<br> 
 
127
<br></ul>
 
128
 
 
129
 
 
130
<a name="PixelArray.extract">
 
131
<big><b>PixelArray.extract</big></b><br><ul>
 
132
  <i>Extracts the passed color from the PixelArray.</i><br>
 
133
  <tt>PixelArray.extract (color, distance=0, weights=(0.299, 0.587, 0.114)): Return PixelArray</tt><br>
 
134
<p>Extracts the passed color by changing all matching pixels to white, while non-matching pixels are changed to black. This returns a new PixelArray with the black/white color mask. </p>
 
135
<p>It uses a simple weighted euclidian distance formula to calculate the distance between the colors. The distance space ranges from <tt>0.0</tt> to <tt>1.0</tt> and is used as threshold for the color detection. This causes the extraction to take pixels with a similar, but not exactly identical color, into account as well. </p>
 
136
<p>New in pygame <tt>1.8.1</tt>. </p>
 
137
<!--COMMENTS:PixelArray.extract--> &nbsp;<br> 
 
138
<br></ul>
 
139
 
 
140
 
 
141
<a name="PixelArray.compare">
 
142
<big><b>PixelArray.compare</big></b><br><ul>
 
143
  <i>Compares the PixelArray with another one.</i><br>
 
144
  <tt>PixelArray.compare (array, distance=0, weights=(0.299, 0.587, 0.114)): Return PixelArray</tt><br>
 
145
<p>Compares the contents of the PixelArray with those from the passed PixelArray. It returns a new PixelArray with a black/white color mask that indicates the differences (white) of both arrays. Both PixelArray objects must have indentical bit depths and dimensions. </p>
 
146
<p>It uses a simple weighted euclidian distance formula to calculate the distance between the colors. The distance space ranges from <tt>0.0</tt> to <tt>1.0</tt> and is used as threshold for the color detection. This causes the comparision to mark pixels with a similar, but not exactly identical color, as black. </p>
 
147
<p>New in pygame <tt>1.8.1</tt>. </p>
 
148
<!--COMMENTS:PixelArray.compare--> &nbsp;<br> 
 
149
<br></ul>
 
150
<br></ul>
 
151
 
 
152
</body></html>