annotate docs/ref/pixelarray.html @ 1849:301bc61643a9 math_module

merged changes from trunk
author lorenz
date Mon, 16 Nov 2009 18:31:40 +0000
parents 1f6df4baebd5
children f51d9315c3e5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1553
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
1
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
2 <html>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
3 <title>pixelarray - Pygame Documentation</title>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
4 <body bgcolor=#aaeebb text=#000000 link=#331111 vlink=#331111>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
5
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
6
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
7 <table cellpadding=0 cellspacing=0 border=0 style='border: 3px solid black;' width='100%'>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
8 <tr>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
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>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
10 <td bgcolor='#6aee28' style='border-left: 3px solid black; padding: 6px;' align=center valign=center>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
11 ||&nbsp;
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
12 <a href=http://www.pygame.org>Pygame Home</a> &nbsp;||&nbsp;
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
13 <a href=../index.html>Help Contents</a> &nbsp;||
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
14 <a href=index.html>Reference Index</a> &nbsp;||
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
15 <br>&nbsp;<br>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
16
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
17 <a href="camera.html">Camera</a>&nbsp;||&nbsp;
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
18 <a href="cdrom.html">Cdrom</a>&nbsp;||&nbsp;
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
19 <a href="color.html">Color</a>&nbsp;||&nbsp;
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
20 <a href="cursors.html">Cursors</a>&nbsp;||&nbsp;
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
21 <a href="display.html">Display</a>&nbsp;||&nbsp;
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
22 <a href="draw.html">Draw</a>&nbsp;||&nbsp;
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
23 <a href="event.html">Event</a>&nbsp;||&nbsp;
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
24 <a href="examples.html">Examples</a>&nbsp;||&nbsp;
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
25 <a href="font.html">Font</a>&nbsp;||&nbsp;
1849
301bc61643a9 merged changes from trunk
lorenz
parents: 1781
diff changeset
26 <a href="freetype.html">Freetype</a>&nbsp;||&nbsp;
1781
1f6df4baebd5 add gfxdraw docs
Lenard Lindstrom <len-l@telus.net>
parents: 1553
diff changeset
27 <a href="gfxdraw.html">Gfxdraw</a>&nbsp;||&nbsp;
1553
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
28 <a href="image.html">Image</a>&nbsp;||&nbsp;
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
29 <a href="joystick.html">Joystick</a>&nbsp;||&nbsp;
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
30 <a href="key.html">Key</a>&nbsp;||&nbsp;
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
31 <a href="locals.html">Locals</a>&nbsp;||&nbsp;
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
32 <a href="mask.html">Mask</a>&nbsp;||&nbsp;
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
33 <a href="midi.html">Midi</a>&nbsp;||&nbsp;
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
34 <a href="mixer.html">Mixer</a>&nbsp;||&nbsp;
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
35 <a href="mouse.html">Mouse</a>&nbsp;||&nbsp;
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
36 <a href="movie.html">Movie</a>&nbsp;||&nbsp;
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
37 <a href="music.html">Music</a>&nbsp;||&nbsp;
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
38 <a href="overlay.html">Overlay</a>&nbsp;||&nbsp;
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
39 <a href="pixelarray.html">Pixelarray</a>&nbsp;||&nbsp;
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
40 <a href="pygame.html">Pygame</a>&nbsp;||&nbsp;
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
41 <a href="rect.html">Rect</a>&nbsp;||&nbsp;
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
42 <a href="scrap.html">Scrap</a>&nbsp;||&nbsp;
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
43 <a href="sndarray.html">Sndarray</a>&nbsp;||&nbsp;
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
44 <a href="sprite.html">Sprite</a>&nbsp;||&nbsp;
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
45 <a href="surface.html">Surface</a>&nbsp;||&nbsp;
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
46 <a href="surfarray.html">Surfarray</a>&nbsp;||&nbsp;
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
47 <a href="tests.html">Tests</a>&nbsp;||&nbsp;
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
48 <a href="time.html">Time</a>&nbsp;||&nbsp;
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
49 <a href="transform.html">Transform</a>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
50 </td></tr></table>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
51 <br>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
52
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
53
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
54 <a name="pygame.PixelArray">
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
55 <big><b>pygame.PixelArray</big></b><br><ul>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
56 <i>pygame object for direct pixel access of surfaces</i><br>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
57 <tt>pygame.PixelArray(Surface): return PixelArray</tt><br>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
58 <ul><small><table>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
59 <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>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
60 <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>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
61 <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>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
62 <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>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
63 <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>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
64 </table></small></ul>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
65 <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>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
66 <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>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
67 <pre> pxarray = pygame.PixelArray (surface)
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
68 # Check, if the first pixel at the topleft corner is blue
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
69 if pxarray[0][0] == surface.map_rgb ((0, 0, 255)):
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
70 ...
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
71 </pre><p>Pixels can be manipulated using integer values or color tuples. </p>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
72 <pre> pxarray[x][y] = 0xFF00FF
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
73 pxarray[x][y] = (255, 0, 255)
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
74 </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>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
75 <pre> pxarray[a:b] = 0xFF00FF # set all pixels to 0xFF00FF
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
76 pxarray[a:b] = (0xFF00FF, 0xAACCEE, ... ) # first pixel = 0xFF00FF,
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
77 # second pixel = 0xAACCEE, ...
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
78 pxarray[a:b] = ((255, 0, 255), (170, 204, 238), ...) # same as above
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
79 pxarray[a:b] = ((255, 0, 255), 0xAACCEE, ...) # same as above
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
80 pxarray[a:b] = otherarray[x:y] # slice sizes must match
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
81 </pre><p>Note, that something like </p>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
82 <pre> pxarray[2:4][3:5] = ...
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
83 </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>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
84 <pre> pxarray[2][3:5] = ...
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
85 pxarray[3][3:5] = ...
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
86 </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>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
87 <pre> # Create some new PixelArray objects providing a different view
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
88 # of the original array/surface.
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
89 newarray = pxarray[2:4,3:5]
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
90 otherarray = pxarray[::2,::2]
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
91 </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>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
92 <pre> pxarray[::2,:] = (0, 0, 0) # Make each second column black.
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
93 </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>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
94 <p>New in pygame <tt>1.8</tt>. Subscript support is new in pygame <tt>1.8.1</tt>. </p>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
95 <!--COMMENTS:pygame.PixelArray--> &nbsp;<br>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
96
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
97
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
98 <a name="PixelArray.surface">
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
99 <big><b>PixelArray.surface</big></b><br><ul>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
100 <i>Gets the Surface the PixelArray uses.</i><br>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
101 <tt>PixelArray.surface: Return Surface</tt><br>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
102 <p>The Surface, the PixelArray was created for. </p>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
103 <!--COMMENTS:PixelArray.surface--> &nbsp;<br>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
104 <br></ul>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
105
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
106
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
107 <a name="PixelArray.make_surface">
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
108 <big><b>PixelArray.make_surface</big></b><br><ul>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
109 <i>Creates a new Surface from the current PixelArray.</i><br>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
110 <tt>PixelArray.make_surface (): Return Surface</tt><br>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
111 <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>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
112 <pre> # Create a new surface flipped around the vertical axis.
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
113 sf = pxarray[:,::-1].make_surface ()
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
114 </pre><p>New in pygame <tt>1.8.1</tt>. </p>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
115 <!--COMMENTS:PixelArray.make_surface--> &nbsp;<br>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
116 <br></ul>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
117
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
118
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
119 <a name="PixelArray.replace">
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
120 <big><b>PixelArray.replace</big></b><br><ul>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
121 <i>Replaces the passed color in the PixelArray with another one.</i><br>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
122 <tt>PixelArray.replace (color, repcolor, distance=0, weights=(0.299, 0.587, 0.114)): Return None</tt><br>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
123 <p>Replaces the pixels with the passed color in the PixelArray by changing them them to the passed replacement color. </p>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
124 <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>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
125 <p>This is an in place operation that directly affects the pixels of the PixelArray. </p>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
126 <p>New in pygame <tt>1.8.1</tt>. </p>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
127 <!--COMMENTS:PixelArray.replace--> &nbsp;<br>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
128 <br></ul>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
129
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
130
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
131 <a name="PixelArray.extract">
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
132 <big><b>PixelArray.extract</big></b><br><ul>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
133 <i>Extracts the passed color from the PixelArray.</i><br>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
134 <tt>PixelArray.extract (color, distance=0, weights=(0.299, 0.587, 0.114)): Return PixelArray</tt><br>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
135 <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>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
136 <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>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
137 <p>New in pygame <tt>1.8.1</tt>. </p>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
138 <!--COMMENTS:PixelArray.extract--> &nbsp;<br>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
139 <br></ul>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
140
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
141
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
142 <a name="PixelArray.compare">
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
143 <big><b>PixelArray.compare</big></b><br><ul>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
144 <i>Compares the PixelArray with another one.</i><br>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
145 <tt>PixelArray.compare (array, distance=0, weights=(0.299, 0.587, 0.114)): Return PixelArray</tt><br>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
146 <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>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
147 <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>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
148 <p>New in pygame <tt>1.8.1</tt>. </p>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
149 <!--COMMENTS:PixelArray.compare--> &nbsp;<br>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
150 <br></ul>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
151 <br></ul>
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
152
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
153 </body></html>