annotate src/surface.doc @ 1849:301bc61643a9 math_module

merged changes from trunk
author lorenz
date Mon, 16 Nov 2009 18:31:40 +0000
parents 02c1e8e9c102
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
1 pygame.Surface
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
2 pygame object for representing images
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
3 pygame.Surface((width, height), flags=0, depth=0, masks=None): return Surface
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
4 pygame.Surface((width, height), flags=0, Surface): return Surface
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
5
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
6 A pygame Surface is used to represent any image. The Surface has a fixed
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
7 resolution and pixel format. Surfaces with 8bit pixels use a color palette
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
8 to map to 24bit color.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
9
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
10 Call pygame.Surface() to create a new image object. The Surface will be
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
11 cleared to all black. The only required arguments are the sizes. With no
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
12 additional arguments, the Surface will be created in a format that best
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
13 matches the display Surface.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
14
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
15 The pixel format can be controlled by passing the bit depth or an existing
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
16 Surface. The flags argument is a bitmask of additional features for the
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
17 surface. You can pass any combination of these flags:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
18
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
19 HWSURFACE, creates the image in video memory
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
20 SRCALPHA, the pixel format will include a per-pixel alpha
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
21
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
22 Both flags are only a request, and may not be possible for all displays and
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
23 formats.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
24
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
25 Advance users can combine a set of bitmasks with a depth value. The masks
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
26 are a set of 4 integers representing which bits in a pixel will represent
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
27 each color. Normal Surfaces should not require the masks argument.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
28
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
29 Surfaces can have many extra attributes like alpha planes, colorkeys, source
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
30 rectangle clipping. These functions mainly effect how the Surface is blitted
1839
02c1e8e9c102 merged changes from trunk to math_module branch
lorenz
parents: 1625
diff changeset
31 to other Surfaces. The blit routines will attempt to use hardware acceleration
02c1e8e9c102 merged changes from trunk to math_module branch
lorenz
parents: 1625
diff changeset
32 when possible, otherwise they will use highly optimized software blitting
02c1e8e9c102 merged changes from trunk to math_module branch
lorenz
parents: 1625
diff changeset
33 methods.
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
34
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
35 There are three types of transparency supported in Pygame: colorkeys,
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
36 surface alphas, and pixel alphas. Surface alphas can be mixed with colorkeys,
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
37 but an image with per pixel alphas cannot use the other modes. Colorkey
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
38 transparency makes a single color value transparent. Any pixels matching
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
39 the colorkey will not be drawn. The surface alpha value is a single value
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
40 that changes the transparency for the entire image. A surface alpha of 255
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
41 is opaque, and a value of 0 is completely transparent.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
42
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
43 Per pixel alphas are different because they store a transparency value for
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
44 every pixel. This allows for the most precise transparency effects, but it
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
45 also the slowest. Per pixel alphas cannot be mixed with surface alpha and
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
46 colorkeys.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
47
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
48 There is support for pixel access for the Surfaces. Pixel access on hardware
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
49 surfaces is slow and not recommended. Pixels can be accessed using the get_at()
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
50 and set_at() functions. These methods are fine for simple access, but will be
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
51 considerably slow when doing of pixel work with them. If you plan on doing a
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
52 lot of pixel level work, it is recommended to use the pygame.surfarray module,
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
53 which can treat the surfaces like large multidimensional arrays
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
54 (and it's quite quick).
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
55
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
56 Any functions that directly access a surface's pixel data will need that
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
57 surface to be lock()'ed. These functions can lock() and unlock() the surfaces
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
58 themselves without assistance. But, if a function will be called many times,
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
59 there will be a lot of overhead for multiple locking and unlocking of the
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
60 surface. It is best to lock the surface manually before making the function
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
61 call many times, and then unlocking when you are finished. All functions that
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
62 need a locked surface will say so in their docs. Remember to leave the Surface
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
63 locked only while necessary.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
64
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
65 Surface pixels are stored internally as a single number that has all the
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
66 colors encoded into it. Use the Surface.map_rgb() and Surface.unmap_rgb()
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
67 to convert between individual red, green, and blue values into a packed
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
68 integer for that Surface.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
69
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
70 Surfaces can also reference sections of other Surfaces. These are created
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
71 with the Surface.subsurface() method. Any change to either Surface will
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
72 effect the other.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
73
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
74 Each Surface contains a clipping area. By default the clip area covers the
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
75 entire Surface. If it is changed, all drawing operations will only effect
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
76 the smaller area.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
77 <SECTION>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
78
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
79
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
80
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
81 blit
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
82 draw one image onto another
685
fb4a41fce260 The start of some new blitting functions. add/sub/mult/min/max.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
83 Surface.blit(source, dest, area=None, special_flags = 0): return Rect
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
84
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
85 Draws a source Surface onto this Surface. The draw can be positioned with
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
86 the dest argument. Dest can either be pair of coordinates representing the
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
87 upper left corner of the source. A Rect can also be passed as the destination
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
88 and the topleft corner of the rectangle will be used as the position for the
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
89 blit. The size of the destination rectangle does not effect the blit.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
90
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
91 An optional area rectangle can be passed as well. This represents a smaller
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
92 portion of the source Surface to draw.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
93
689
a84f4c96d12b Some more changes to the blending stuff.
Rene Dudfield <renesd@gmail.com>
parents: 685
diff changeset
94 An optional special flags is for passing in
1141
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 1137
diff changeset
95 new in 1.8.0:
689
a84f4c96d12b Some more changes to the blending stuff.
Rene Dudfield <renesd@gmail.com>
parents: 685
diff changeset
96 BLEND_ADD, BLEND_SUB, BLEND_MULT, BLEND_MIN, BLEND_MAX
1141
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 1137
diff changeset
97 new in 1.8.1:
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 1137
diff changeset
98 BLEND_RGBA_ADD, BLEND_RGBA_SUB, BLEND_RGBA_MULT, BLEND_RGBA_MIN, BLEND_RGBA_MAX
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 1137
diff changeset
99 BLEND_RGB_ADD, BLEND_RGB_SUB, BLEND_RGB_MULT, BLEND_RGB_MIN, BLEND_RGB_MAX
689
a84f4c96d12b Some more changes to the blending stuff.
Rene Dudfield <renesd@gmail.com>
parents: 685
diff changeset
100 With other special blitting flags perhaps added in the future.
685
fb4a41fce260 The start of some new blitting functions. add/sub/mult/min/max.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
101
696
cc66586f274d some changes from doc comments on website.
Rene Dudfield <renesd@gmail.com>
parents: 689
diff changeset
102 The return rectangle is the area of the affected pixels, excluding any pixels
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
103 outside the destination Surface, or outside the clipping area.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
104
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
105 Pixel alphas will be ignored when blitting to an 8 bit Surface.
714
35ae39f336fd Added some modifications based on comments written in the website.
Rene Dudfield <renesd@gmail.com>
parents: 696
diff changeset
106
35ae39f336fd Added some modifications based on comments written in the website.
Rene Dudfield <renesd@gmail.com>
parents: 696
diff changeset
107 special_flags new in pygame 1.8.
1524
28a601e11e62 fix surface self-blits for colorkey and blanket alpha: Bugzilla Bug 19
Lenard Lindstrom <len-l@telus.net>
parents: 1234
diff changeset
108
28a601e11e62 fix surface self-blits for colorkey and blanket alpha: Bugzilla Bug 19
Lenard Lindstrom <len-l@telus.net>
parents: 1234
diff changeset
109 For a surface with colorkey or blanket alpha, a blit to self may give slightly
28a601e11e62 fix surface self-blits for colorkey and blanket alpha: Bugzilla Bug 19
Lenard Lindstrom <len-l@telus.net>
parents: 1234
diff changeset
110 different colors than a non self-blit.
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
111 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
112
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
113
685
fb4a41fce260 The start of some new blitting functions. add/sub/mult/min/max.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
114
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
115 convert
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
116 change the pixel format of an image
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
117 Surface.convert(Surface): return Surface
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
118 Surface.convert(depth, flags=0): return Surface
745
a807e78efb40 Removed "Surface.convert(depth, masks): return Surface"
Rene Dudfield <renesd@gmail.com>
parents: 744
diff changeset
119 Surface.convert(masks, flags=0): return Surface
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
120 Surface.convert(): return Surface
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
121
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
122 Creates a new copy of the Surface with the pixel format changed. The new pixel
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
123 format can be determined from another existing Surface. Otherwise depth,
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
124 flags, and masks arguments can be used, similar to the pygame.Surface() call.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
125
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
126 If no arguments are passed the new Surface will have the same pixel format
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
127 as the display Surface. This is always the fastest format for blitting. It
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
128 is a good idea to convert all Surfaces before they are blitted many times.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
129
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
130 The converted Surface will have no pixel alphas. They will be stripped if
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
131 the original had them. See Surface.convert_alpha() for preserving or creating
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
132 per-pixel alphas.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
133 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
134
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
135
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
136
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
137 convert_alpha
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
138 change the pixel format of an image including per pixel alphas
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
139 Surface.convert_alpha(Surface): return Surface
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
140 Surface.convert_alpha(): return Surface
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
141
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
142 Creates a new copy of the surface with the desired pixel format. The new
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
143 surface will be in a format suited for quick blitting to the given format
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
144 with per pixel alpha. If no surface is given, the new surface will be
1038
2fab82895a31 Fixed numerous doc comments. Removed wrong Rect.clip_ip() entry.
marcus
parents: 1022
diff changeset
145 optimized for blitting to the current display.
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
146
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
147 Unlike the Surface.convert() method, the pixel format for the new image will not
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
148 be exactly the same as the requested source, but it will be optimized for
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
149 fast alpha blitting to the destination.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
150 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
151
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
152
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
153
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
154 copy
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
155 create a new copy of a Surface
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
156 Surface.copy(): return Surface
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
157
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
158 Makes a duplicate copy of a Surface. The new Surface will have the same
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
159 pixel formats, color palettes, and transparency settings as the original.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
160 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
161
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
162
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
163
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
164 fill
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
165 fill Surface with a solid color
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents: 745
diff changeset
166 Surface.fill(color, rect=None, special_flags=0): return Rect
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
167
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
168 Fill the Surface with a solid color. If no rect argument is given the
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
169 entire Surface will be filled. The rect argument will limit the fill to
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
170 a specific area. The fill will also be contained by the Surface clip area.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
171
845
c420a3e23f74 Changed the docs for surface.fill for SRCALPHA surfaces.
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
172 The color argument can be either a RGB sequence, a RGBA sequence or
c420a3e23f74 Changed the docs for surface.fill for SRCALPHA surfaces.
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
173 a mapped color index. If using RGBA, the Alpha (A part of RGBA) is ignored
c420a3e23f74 Changed the docs for surface.fill for SRCALPHA surfaces.
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
174 unless the surface uses per pixel alpha (Surface has the SRCALPHA flag).
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
175
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents: 745
diff changeset
176 An optional special_flags is for passing in
1141
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 1137
diff changeset
177 new in 1.8.0:
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents: 745
diff changeset
178 BLEND_ADD, BLEND_SUB, BLEND_MULT, BLEND_MIN, BLEND_MAX
1141
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 1137
diff changeset
179 new in 1.8.1:
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 1137
diff changeset
180 BLEND_RGBA_ADD, BLEND_RGBA_SUB, BLEND_RGBA_MULT, BLEND_RGBA_MIN, BLEND_RGBA_MAX
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 1137
diff changeset
181 BLEND_RGB_ADD, BLEND_RGB_SUB, BLEND_RGB_MULT, BLEND_RGB_MIN, BLEND_RGB_MAX
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents: 745
diff changeset
182 With other special blitting flags perhaps added in the future.
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents: 745
diff changeset
183
696
cc66586f274d some changes from doc comments on website.
Rene Dudfield <renesd@gmail.com>
parents: 689
diff changeset
184 This will return the affected Surface area.
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
185 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
186
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
187
1625
a8e159731135 fixing up spacing between functions
Rene Dudfield <renesd@gmail.com>
parents: 1525
diff changeset
188
1525
48ab3db38416 add Surface.scroll method
Lenard Lindstrom <len-l@telus.net>
parents: 1524
diff changeset
189 scroll
48ab3db38416 add Surface.scroll method
Lenard Lindstrom <len-l@telus.net>
parents: 1524
diff changeset
190 Shift the surface image in place
48ab3db38416 add Surface.scroll method
Lenard Lindstrom <len-l@telus.net>
parents: 1524
diff changeset
191 Surface.scroll(dx=0, dy=0): return None
48ab3db38416 add Surface.scroll method
Lenard Lindstrom <len-l@telus.net>
parents: 1524
diff changeset
192
48ab3db38416 add Surface.scroll method
Lenard Lindstrom <len-l@telus.net>
parents: 1524
diff changeset
193 Move the image by dx pixels right and dy pixels down. dx and dy may be negative
48ab3db38416 add Surface.scroll method
Lenard Lindstrom <len-l@telus.net>
parents: 1524
diff changeset
194 for left and up scrolls respectively. Areas of the surface that are not
48ab3db38416 add Surface.scroll method
Lenard Lindstrom <len-l@telus.net>
parents: 1524
diff changeset
195 overwritten retain their original pixel values. Scrolling is contained
48ab3db38416 add Surface.scroll method
Lenard Lindstrom <len-l@telus.net>
parents: 1524
diff changeset
196 by the Surface clip area. It is safe to have dx and dy values that exceed
48ab3db38416 add Surface.scroll method
Lenard Lindstrom <len-l@telus.net>
parents: 1524
diff changeset
197 the surface size.
1849
301bc61643a9 merged changes from trunk
lorenz
parents: 1839
diff changeset
198
301bc61643a9 merged changes from trunk
lorenz
parents: 1839
diff changeset
199 New in Pygame 1.9
1525
48ab3db38416 add Surface.scroll method
Lenard Lindstrom <len-l@telus.net>
parents: 1524
diff changeset
200 <END>
48ab3db38416 add Surface.scroll method
Lenard Lindstrom <len-l@telus.net>
parents: 1524
diff changeset
201
48ab3db38416 add Surface.scroll method
Lenard Lindstrom <len-l@telus.net>
parents: 1524
diff changeset
202
1625
a8e159731135 fixing up spacing between functions
Rene Dudfield <renesd@gmail.com>
parents: 1525
diff changeset
203
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
204 set_colorkey
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
205 Set the transparent colorkey
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
206 Surface.set_colorkey(Color, flags=0): return None
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
207 Surface.set_colorkey(None): return None
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
208
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
209 Set the current color key for the Surface. When blitting this Surface onto
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
210 a destination, and pixels that have the same color as the colorkey will be
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
211 transparent. The color can be an RGB color or a mapped color integer. If None
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
212 is passed, the colorkey will be unset.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
213
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
214 The colorkey will be ignored if the Surface is formatted to use per pixel
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
215 alpha values. The colorkey can be mixed with the full Surface alpha value.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
216
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
217 The optional flags argument can be set to pygame.RLEACCEL to provide better
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
218 performance on non accelerated displays. An RLEACCEL Surface will be slower
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
219 to modify, but quicker to blit as a source.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
220 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
221
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
222
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
223
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
224 get_colorkey
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
225 Get the current transparent colorkey
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
226 Surface.get_colorkey(): return RGB or None
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
227
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
228 Return the current colorkey value for the Surface. If the colorkey is not
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
229 set then None is returned.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
230 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
231
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
232
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
233
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
234 set_alpha
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
235 set the alpha value for the full Surface image
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
236 Surface.set_alpha(value, flags=0): return None
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
237 Surface.set_alpha(None): return None
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
238
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
239 Set the current alpha value fo r the Surface. When blitting this Surface onto
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
240 a destination, the pixels will be drawn slightly transparent. The alpha value
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
241 is an integer from 0 to 255, 0 is fully transparent and 255 is fully
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
242 opaque. If None is passed for the alpha value, then the Surface alpha will
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
243 be disabled.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
244
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
245 This value is different than the per pixel Surface alpha. If the Surface
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
246 format contains per pixel alphas, then this alpha value will be ignored.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
247 If the Surface contains per pixel alphas, setting the alpha value to None
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
248 will disable the per pixel transparency.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
249
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
250 The optional flags argument can be set to pygame.RLEACCEL to provide better
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
251 performance on non accelerated displays. An RLEACCEL Surface will be slower
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
252 to modify, but quicker to blit as a source.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
253 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
254
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
255
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
256
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
257 get_alpha
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
258 get the current Surface transparency value
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
259 Surface.get_alpha(): return int_value or None
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
260
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
261 Return the current alpha value for the Surface. If the alpha value is not
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
262 set then None is returned.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
263 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
264
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
265
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
266
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
267 lock
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
268 lock the Surface memory for pixel access
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
269 Surface.lock(): return None
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
270
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
271 Lock the pixel data of a Surface for access. On accelerated Surfaces, the
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
272 pixel data may be stored in volatile video memory or nonlinear compressed
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
273 forms. When a Surface is locked the pixel memory becomes available to access
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
274 by regular software. Code that reads or writes pixel values will need the
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
275 Surface to be locked.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
276
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
277 Surfaces should not remain locked for more than necessary. A locked Surface
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
278 can often not be displayed or managed by Pygame.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
279
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
280 Not all Surfaces require locking. The Surface.mustlock() method can determine
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
281 if it is actually required. There is no performance penalty for locking and
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
282 unlocking a Surface that does not need it.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
283
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
284 All pygame functions will automatically lock and unlock the Surface data as
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
285 needed. If a section of code is going to make calls that will repeatedly
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
286 lock and unlock the Surface many times, it can be helpful to wrap the block
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
287 inside a lock and unlock pair.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
288
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
289 It is safe to nest locking and unlocking calls. The surface will only be
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
290 unlocked after the final lock is released.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
291 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
292
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
293
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
294
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
295 unlock
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
296 unlock the Surface memory from pixel access
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
297 Surface.unlock(): return None
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
298
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
299 Unlock the Surface pixel data after it has been locked. The unlocked Surface
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
300 can once again be drawn and managed by Pygame. See the Surface.lock()
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
301 documentation for more details.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
302
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
303 All pygame functions will automatically lock and unlock the Surface data as
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
304 needed. If a section of code is going to make calls that will repeatedly
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
305 lock and unlock the Surface many times, it can be helpful to wrap the block
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
306 inside a lock and unlock pair.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
307
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
308 It is safe to nest locking and unlocking calls. The surface will only be
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
309 unlocked after the final lock is released.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
310 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
311
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
312
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
313
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
314 mustlock
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
315 test if the Surface requires locking
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
316 Surface.mustlock(): return bool
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
317
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
318 Returns True if the Surface is required to be locked to access pixel data.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
319 Usually pure software Surfaces do not require locking. This method is
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
320 rarely needed, since it is safe and quickest to just lock all Surfaces as
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
321 needed.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
322
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
323 All pygame functions will automatically lock and unlock the Surface data as
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
324 needed. If a section of code is going to make calls that will repeatedly
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
325 lock and unlock the Surface many times, it can be helpful to wrap the block
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
326 inside a lock and unlock pair.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
327 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
328
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
329
1625
a8e159731135 fixing up spacing between functions
Rene Dudfield <renesd@gmail.com>
parents: 1525
diff changeset
330
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
331 get_locked
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
332 test if the Surface is current locked
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
333 Surface.get_locked(): return bool
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
334
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
335 Returns True when the Surface is locked. It doesn't matter how many times
1137
ec3ced33488f Reworked locking code to be more strict about locking.
marcus
parents: 1038
diff changeset
336 the Surface is locked.
ec3ced33488f Reworked locking code to be more strict about locking.
marcus
parents: 1038
diff changeset
337 <END>
ec3ced33488f Reworked locking code to be more strict about locking.
marcus
parents: 1038
diff changeset
338
ec3ced33488f Reworked locking code to be more strict about locking.
marcus
parents: 1038
diff changeset
339
1625
a8e159731135 fixing up spacing between functions
Rene Dudfield <renesd@gmail.com>
parents: 1525
diff changeset
340
1137
ec3ced33488f Reworked locking code to be more strict about locking.
marcus
parents: 1038
diff changeset
341 get_locks
ec3ced33488f Reworked locking code to be more strict about locking.
marcus
parents: 1038
diff changeset
342 Gets the locks for the Surface
ec3ced33488f Reworked locking code to be more strict about locking.
marcus
parents: 1038
diff changeset
343 Surface.get_locks(): return tuple
ec3ced33488f Reworked locking code to be more strict about locking.
marcus
parents: 1038
diff changeset
344
ec3ced33488f Reworked locking code to be more strict about locking.
marcus
parents: 1038
diff changeset
345 Returns the currently existing locks for the Surface.
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
346 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
347
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
348
1625
a8e159731135 fixing up spacing between functions
Rene Dudfield <renesd@gmail.com>
parents: 1525
diff changeset
349
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
350 get_at
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
351 get the color value at a single pixel
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
352 Surface.get_at((x, y)): return Color
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
353
1839
02c1e8e9c102 merged changes from trunk to math_module branch
lorenz
parents: 1625
diff changeset
354 Return a copy of the RGBA Color value at the given pixel. If the Surface has
02c1e8e9c102 merged changes from trunk to math_module branch
lorenz
parents: 1625
diff changeset
355 no per pixel alpha, then the alpha value will always be 255 (opaque).
02c1e8e9c102 merged changes from trunk to math_module branch
lorenz
parents: 1625
diff changeset
356 If the pixel position is outside the area of the Surface an IndexError
02c1e8e9c102 merged changes from trunk to math_module branch
lorenz
parents: 1625
diff changeset
357 exception will be raised.
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
358
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
359 Getting and setting pixels one at a time is generally too slow to be used
1839
02c1e8e9c102 merged changes from trunk to math_module branch
lorenz
parents: 1625
diff changeset
360 in a game or realtime situation. It is better to use methods which operate
02c1e8e9c102 merged changes from trunk to math_module branch
lorenz
parents: 1625
diff changeset
361 on many pixels at a time like with the blit, fill and draw methods -
02c1e8e9c102 merged changes from trunk to math_module branch
lorenz
parents: 1625
diff changeset
362 or by using surfarray/PixelArray.
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
363
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
364 This function will temporarily lock and unlock the Surface as needed.
1839
02c1e8e9c102 merged changes from trunk to math_module branch
lorenz
parents: 1625
diff changeset
365
02c1e8e9c102 merged changes from trunk to math_module branch
lorenz
parents: 1625
diff changeset
366 Returning a Color instead of tuple, New in pygame 1.9.0.
02c1e8e9c102 merged changes from trunk to math_module branch
lorenz
parents: 1625
diff changeset
367 Use tuple(surf.get_at((x,y))) if you want a tuple, and not a Color.
02c1e8e9c102 merged changes from trunk to math_module branch
lorenz
parents: 1625
diff changeset
368 This should only matter if you want to use the color as a key in a dict.
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
369 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
370
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
371
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
372
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
373 set_at
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
374 set the color value for a single pixel
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
375 Surface.set_at((x, y), Color): return None
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
376
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
377 Set the RGBA or mapped integer color value for a single pixel. If the Surface
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
378 does not have per pixel alphas, the alpha value is ignored. Settting pixels
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
379 outside the Surface area or outside the Surface clipping will have no effect.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
380
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
381 Getting and setting pixels one at a time is generally too slow to be used
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
382 in a game or realtime situation.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
383
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
384 This function will temporarily lock and unlock the Surface as needed.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
385 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
386
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
387
1625
a8e159731135 fixing up spacing between functions
Rene Dudfield <renesd@gmail.com>
parents: 1525
diff changeset
388
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
389 get_palette
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
390 get the color index palette for an 8bit Surface
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
391 Surface.get_palette(): return [RGB, RGB, RGB, ...]
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
392
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
393 Return a list of up to 256 color elements that represent the indexed colors
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
394 used in an 8bit Surface. The returned list is a copy of the palette, and
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
395 changes will have no effect on the Surface.
1839
02c1e8e9c102 merged changes from trunk to math_module branch
lorenz
parents: 1625
diff changeset
396
02c1e8e9c102 merged changes from trunk to math_module branch
lorenz
parents: 1625
diff changeset
397 Returning a list of Color(with length 3) instances instead of tuples, New in pygame 1.9.0
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
398 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
399
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
400
1625
a8e159731135 fixing up spacing between functions
Rene Dudfield <renesd@gmail.com>
parents: 1525
diff changeset
401
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
402 get_palette_at
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
403 get the color for a single entry in a palette
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
404 Surface.get_palette_at(index): return RGB
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
405
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
406 Returns the red, green, and blue color values for a single index in a Surface
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
407 palette. The index should be a value from 0 to 255.
1839
02c1e8e9c102 merged changes from trunk to math_module branch
lorenz
parents: 1625
diff changeset
408
02c1e8e9c102 merged changes from trunk to math_module branch
lorenz
parents: 1625
diff changeset
409 Returning Color(with length 3) instance instead of a tuple, New in pygame 1.9.0
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
410 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
411
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
412
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
413
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
414 set_palette
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
415 set the color palette for an 8bit Surface
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
416 Surface.set_palette([RGB, RGB, RGB, ...]): return None
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
417
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
418 Set the full palette for an 8bit Surface. This will replace the colors in
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
419 the existing palette. A partial palette can be passed and only the first
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
420 colors in the original palette will be changed.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
421
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
422 This function has no effect on a Surface with more than 8bits per pixel.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
423 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
424
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
425
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
426
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
427 set_palette_at
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
428 set the color for a single index in an 8bit Surface palette
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
429 Surface.set_at(index, RGB): return None
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
430
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
431 Set the palette value for a single entry in a Surface palette. The index should
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
432 be a value from 0 to 255.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
433
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
434 This function has no effect on a Surface with more than 8bits per pixel.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
435 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
436
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
437
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
438
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
439 map_rgb
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
440 convert a color into a mapped color value
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
441 Surface.map_rgb(Color): return mapped_int
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
442
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
443 Convert an RGBA color into the mapped integer value for this Surface. The
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
444 returned integer will contain no more bits than the bit depth of the Surface.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
445 Mapped color values are not often used inside Pygame, but can be passed to
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
446 most functions that require a Surface and a color.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
447
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
448 See the Surface object documentation for more information about colors
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
449 and pixel formats.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
450 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
451
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
452
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
453
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
454 unmap_rgb
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
455 convert a mapped integer color value into a Color
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
456 Surface.map_rgb(mapped_int): return Color
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
457
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
458 Convert an mapped integer color into the RGB color components for this Surface.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
459 Mapped color values are not often used inside Pygame, but can be passed to
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
460 most functions that require a Surface and a color.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
461
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
462 See the Surface object documentation for more information about colors
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
463 and pixel formats.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
464 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
465
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
466
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
467
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
468 set_clip
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
469 set the current clipping area of the Surface
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
470 Surface.set_clip(rect): return None
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
471 Surface.set_clip(None): return None
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
472
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
473 Each Surface has an active clipping area. This is a rectangle that represents
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
474 the only pixels on the Surface that can be modified. If None is passed for the
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
475 rectangle the full Surface will be available for changes.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
476
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
477 The clipping area is always restricted to the area of the Surface itself. If
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
478 the clip rectangle is too large it will be shrunk to fit inside the Surface.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
479 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
480
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
481
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
482
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
483 get_clip
1022
918ed48aa9fe Typo fix
marcus
parents: 934
diff changeset
484 get the current clipping area of the Surface
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
485 Surface.get_clip(): return Rect
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
486
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
487 Return a rectangle of the current clipping area. The Surface will always
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
488 return a valid rectangle that will never be outside the bounds of the image.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
489 If the Surface has had None set for the clipping area, the Surface will
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
490 return a rectangle with the full area of the Surface.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
491 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
492
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
493
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
494
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
495 subsurface
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
496 create a new surface that references its parent
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
497 Surface.subsurface(Rect): return Surface
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
498
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
499 Returns a new Surface that shares its pixels with its new parent. The new
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
500 Surface is considered a child of the original. Modifications to either
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
501 Surface pixels will effect each other. Surface information like clipping
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
502 area and color keys are unique to each Surface.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
503
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
504 The new Surface will inherit the palette, color key, and alpha settings from
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
505 its parent.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
506
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
507 It is possible to have any number of subsurfaces and subsubsurfaces on the
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
508 parent. It is also possible to subsurface the display Surface if the display
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
509 mode is not hardware accelerated.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
510
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
511 See the Surface.get_offset(), Surface.get_parent() to learn more
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
512 about the state of a subsurface.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
513 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
514
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
515
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
516
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
517 get_parent
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
518 find the parent of a subsurface
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
519 Surface.get_parent(): return Surface
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
520
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
521 Returns the parent Surface of a subsurface. If this is not a subsurface
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
522 then None will be returned.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
523 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
524
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
525
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
526
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
527 get_abs_parent
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
528 find the top level parent of a subsurface
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
529 Surface.get_abs_parent(): return Surface
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
530
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
531 Returns the parent Surface of a subsurface. If this is not a subsurface
744
e0e6e8a457db get_abs_parent was wrong about None being returned.
Rene Dudfield <renesd@gmail.com>
parents: 730
diff changeset
532 then this surface will be returned.
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
533 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
534
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
535
1625
a8e159731135 fixing up spacing between functions
Rene Dudfield <renesd@gmail.com>
parents: 1525
diff changeset
536
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
537 get_offset
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
538 find the position of a child subsurface inside a parent
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
539 Surface.get_offset(): return (x, y)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
540
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
541 Get the offset position of a child subsurface inside of a parent. If the
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
542 Surface is not a subsurface this will return (0, 0).
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
543 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
544
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
545
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
546
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
547 get_abs_offset
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
548 find the absolute position of a child subsurface inside its top level parent
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
549 Surface.get_abs_offset(): return (x, y)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
550
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
551 Get the offset position of a child subsurface inside of its top level
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
552 parent Surface. If the Surface is not a subsurface this will return (0, 0).
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
553 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
554
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
555
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
556
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
557 get_size
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
558 get the dimensions of the Surface
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
559 Surface.get_size(): return (width, height)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
560
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
561 Return the width and height of the Surface in pixels.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
562 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
563
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
564
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
565
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
566 get_width
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
567 get the width of the Surface
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
568 Surface.get_width(): return width
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
569
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
570 Return the width of the Surface in pixels.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
571 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
572
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
573
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
574
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
575 get_height
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
576 get the height of the Surface
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
577 Surface.get_height(): return height
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
578
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
579 Return the height of the Surface in pixels.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
580 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
581
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
582
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
583
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
584 get_rect
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
585 get the rectangular area of the Surface
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
586 Surface.get_rect(**kwargs): return Rect
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
587
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
588 Returns a new rectangle covering the entire surface. This rectangle will
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
589 always start at 0, 0 with a width. and height the same size as the image.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
590
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
591 You can pass keyword argument values to this function. These named values
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
592 will be applied to the attributes of the Rect before it is returned. An
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
593 example would be 'mysurf.get_rect(center=(100,100))' to create a rectangle
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
594 for the Surface centered at a given position.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
595 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
596
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
597
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
598
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
599 get_bitsize
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
600 get the bit depth of the Surface pixel format
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
601 Surface.get_bitsize(): return int
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
602
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
603 Returns the number of bits used to represent each pixel. This value may not
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
604 exactly fill the number of bytes used per pixel. For example a 15 bit Surface
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
605 still requires a full 2 bytes.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
606 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
607
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
608
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
609
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
610 get_bytesize
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
611 get the bytes used per Surface pixel
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
612 Surface.get_bytesize(): return int
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
613
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
614 Return the number of bytes used per pixel.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
615 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
616
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
617
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
618
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
619 get_flags
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
620 get the additional flags used for the Surface
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
621 Surface.get_flags(): return int
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
622
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
623 Returns a set of current Surface features. Each feature is a bit in the
729
3a0ffb0d17bc added a full list of flags into the surface docs
Rene Dudfield <renesd@gmail.com>
parents: 714
diff changeset
624 flags bitmask. Typical flags are HWSURFACE, RLEACCEL, SRCALPHA, and SRCCOLORKEY.
3a0ffb0d17bc added a full list of flags into the surface docs
Rene Dudfield <renesd@gmail.com>
parents: 714
diff changeset
625
3a0ffb0d17bc added a full list of flags into the surface docs
Rene Dudfield <renesd@gmail.com>
parents: 714
diff changeset
626
730
e2296f088920 moved the full list of flags to the get_flags call where it would be needed the most.
Rene Dudfield <renesd@gmail.com>
parents: 729
diff changeset
627 Here is a more complete list of flags. A full list can be found in SDL_video.h
e2296f088920 moved the full list of flags to the get_flags call where it would be needed the most.
Rene Dudfield <renesd@gmail.com>
parents: 729
diff changeset
628 SWSURFACE 0x00000000 # Surface is in system memory
e2296f088920 moved the full list of flags to the get_flags call where it would be needed the most.
Rene Dudfield <renesd@gmail.com>
parents: 729
diff changeset
629 HWSURFACE 0x00000001 # Surface is in video memory
e2296f088920 moved the full list of flags to the get_flags call where it would be needed the most.
Rene Dudfield <renesd@gmail.com>
parents: 729
diff changeset
630 ASYNCBLIT 0x00000004 # Use asynchronous blits if possible
e2296f088920 moved the full list of flags to the get_flags call where it would be needed the most.
Rene Dudfield <renesd@gmail.com>
parents: 729
diff changeset
631
e2296f088920 moved the full list of flags to the get_flags call where it would be needed the most.
Rene Dudfield <renesd@gmail.com>
parents: 729
diff changeset
632 Available for pygame.display.set_mode()
e2296f088920 moved the full list of flags to the get_flags call where it would be needed the most.
Rene Dudfield <renesd@gmail.com>
parents: 729
diff changeset
633 ANYFORMAT 0x10000000 # Allow any video depth/pixel-format
e2296f088920 moved the full list of flags to the get_flags call where it would be needed the most.
Rene Dudfield <renesd@gmail.com>
parents: 729
diff changeset
634 HWPALETTE 0x20000000 # Surface has exclusive palette
e2296f088920 moved the full list of flags to the get_flags call where it would be needed the most.
Rene Dudfield <renesd@gmail.com>
parents: 729
diff changeset
635 DOUBLEBUF 0x40000000 # Set up double-buffered video mode
e2296f088920 moved the full list of flags to the get_flags call where it would be needed the most.
Rene Dudfield <renesd@gmail.com>
parents: 729
diff changeset
636 FULLSCREEN 0x80000000 # Surface is a full screen display
e2296f088920 moved the full list of flags to the get_flags call where it would be needed the most.
Rene Dudfield <renesd@gmail.com>
parents: 729
diff changeset
637 OPENGL 0x00000002 # Create an OpenGL rendering context
e2296f088920 moved the full list of flags to the get_flags call where it would be needed the most.
Rene Dudfield <renesd@gmail.com>
parents: 729
diff changeset
638 OPENGLBLIT 0x0000000A # Create an OpenGL rendering context
e2296f088920 moved the full list of flags to the get_flags call where it would be needed the most.
Rene Dudfield <renesd@gmail.com>
parents: 729
diff changeset
639 # and use it for blitting. Obsolete.
e2296f088920 moved the full list of flags to the get_flags call where it would be needed the most.
Rene Dudfield <renesd@gmail.com>
parents: 729
diff changeset
640 RESIZABLE 0x00000010 # This video mode may be resized
e2296f088920 moved the full list of flags to the get_flags call where it would be needed the most.
Rene Dudfield <renesd@gmail.com>
parents: 729
diff changeset
641 NOFRAME 0x00000020 # No window caption or edge frame
e2296f088920 moved the full list of flags to the get_flags call where it would be needed the most.
Rene Dudfield <renesd@gmail.com>
parents: 729
diff changeset
642
e2296f088920 moved the full list of flags to the get_flags call where it would be needed the most.
Rene Dudfield <renesd@gmail.com>
parents: 729
diff changeset
643 Used internally (read-only)
e2296f088920 moved the full list of flags to the get_flags call where it would be needed the most.
Rene Dudfield <renesd@gmail.com>
parents: 729
diff changeset
644 HWACCEL 0x00000100 # Blit uses hardware acceleration
e2296f088920 moved the full list of flags to the get_flags call where it would be needed the most.
Rene Dudfield <renesd@gmail.com>
parents: 729
diff changeset
645 SRCCOLORKEY 0x00001000 # Blit uses a source color key
e2296f088920 moved the full list of flags to the get_flags call where it would be needed the most.
Rene Dudfield <renesd@gmail.com>
parents: 729
diff changeset
646 RLEACCELOK 0x00002000 # Private flag
e2296f088920 moved the full list of flags to the get_flags call where it would be needed the most.
Rene Dudfield <renesd@gmail.com>
parents: 729
diff changeset
647 RLEACCEL 0x00004000 # Surface is RLE encoded
e2296f088920 moved the full list of flags to the get_flags call where it would be needed the most.
Rene Dudfield <renesd@gmail.com>
parents: 729
diff changeset
648 SRCALPHA 0x00010000 # Blit uses source alpha blending
e2296f088920 moved the full list of flags to the get_flags call where it would be needed the most.
Rene Dudfield <renesd@gmail.com>
parents: 729
diff changeset
649 PREALLOC 0x01000000 # Surface uses preallocated memory
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
650 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
651
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
652
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
653
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
654 get_pitch
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
655 get the number of bytes used per Surface row
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
656 Surface.get_pitch(): return int
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
657
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
658 Return the number of bytes separating each row in the Surface. Surfaces
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
659 in video memory are not always linearly packed. Subsurfaces will also have a
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
660 larger pitch than their real width.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
661
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
662 This value is not needed for normal Pygame usage.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
663 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
664
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
665
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
666
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
667 get_masks
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
668 the bitmasks needed to convert between a color and a mapped integer
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
669 Surface.get_masks(): return (R, G, B, A)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
670
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
671 Returns the bitmasks used to isolate each color in a mapped integer.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
672
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
673 This value is not needed for normal Pygame usage.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
674 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
675
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
676
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
677
1234
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1141
diff changeset
678 set_masks
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1141
diff changeset
679 set the bitmasks needed to convert between a color and a mapped integer
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1141
diff changeset
680 Surface.set_masks((r,g,b,a)): return None
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1141
diff changeset
681
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1141
diff changeset
682 This is not needed for normal Pygame usage.
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1141
diff changeset
683 New in pygame 1.8.1
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1141
diff changeset
684 <END>
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1141
diff changeset
685
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1141
diff changeset
686
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1141
diff changeset
687
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
688 get_shifts
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
689 the bit shifts needed to convert between a color and a mapped integer
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
690 Surface.get_shifts(): return (R, G, B, A)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
691
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
692 Returns the pixel shifts need to convert between each color and a mapped
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
693 integer.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
694
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
695 This value is not needed for normal Pygame usage.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
696 <END>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
697
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
698
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
699
1234
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1141
diff changeset
700 set_shifts
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1141
diff changeset
701 sets the bit shifts needed to convert between a color and a mapped integer
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1141
diff changeset
702 Surface.get_shifts((r,g,b,a)): return None
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1141
diff changeset
703
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1141
diff changeset
704 This is not needed for normal Pygame usage.
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1141
diff changeset
705 New in pygame 1.8.1
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1141
diff changeset
706 <END>
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1141
diff changeset
707
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1141
diff changeset
708
1625
a8e159731135 fixing up spacing between functions
Rene Dudfield <renesd@gmail.com>
parents: 1525
diff changeset
709
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
710 get_losses
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
711 the significant bits used to convert between a color and a mapped integer
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
712 Surface.get_losses(): return (R, G, B, A)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
713
930
6c7f1d4107f4 surface.get_bounding_rect
brian
parents: 860
diff changeset
714 Return the least significant number of bits stripped from each color
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
715 in a mapped integer.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
716
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
717 This value is not needed for normal Pygame usage.
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
718 <END>
860
41b22371307e Changes from Marcus.
Rene Dudfield <renesd@gmail.com>
parents: 854
diff changeset
719
930
6c7f1d4107f4 surface.get_bounding_rect
brian
parents: 860
diff changeset
720
6c7f1d4107f4 surface.get_bounding_rect
brian
parents: 860
diff changeset
721
6c7f1d4107f4 surface.get_bounding_rect
brian
parents: 860
diff changeset
722 get_bounding_rect
6c7f1d4107f4 surface.get_bounding_rect
brian
parents: 860
diff changeset
723 find the smallest rect containing data
6c7f1d4107f4 surface.get_bounding_rect
brian
parents: 860
diff changeset
724 Surface.get_bounding_rect(min_alpha = 1): return Rect
6c7f1d4107f4 surface.get_bounding_rect
brian
parents: 860
diff changeset
725
6c7f1d4107f4 surface.get_bounding_rect
brian
parents: 860
diff changeset
726 Returns the smallest rectangular region that contains all the pixels
6c7f1d4107f4 surface.get_bounding_rect
brian
parents: 860
diff changeset
727 in the surface that have an alpha value greater than or equal to the
6c7f1d4107f4 surface.get_bounding_rect
brian
parents: 860
diff changeset
728 minimum alpha value.
6c7f1d4107f4 surface.get_bounding_rect
brian
parents: 860
diff changeset
729
6c7f1d4107f4 surface.get_bounding_rect
brian
parents: 860
diff changeset
730 This function will temporarily lock and unlock the Surface as needed.
934
d3b1773c8422 Fixing up some minor doc stuff
brian
parents: 930
diff changeset
731
d3b1773c8422 Fixing up some minor doc stuff
brian
parents: 930
diff changeset
732 New in pygame 1.8.
930
6c7f1d4107f4 surface.get_bounding_rect
brian
parents: 860
diff changeset
733 <END>
6c7f1d4107f4 surface.get_bounding_rect
brian
parents: 860
diff changeset
734
6c7f1d4107f4 surface.get_bounding_rect
brian
parents: 860
diff changeset
735
6c7f1d4107f4 surface.get_bounding_rect
brian
parents: 860
diff changeset
736
860
41b22371307e Changes from Marcus.
Rene Dudfield <renesd@gmail.com>
parents: 854
diff changeset
737 get_buffer
41b22371307e Changes from Marcus.
Rene Dudfield <renesd@gmail.com>
parents: 854
diff changeset
738 acquires a buffer object for the pixels of the Surface.
41b22371307e Changes from Marcus.
Rene Dudfield <renesd@gmail.com>
parents: 854
diff changeset
739 Surface.get_buffer(): return BufferProxy
41b22371307e Changes from Marcus.
Rene Dudfield <renesd@gmail.com>
parents: 854
diff changeset
740
41b22371307e Changes from Marcus.
Rene Dudfield <renesd@gmail.com>
parents: 854
diff changeset
741 Return a buffer object for the pixels of the Surface. The buffer can be
41b22371307e Changes from Marcus.
Rene Dudfield <renesd@gmail.com>
parents: 854
diff changeset
742 used for direct pixel access and manipulation.
41b22371307e Changes from Marcus.
Rene Dudfield <renesd@gmail.com>
parents: 854
diff changeset
743
41b22371307e Changes from Marcus.
Rene Dudfield <renesd@gmail.com>
parents: 854
diff changeset
744 This method implicitly locks the Surface. The lock will be released,
41b22371307e Changes from Marcus.
Rene Dudfield <renesd@gmail.com>
parents: 854
diff changeset
745 once the returned BufferProxy object is deleted.
41b22371307e Changes from Marcus.
Rene Dudfield <renesd@gmail.com>
parents: 854
diff changeset
746
41b22371307e Changes from Marcus.
Rene Dudfield <renesd@gmail.com>
parents: 854
diff changeset
747 New in pygame 1.8.
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
748 <END>
860
41b22371307e Changes from Marcus.
Rene Dudfield <renesd@gmail.com>
parents: 854
diff changeset
749 <END>