Mercurial > pygame
annotate docs/_sources/ref/pixelarray.txt @ 3172:d1b367fc08bc tests-returncode
Use a return code of 1 when the tests fail.
| author | Thomas Kluyver <takowl@gmail.com> |
|---|---|
| date | Wed, 09 Jan 2013 10:13:57 +0000 |
| parents | 5a558a74e434 |
| children |
| rev | line source |
|---|---|
|
2198
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
1 .. include:: common.txt |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
2 |
|
2218
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
3 :class:`pygame.PixelArray` |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
4 ========================== |
|
2198
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
5 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
6 .. currentmodule:: pygame |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
7 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
8 .. class:: PixelArray |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
9 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
10 | :sl:`pygame object for direct pixel access of surfaces` |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
11 | :sg:`PixelArray(Surface) -> PixelArray` |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
12 |
|
2218
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
13 The PixelArray wraps a Surface and provides direct access to the |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
14 surface's pixels. A pixel array can be one or two dimensional. |
|
2240
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
15 A two dimensional array, like its surface, is indexed [column, row]. |
|
2218
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
16 Pixel arrays support slicing, both for returning a subarray or |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
17 for assignment. A pixel array sliced on a single column or row |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
18 returns a one dimensional pixel array. Arithmetic and other operations |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
19 are not supported. A pixel array can be safely assigned to itself. |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
20 Finally, pixel arrays export an array struct interface, allowing |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
21 them to interact with :mod:`pygame.pixelcopy` methods and NumPy |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
22 arrays. |
|
2198
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
23 |
|
2240
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
24 A PixelArray pixel item can be assigned a raw integer values, a |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
25 :class:`pygame.Color` instance, or a (r, g, b[, a]) tuple. |
|
2198
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
26 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
27 :: |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
28 |
|
2218
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
29 pxarray[x, y] = 0xFF00FF |
|
2240
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
30 pxarray[x, y] = pygame.Color(255, 0, 255) |
|
2218
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
31 pxarray[x, y] = (255, 0, 255) |
|
2198
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
32 |
|
2240
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
33 However, only a pixel's integer value is returned. So, to compare a pixel |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
34 to a particular color the color needs to be first mapped using |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
35 the :meth:`Surface.map_rgb()` method of the Surface object for which the |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
36 PixelArray was created. |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
37 |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
38 :: |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
39 |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
40 pxarray = pygame.PixelArray(surface) |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
41 # Check, if the first pixel at the topleft corner is blue |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
42 if pxarray[0, 0] == surface.map_rgb((0, 0, 255)): |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
43 ... |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
44 |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
45 When assigning to a range of of pixels, a non tuple sequence of colors or |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
46 a PixelArray can be used as the value. For a sequence, the length must |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
47 match the PixelArray width. |
|
2198
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
48 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
49 :: |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
50 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
51 pxarray[a:b] = 0xFF00FF # set all pixels to 0xFF00FF |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
52 pxarray[a:b] = (0xFF00FF, 0xAACCEE, ... ) # first pixel = 0xFF00FF, |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
53 # second pixel = 0xAACCEE, ... |
|
2240
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
54 pxarray[a:b] = [(255, 0, 255), (170, 204, 238), ...] # same as above |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
55 pxarray[a:b] = [(255, 0, 255), 0xAACCEE, ...] # same as above |
|
2198
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
56 pxarray[a:b] = otherarray[x:y] # slice sizes must match |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
57 |
|
2240
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
58 For PixelArray assignment, if the right hand side array has a row length |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
59 of 1, then the column is broadcast over the target array's rows. An |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
60 array of height 1 is broadcast over the target's columns, and is equivalent |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
61 to assigning a 1D PixelArray. |
|
2198
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
62 |
|
2240
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
63 Subscipt slices can also be used to assign to a rectangular subview of |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
64 the target PixelArray. |
|
2198
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
65 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
66 :: |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
67 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
68 # Create some new PixelArray objects providing a different view |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
69 # of the original array/surface. |
|
2218
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
70 newarray = pxarray[2:4, 3:5] |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
71 otherarray = pxarray[::2, ::2] |
|
2198
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
72 |
|
2240
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
73 Subscript slices can also be used to do fast rectangular pixel manipulations |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
74 instead of iterating over the x or y axis. The |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
75 |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
76 :: |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
77 |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
78 pxarray[::2, :] = (0, 0, 0) # Make even columns black. |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
79 pxarray[::2] = (0, 0, 0) # Same as [::2, :] |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
80 |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
81 During its lifetime, the PixelArray locks the surface, thus you explicitly |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
82 have to delete it once its not used anymore and the surface should perform |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
83 operations in the same scope. A simple ``:`` slice index for the column can |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
84 be omitted. |
|
2198
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
85 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
86 :: |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
87 |
|
2240
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
88 pxarray[::2, ...] = (0, 0, 0) # Same as pxarray[::2, :] |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
89 pxarray[...] = (255, 0, 0) # Same as pxarray[:] |
|
2198
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
90 |
|
2245
5a558a74e434
Add note to PixelArray doc about future indend changes that will break PixelArray to PixelArray assignments in some cases
Lenard Lindstrom <len-l@telus.net>
parents:
2240
diff
changeset
|
91 A note about PixelArray to PixelArray assignment, for arrays with an |
|
5a558a74e434
Add note to PixelArray doc about future indend changes that will break PixelArray to PixelArray assignments in some cases
Lenard Lindstrom <len-l@telus.net>
parents:
2240
diff
changeset
|
92 item size of 3 (created from 24 bit surfaces) pixel values are translated |
|
5a558a74e434
Add note to PixelArray doc about future indend changes that will break PixelArray to PixelArray assignments in some cases
Lenard Lindstrom <len-l@telus.net>
parents:
2240
diff
changeset
|
93 from the source to the destinations format. The red, green, and blue |
|
5a558a74e434
Add note to PixelArray doc about future indend changes that will break PixelArray to PixelArray assignments in some cases
Lenard Lindstrom <len-l@telus.net>
parents:
2240
diff
changeset
|
94 color elements of each pixel are shifted to match the format of the |
|
5a558a74e434
Add note to PixelArray doc about future indend changes that will break PixelArray to PixelArray assignments in some cases
Lenard Lindstrom <len-l@telus.net>
parents:
2240
diff
changeset
|
95 target surface. For all other pixel sizes no such remapping occurs. |
|
5a558a74e434
Add note to PixelArray doc about future indend changes that will break PixelArray to PixelArray assignments in some cases
Lenard Lindstrom <len-l@telus.net>
parents:
2240
diff
changeset
|
96 This should change in later Pygame releases, where format conversions |
|
5a558a74e434
Add note to PixelArray doc about future indend changes that will break PixelArray to PixelArray assignments in some cases
Lenard Lindstrom <len-l@telus.net>
parents:
2240
diff
changeset
|
97 are performed for all pixel sizes. To avoid code breakage when full mapped |
|
5a558a74e434
Add note to PixelArray doc about future indend changes that will break PixelArray to PixelArray assignments in some cases
Lenard Lindstrom <len-l@telus.net>
parents:
2240
diff
changeset
|
98 copying is implemented it is suggested PixelArray to PixelArray copies be |
|
5a558a74e434
Add note to PixelArray doc about future indend changes that will break PixelArray to PixelArray assignments in some cases
Lenard Lindstrom <len-l@telus.net>
parents:
2240
diff
changeset
|
99 only between surfaces of identical format. |
|
5a558a74e434
Add note to PixelArray doc about future indend changes that will break PixelArray to PixelArray assignments in some cases
Lenard Lindstrom <len-l@telus.net>
parents:
2240
diff
changeset
|
100 |
|
2240
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
101 New in pygame 1.9.2 |
|
2198
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
102 |
|
2240
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
103 - array struct interface |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
104 - transpose method |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
105 - broadcasting for a length 1 dimension |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
106 |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
107 Changed in pyame 1.9.2 |
|
2218
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
108 |
|
2240
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
109 - A 2D PixelArray can have a length 1 dimension. |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
110 Only an integer index on a 2D PixelArray returns a 1D array. |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
111 - For assignment, a tuple can only be a color. Any other sequence type |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
112 is a sequence of colors. |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
113 |
|
2218
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
114 |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
115 .. versionadded: 1.8.0 |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
116 Subscript support |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
117 |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
118 .. versionadded: 1.8.1 |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
119 Methods :meth:`make_surface`, :meth:`replace`, :meth:`extract`, and |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
120 :meth:`compare` |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
121 |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
122 .. versionadded: 1.9.2 |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
123 Properties :attr:`itemsize`, :attr:`ndim`, :attr:`shape`, |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
124 and :attr:`strides` |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
125 |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
126 .. versionadded: 1.9.2 |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
127 Array struct interface |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
128 |
|
2198
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
129 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
130 .. attribute:: surface |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
131 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
132 | :sl:`Gets the Surface the PixelArray uses.` |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
133 | :sg:`surface -> Surface` |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
134 |
|
2218
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
135 The Surface the PixelArray was created for. |
|
2198
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
136 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
137 .. ## PixelArray.surface ## |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
138 |
|
2218
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
139 .. attribute:: itemsize |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
140 |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
141 | :sl:`Returns the byte size of a pixel array item` |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
142 | :sg:`itemsize -> int` |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
143 |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
144 This is the same as :meth:`Surface.get_bytesize` for the |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
145 pixel array's surface. |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
146 |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
147 New in pygame 1.9.2 |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
148 |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
149 .. attribute:: ndim |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
150 |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
151 | :sl:`Returns the number of dimensions.` |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
152 | :sg:`ndim -> int` |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
153 |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
154 A pixel array can be 1 or 2 dimensional. |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
155 |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
156 New in pygame 1.9.2 |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
157 |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
158 .. attribute:: shape |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
159 |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
160 | :sl:`Returns the array size.` |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
161 | :sg:`shape -> tuple of int's` |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
162 |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
163 A tuple or length :attr:`ndim` giving the length of each |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
164 dimension. Analogous to :meth:`Surface.get_size`. |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
165 |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
166 New in pygame 1.9.2 |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
167 |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
168 .. attribute:: strides |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
169 |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
170 | :sl:`Returns byte offsets for each array dimension.` |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
171 | :sg:`strides -> tuple of int's` |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
172 |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
173 A tuple or length :attr:`ndim` byte counts. When a stride is |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
174 multiplied by the corresponding index it gives the offset |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
175 of that index from the start of the array. A stride is negative |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
176 for an array that has is inverted (has a negative step). |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
177 |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
178 New in pygame 1.9.2 |
|
7b81f1162a96
Add an array struct interface and the ndim, itemsize, shape, strides, and _pixels_address properties.
Lenard Lindstrom <len-l@telus.net>
parents:
2198
diff
changeset
|
179 |
|
2198
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
180 .. method:: make_surface |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
181 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
182 | :sl:`Creates a new Surface from the current PixelArray.` |
|
2240
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
183 | :sg:`make_surface() -> Surface` |
|
2198
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
184 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
185 Creates a new Surface from the current PixelArray. Depending on the |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
186 current PixelArray the size, pixel order etc. will be different from the |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
187 original Surface. |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
188 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
189 :: |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
190 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
191 # Create a new surface flipped around the vertical axis. |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
192 sf = pxarray[:,::-1].make_surface () |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
193 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
194 New in pygame 1.8.1. |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
195 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
196 .. ## PixelArray.make_surface ## |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
197 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
198 .. method:: replace |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
199 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
200 | :sl:`Replaces the passed color in the PixelArray with another one.` |
|
2240
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
201 | :sg:`replace(color, repcolor, distance=0, weights=(0.299, 0.587, 0.114)) -> None` |
|
2198
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
202 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
203 Replaces the pixels with the passed color in the PixelArray by changing |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
204 them them to the passed replacement color. |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
205 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
206 It uses a simple weighted euclidian distance formula to calculate the |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
207 distance between the colors. The distance space ranges from 0.0 to 1.0 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
208 and is used as threshold for the color detection. This causes the |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
209 replacement to take pixels with a similar, but not exactly identical |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
210 color, into account as well. |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
211 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
212 This is an in place operation that directly affects the pixels of the |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
213 PixelArray. |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
214 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
215 New in pygame 1.8.1. |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
216 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
217 .. ## PixelArray.replace ## |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
218 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
219 .. method:: extract |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
220 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
221 | :sl:`Extracts the passed color from the PixelArray.` |
|
2240
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
222 | :sg:`extract(color, distance=0, weights=(0.299, 0.587, 0.114)) -> PixelArray` |
|
2198
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
223 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
224 Extracts the passed color by changing all matching pixels to white, while |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
225 non-matching pixels are changed to black. This returns a new PixelArray |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
226 with the black/white color mask. |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
227 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
228 It uses a simple weighted euclidian distance formula to calculate the |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
229 distance between the colors. The distance space ranges from 0.0 to 1.0 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
230 and is used as threshold for the color detection. This causes the |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
231 extraction to take pixels with a similar, but not exactly identical |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
232 color, into account as well. |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
233 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
234 New in pygame 1.8.1. |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
235 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
236 .. ## PixelArray.extract ## |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
237 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
238 .. method:: compare |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
239 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
240 | :sl:`Compares the PixelArray with another one.` |
|
2240
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
241 | :sg:`compare(array, distance=0, weights=(0.299, 0.587, 0.114)) -> PixelArray` |
|
2198
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
242 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
243 Compares the contents of the PixelArray with those from the passed |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
244 PixelArray. It returns a new PixelArray with a black/white color mask |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
245 that indicates the differences (white) of both arrays. Both PixelArray |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
246 objects must have indentical bit depths and dimensions. |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
247 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
248 It uses a simple weighted euclidian distance formula to calculate the |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
249 distance between the colors. The distance space ranges from 0.0 to 1.0 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
250 and is used as threshold for the color detection. This causes the |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
251 comparision to mark pixels with a similar, but not exactly identical |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
252 color, as black. |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
253 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
254 New in pygame 1.8.1. |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
255 |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
256 .. ## PixelArray.compare ## |
|
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
257 |
|
2240
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
258 .. method:: transpose |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
259 |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
260 | :sl:`Exchanges the x and y axis.` |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
261 | :sg:`transpose() -> PixelArray` |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
262 |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
263 This method returns a new view of the pixel array with the rows and |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
264 columns swapped. So for a (w, h) sized array a (h, w) slice is returned. |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
265 If an array is one dimensional, then a length 1 x dimension is added, |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
266 resulting in a 2D pixel array. |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
267 |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
268 New in pygame 1.9.2 |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
269 |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
270 .. ## PixelArray.transpose ## |
|
be3228f63883
Make PixelArray more internally consistent
Lenard Lindstrom <len-l@telus.net>
parents:
2218
diff
changeset
|
271 |
|
2198
da4302429d3b
replace makeref.py generated documents with makeref2.py documents
Lenard Lindstrom <len-l@telus.net>
parents:
diff
changeset
|
272 .. ## pygame.PixelArray ## |
