annotate docs/ref/surface.html @ 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
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
2 <html>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
3 <title>surface - Pygame Documentation</title>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
4 <body bgcolor=#aaeebb text=#000000 link=#331111 vlink=#331111>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
5
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
6
651
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
7 <table cellpadding=0 cellspacing=0 border=0 style='border: 3px solid black;' width='100%'>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
8 <tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
9 <td bgcolor='#c2fc20' style='padding: 6px;' align=center valign=center><a href='http://www.pygame.org/'><img src='../pygame_tiny.gif' border=0 width=200 height=60></a><br><b>pygame documentation</b></td>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
10 <td bgcolor='#6aee28' style='border-left: 3px solid black; padding: 6px;' align=center valign=center>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
11 ||&nbsp;
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
12 <a href=http://www.pygame.org>Pygame Home</a> &nbsp;||&nbsp;
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
13 <a href=../index.html>Help Contents</a> &nbsp;||
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
14 <a href=index.html>Reference Index</a> &nbsp;||
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
15 <br>&nbsp;<br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
16
1323
1ca45b50f8ea camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents: 1234
diff changeset
17 <a href="camera.html">Camera</a>&nbsp;||&nbsp;
974
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
18 <a href="cdrom.html">Cdrom</a>&nbsp;||&nbsp;
1037
c4c38b97db3b Added Color class.
marcus
parents: 1036
diff changeset
19 <a href="color.html">Color</a>&nbsp;||&nbsp;
974
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
20 <a href="cursors.html">Cursors</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
21 <a href="display.html">Display</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
22 <a href="draw.html">Draw</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
23 <a href="event.html">Event</a>&nbsp;||&nbsp;
1448
c496066bc336 add examples module document page
Lenard Lindstrom <len-l@telus.net>
parents: 1419
diff changeset
24 <a href="examples.html">Examples</a>&nbsp;||&nbsp;
974
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
25 <a href="font.html">Font</a>&nbsp;||&nbsp;
1849
301bc61643a9 merged changes from trunk
lorenz
parents: 1839
diff changeset
26 <a href="freetype.html">Freetype</a>&nbsp;||&nbsp;
1781
1f6df4baebd5 add gfxdraw docs
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
27 <a href="gfxdraw.html">Gfxdraw</a>&nbsp;||&nbsp;
974
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
28 <a href="image.html">Image</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
29 <a href="joystick.html">Joystick</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
30 <a href="key.html">Key</a>&nbsp;||&nbsp;
1373
d0e31483bd3b Added a pygame.locals module page back into the docs
Lenard Lindstrom <len-l@telus.net>
parents: 1323
diff changeset
31 <a href="locals.html">Locals</a>&nbsp;||&nbsp;
974
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
32 <a href="mask.html">Mask</a>&nbsp;||&nbsp;
1548
9379bdac652e add event object comparison as per mailing list request
Lenard Lindstrom <len-l@telus.net>
parents: 1525
diff changeset
33 <a href="midi.html">Midi</a>&nbsp;||&nbsp;
974
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
34 <a href="mixer.html">Mixer</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
35 <a href="mouse.html">Mouse</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
36 <a href="movie.html">Movie</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
37 <a href="music.html">Music</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
38 <a href="overlay.html">Overlay</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
39 <a href="pixelarray.html">Pixelarray</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
40 <a href="pygame.html">Pygame</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
41 <a href="rect.html">Rect</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
42 <a href="scrap.html">Scrap</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
43 <a href="sndarray.html">Sndarray</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
44 <a href="sprite.html">Sprite</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
45 <a href="surface.html">Surface</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
46 <a href="surfarray.html">Surfarray</a>&nbsp;||&nbsp;
1419
5f26c8759fa7 pygame.tests: added docs, go module and polished help messages
Lenard Lindstrom <len-l@telus.net>
parents: 1373
diff changeset
47 <a href="tests.html">Tests</a>&nbsp;||&nbsp;
974
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
48 <a href="time.html">Time</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
49 <a href="transform.html">Transform</a>
651
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
50 </td></tr></table>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
51 <br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
52
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
53
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
54 <a name="pygame.Surface">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
55 <big><b>pygame.Surface</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
56 <i>pygame object for representing images</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
57 <tt>pygame.Surface((width, height), flags=0, depth=0, masks=None): return Surface</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
58 <tt>pygame.Surface((width, height), flags=0, Surface): return Surface</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
59 <ul><small><table>
651
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
60 <tr><td><a href="surface.html#Surface.blit">Surface.blit</a> - <font size=-1>draw one image onto another</font></td><td>draw one image onto another</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
61 <tr><td><a href="surface.html#Surface.convert">Surface.convert</a> - <font size=-1>change the pixel format of an image</font></td><td>change the pixel format of an image</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
62 <tr><td><a href="surface.html#Surface.convert_alpha">Surface.convert_alpha</a> - <font size=-1>change the pixel format of an image including per pixel alphas</font></td><td>change the pixel format of an image including per pixel alphas</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
63 <tr><td><a href="surface.html#Surface.copy">Surface.copy</a> - <font size=-1>create a new copy of a Surface</font></td><td>create a new copy of a Surface</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
64 <tr><td><a href="surface.html#Surface.fill">Surface.fill</a> - <font size=-1>fill Surface with a solid color</font></td><td>fill Surface with a solid color</td></tr>
1525
48ab3db38416 add Surface.scroll method
Lenard Lindstrom <len-l@telus.net>
parents: 1524
diff changeset
65 <tr><td><a href="surface.html#Surface.scroll">Surface.scroll</a> - <font size=-1>Shift the surface image in place</font></td><td>Shift the surface image in place</td></tr>
651
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
66 <tr><td><a href="surface.html#Surface.set_colorkey">Surface.set_colorkey</a> - <font size=-1>Set the transparent colorkey</font></td><td>Set the transparent colorkey</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
67 <tr><td><a href="surface.html#Surface.get_colorkey">Surface.get_colorkey</a> - <font size=-1>Get the current transparent colorkey</font></td><td>Get the current transparent colorkey</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
68 <tr><td><a href="surface.html#Surface.set_alpha">Surface.set_alpha</a> - <font size=-1>set the alpha value for the full Surface image</font></td><td>set the alpha value for the full Surface image</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
69 <tr><td><a href="surface.html#Surface.get_alpha">Surface.get_alpha</a> - <font size=-1>get the current Surface transparency value</font></td><td>get the current Surface transparency value</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
70 <tr><td><a href="surface.html#Surface.lock">Surface.lock</a> - <font size=-1>lock the Surface memory for pixel access</font></td><td>lock the Surface memory for pixel access</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
71 <tr><td><a href="surface.html#Surface.unlock">Surface.unlock</a> - <font size=-1>unlock the Surface memory from pixel access</font></td><td>unlock the Surface memory from pixel access</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
72 <tr><td><a href="surface.html#Surface.mustlock">Surface.mustlock</a> - <font size=-1>test if the Surface requires locking</font></td><td>test if the Surface requires locking</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
73 <tr><td><a href="surface.html#Surface.get_locked">Surface.get_locked</a> - <font size=-1>test if the Surface is current locked</font></td><td>test if the Surface is current locked</td></tr>
1137
ec3ced33488f Reworked locking code to be more strict about locking.
marcus
parents: 1038
diff changeset
74 <tr><td><a href="surface.html#Surface.get_locks">Surface.get_locks</a> - <font size=-1>Gets the locks for the Surface</font></td><td>Gets the locks for the Surface</td></tr>
651
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
75 <tr><td><a href="surface.html#Surface.get_at">Surface.get_at</a> - <font size=-1>get the color value at a single pixel</font></td><td>get the color value at a single pixel</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
76 <tr><td><a href="surface.html#Surface.set_at">Surface.set_at</a> - <font size=-1>set the color value for a single pixel</font></td><td>set the color value for a single pixel</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
77 <tr><td><a href="surface.html#Surface.get_palette">Surface.get_palette</a> - <font size=-1>get the color index palette for an 8bit Surface</font></td><td>get the color index palette for an 8bit Surface</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
78 <tr><td><a href="surface.html#Surface.get_palette_at">Surface.get_palette_at</a> - <font size=-1>get the color for a single entry in a palette</font></td><td>get the color for a single entry in a palette</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
79 <tr><td><a href="surface.html#Surface.set_palette">Surface.set_palette</a> - <font size=-1>set the color palette for an 8bit Surface</font></td><td>set the color palette for an 8bit Surface</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
80 <tr><td><a href="surface.html#Surface.set_palette_at">Surface.set_palette_at</a> - <font size=-1>set the color for a single index in an 8bit Surface palette</font></td><td>set the color for a single index in an 8bit Surface palette</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
81 <tr><td><a href="surface.html#Surface.map_rgb">Surface.map_rgb</a> - <font size=-1>convert a color into a mapped color value</font></td><td>convert a color into a mapped color value</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
82 <tr><td><a href="surface.html#Surface.unmap_rgb">Surface.unmap_rgb</a> - <font size=-1>convert a mapped integer color value into a Color</font></td><td>convert a mapped integer color value into a Color</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
83 <tr><td><a href="surface.html#Surface.set_clip">Surface.set_clip</a> - <font size=-1>set the current clipping area of the Surface</font></td><td>set the current clipping area of the Surface</td></tr>
1036
e0f8354aa687 Some documentation updates... mainly updating sprite docs. More to do...
Rene Dudfield <renesd@gmail.com>
parents: 974
diff changeset
84 <tr><td><a href="surface.html#Surface.get_clip">Surface.get_clip</a> - <font size=-1>get the current clipping area of the Surface</font></td><td>get the current clipping area of the Surface</td></tr>
651
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
85 <tr><td><a href="surface.html#Surface.subsurface">Surface.subsurface</a> - <font size=-1>create a new surface that references its parent</font></td><td>create a new surface that references its parent</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
86 <tr><td><a href="surface.html#Surface.get_parent">Surface.get_parent</a> - <font size=-1>find the parent of a subsurface</font></td><td>find the parent of a subsurface</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
87 <tr><td><a href="surface.html#Surface.get_abs_parent">Surface.get_abs_parent</a> - <font size=-1>find the top level parent of a subsurface</font></td><td>find the top level parent of a subsurface</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
88 <tr><td><a href="surface.html#Surface.get_offset">Surface.get_offset</a> - <font size=-1>find the position of a child subsurface inside a parent</font></td><td>find the position of a child subsurface inside a parent</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
89 <tr><td><a href="surface.html#Surface.get_abs_offset">Surface.get_abs_offset</a> - <font size=-1>find the absolute position of a child subsurface inside its top level parent</font></td><td>find the absolute position of a child subsurface inside its top level parent</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
90 <tr><td><a href="surface.html#Surface.get_size">Surface.get_size</a> - <font size=-1>get the dimensions of the Surface</font></td><td>get the dimensions of the Surface</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
91 <tr><td><a href="surface.html#Surface.get_width">Surface.get_width</a> - <font size=-1>get the width of the Surface</font></td><td>get the width of the Surface</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
92 <tr><td><a href="surface.html#Surface.get_height">Surface.get_height</a> - <font size=-1>get the height of the Surface</font></td><td>get the height of the Surface</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
93 <tr><td><a href="surface.html#Surface.get_rect">Surface.get_rect</a> - <font size=-1>get the rectangular area of the Surface</font></td><td>get the rectangular area of the Surface</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
94 <tr><td><a href="surface.html#Surface.get_bitsize">Surface.get_bitsize</a> - <font size=-1>get the bit depth of the Surface pixel format</font></td><td>get the bit depth of the Surface pixel format</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
95 <tr><td><a href="surface.html#Surface.get_bytesize">Surface.get_bytesize</a> - <font size=-1>get the bytes used per Surface pixel</font></td><td>get the bytes used per Surface pixel</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
96 <tr><td><a href="surface.html#Surface.get_flags">Surface.get_flags</a> - <font size=-1>get the additional flags used for the Surface</font></td><td>get the additional flags used for the Surface</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
97 <tr><td><a href="surface.html#Surface.get_pitch">Surface.get_pitch</a> - <font size=-1>get the number of bytes used per Surface row</font></td><td>get the number of bytes used per Surface row</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
98 <tr><td><a href="surface.html#Surface.get_masks">Surface.get_masks</a> - <font size=-1>the bitmasks needed to convert between a color and a mapped integer</font></td><td>the bitmasks needed to convert between a color and a mapped integer</td></tr>
1234
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1221
diff changeset
99 <tr><td><a href="surface.html#Surface.set_masks">Surface.set_masks</a> - <font size=-1>set the bitmasks needed to convert between a color and a mapped integer</font></td><td>set the bitmasks needed to convert between a color and a mapped integer</td></tr>
651
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
100 <tr><td><a href="surface.html#Surface.get_shifts">Surface.get_shifts</a> - <font size=-1>the bit shifts needed to convert between a color and a mapped integer</font></td><td>the bit shifts needed to convert between a color and a mapped integer</td></tr>
1234
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1221
diff changeset
101 <tr><td><a href="surface.html#Surface.set_shifts">Surface.set_shifts</a> - <font size=-1>sets the bit shifts needed to convert between a color and a mapped integer</font></td><td>sets the bit shifts needed to convert between a color and a mapped integer</td></tr>
651
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
102 <tr><td><a href="surface.html#Surface.get_losses">Surface.get_losses</a> - <font size=-1>the significant bits used to convert between a color and a mapped integer</font></td><td>the significant bits used to convert between a color and a mapped integer</td></tr>
957
a1b08375b132 Added display.set_mode() resolution enhancement as posted by Lorenz Quack.
marcus
parents: 862
diff changeset
103 <tr><td><a href="surface.html#Surface.get_bounding_rect">Surface.get_bounding_rect</a> - <font size=-1>find the smallest rect containing data</font></td><td>find the smallest rect containing data</td></tr>
862
57ac2edacc4d Mask can now get bounding rects of set bits.
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
104 <tr><td><a href="surface.html#Surface.get_buffer">Surface.get_buffer</a> - <font size=-1>acquires a buffer object for the pixels of the Surface.</font></td><td>acquires a buffer object for the pixels of the Surface.</td></tr>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
105 </table></small></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
106 <p><tt>A</tt> pygame Surface is used to represent any image. The Surface has a fixed resolution and pixel format. Surfaces with 8bit pixels use a color palette to map to 24bit color. </p>
651
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
107 <p>Call <tt><a href="surface.html#pygame.Surface">pygame.Surface</a> - <font size=-1>pygame object for representing images</font></tt> to create a new image object. The Surface will be cleared to all black. The only required arguments are the sizes. With no additional arguments, the Surface will be created in a format that best matches the display Surface. </p>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
108 <p>The pixel format can be controlled by passing the bit depth or an existing Surface. The flags argument is a bitmask of additional features for the surface. You can pass any combination of these flags: </p>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
109 <pre> HWSURFACE, creates the image in video memory
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
110 SRCALPHA, the pixel format will include a per-pixel alpha
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
111 </pre><p>Both flags are only a request, and may not be possible for all displays and formats. </p>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
112 <p>Advance users can combine a set of bitmasks with a depth value. The masks are a set of 4 integers representing which bits in a pixel will represent each color. Normal Surfaces should not require the masks argument. </p>
1839
02c1e8e9c102 merged changes from trunk to math_module branch
lorenz
parents: 1781
diff changeset
113 <p>Surfaces can have many extra attributes like alpha planes, colorkeys, source rectangle clipping. These functions mainly effect how the Surface is blitted to other Surfaces. The blit routines will attempt to use hardware acceleration when possible, otherwise they will use highly optimized software blitting methods. </p>
02c1e8e9c102 merged changes from trunk to math_module branch
lorenz
parents: 1781
diff changeset
114 <p>There are three types of transparency supported in Pygame: colorkeys, surface alphas, and pixel alphas. Surface alphas can be mixed with colorkeys, but an image with per pixel alphas cannot use the other modes. Colorkey transparency makes a single color value transparent. Any pixels matching the colorkey will not be drawn. The surface alpha value is a single value that changes the transparency for the entire image. <tt>A</tt> surface alpha of 255 is opaque, and a value of 0 is completely transparent. </p>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
115 <p>Per pixel alphas are different because they store a transparency value for every pixel. This allows for the most precise transparency effects, but it also the slowest. Per pixel alphas cannot be mixed with surface alpha and colorkeys. </p>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
116 <p>There is support for pixel access for the Surfaces. Pixel access on hardware surfaces is slow and not recommended. Pixels can be accessed using the get_at() and set_at() functions. These methods are fine for simple access, but will be considerably slow when doing of pixel work with them. If you plan on doing a lot of pixel level work, it is recommended to use the <tt>pygame.surfarray</tt> module, which can treat the surfaces like large multidimensional arrays (and it's quite quick). </p>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
117 <p>Any functions that directly access a surface's pixel data will need that surface to be lock()'ed. These functions can lock() and unlock() the surfaces themselves without assistance. But, if a function will be called many times, there will be a lot of overhead for multiple locking and unlocking of the surface. It is best to lock the surface manually before making the function call many times, and then unlocking when you are finished. All functions that need a locked surface will say so in their docs. Remember to leave the Surface locked only while necessary. </p>
651
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
118 <p>Surface pixels are stored internally as a single number that has all the colors encoded into it. Use the <tt><a href="surface.html#Surface.map_rgb">Surface.map_rgb</a> - <font size=-1>convert a color into a mapped color value</font></tt> and <tt><a href="surface.html#Surface.unmap_rgb">Surface.unmap_rgb</a> - <font size=-1>convert a mapped integer color value into a Color</font></tt> to convert between individual red, green, and blue values into a packed integer for that Surface. </p>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
119 <p>Surfaces can also reference sections of other Surfaces. These are created with the <tt><a href="surface.html#Surface.subsurface">Surface.subsurface</a> - <font size=-1>create a new surface that references its parent</font></tt> method. Any change to either Surface will effect the other. </p>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
120 <p>Each Surface contains a clipping area. By default the clip area covers the entire Surface. If it is changed, all drawing operations will only effect the smaller area. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
121 <!--COMMENTS:pygame.Surface--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
122
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
123
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
124 <a name="Surface.blit">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
125 <big><b>Surface.blit</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
126 <i>draw one image onto another</i><br>
710
28bbafc4d9de More documentation fixes from Dan Richter
pygame
parents: 678
diff changeset
127 <tt>Surface.blit(source, dest, area=None, special_flags = 0): return Rect</tt><br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
128 <p>Draws a source Surface onto this Surface. The draw can be positioned with the dest argument. Dest can either be pair of coordinates representing the upper left corner of the source. <tt>A</tt> Rect can also be passed as the destination and the topleft corner of the rectangle will be used as the position for the blit. The size of the destination rectangle does not effect the blit. </p>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
129 <p>An optional area rectangle can be passed as well. This represents a smaller portion of the source Surface to draw. </p>
1221
25886fe3a0e8 Bugfix and test for transform.threshold, updated docs (thanks Nirav), added basic tagging to run_tests.py/test_runner.py.
akalias
parents: 1137
diff changeset
130 <p>An optional special flags is for passing in new in <tt>1.8.0:</tt> <tt>BLEND_ADD</tt>, <tt>BLEND_SUB</tt>, <tt>BLEND_MULT</tt>, <tt>BLEND_MIN</tt>, <tt>BLEND_MAX</tt> new in <tt>1.8.1:</tt> <tt>BLEND_RGBA_ADD</tt>, <tt>BLEND_RGBA_SUB</tt>, <tt>BLEND_RGBA_MULT</tt>, <tt>BLEND_RGBA_MIN</tt>, <tt>BLEND_RGBA_MAX</tt> <tt>BLEND_RGB_ADD</tt>, <tt>BLEND_RGB_SUB</tt>, <tt>BLEND_RGB_MULT</tt>, <tt>BLEND_RGB_MIN</tt>, <tt>BLEND_RGB_MAX</tt> With other special blitting flags perhaps added in the future. </p>
710
28bbafc4d9de More documentation fixes from Dan Richter
pygame
parents: 678
diff changeset
131 <p>The return rectangle is the area of the affected pixels, excluding any pixels outside the destination Surface, or outside the clipping area. </p>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
132 <p>Pixel alphas will be ignored when blitting to an 8 bit Surface. </p>
756
333b0c31e389 New docs, with bug fixes from doc comments.
Rene Dudfield <renesd@gmail.com>
parents: 710
diff changeset
133 <p>special_flags new in pygame <tt>1.8</tt>. </p>
1524
28a601e11e62 fix surface self-blits for colorkey and blanket alpha: Bugzilla Bug 19
Lenard Lindstrom <len-l@telus.net>
parents: 1448
diff changeset
134 <p>For a surface with colorkey or blanket alpha, a blit to self may give slightly different colors than a non self-blit. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
135 <!--COMMENTS:Surface.blit--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
136 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
137
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
138
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
139 <a name="Surface.convert">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
140 <big><b>Surface.convert</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
141 <i>change the pixel format of an image</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
142 <tt>Surface.convert(Surface): return Surface</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
143 <tt>Surface.convert(depth, flags=0): return Surface</tt><br>
756
333b0c31e389 New docs, with bug fixes from doc comments.
Rene Dudfield <renesd@gmail.com>
parents: 710
diff changeset
144 <tt>Surface.convert(masks, flags=0): return Surface</tt><br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
145 <tt>Surface.convert(): return Surface</tt><br>
651
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
146 <p>Creates a new copy of the Surface with the pixel format changed. The new pixel format can be determined from another existing Surface. Otherwise depth, flags, and masks arguments can be used, similar to the <tt><a href="surface.html#pygame.Surface">pygame.Surface</a> - <font size=-1>pygame object for representing images</font></tt> call. </p>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
147 <p>If no arguments are passed the new Surface will have the same pixel format as the display Surface. This is always the fastest format for blitting. It is a good idea to convert all Surfaces before they are blitted many times. </p>
651
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
148 <p>The converted Surface will have no pixel alphas. They will be stripped if the original had them. See <tt><a href="surface.html#Surface.convert_alpha">Surface.convert_alpha</a> - <font size=-1>change the pixel format of an image including per pixel alphas</font></tt> for preserving or creating per-pixel alphas. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
149 <!--COMMENTS:Surface.convert--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
150 <br></ul>
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 <a name="Surface.convert_alpha">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
154 <big><b>Surface.convert_alpha</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
155 <i>change the pixel format of an image including per pixel alphas</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
156 <tt>Surface.convert_alpha(Surface): return Surface</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
157 <tt>Surface.convert_alpha(): return Surface</tt><br>
1038
2fab82895a31 Fixed numerous doc comments. Removed wrong Rect.clip_ip() entry.
marcus
parents: 1037
diff changeset
158 <p>Creates a new copy of the surface with the desired pixel format. The new surface will be in a format suited for quick blitting to the given format with per pixel alpha. If no surface is given, the new surface will be optimized for blitting to the current display. </p>
651
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
159 <p>Unlike the <tt><a href="surface.html#Surface.convert">Surface.convert</a> - <font size=-1>change the pixel format of an image</font></tt> method, the pixel format for the new image will not be exactly the same as the requested source, but it will be optimized for fast alpha blitting to the destination. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
160 <!--COMMENTS:Surface.convert_alpha--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
161 <br></ul>
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 <a name="Surface.copy">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
165 <big><b>Surface.copy</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
166 <i>create a new copy of a Surface</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
167 <tt>Surface.copy(): return Surface</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
168 <p>Makes a duplicate copy of a Surface. The new Surface will have the same pixel formats, color palettes, and transparency settings as the original. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
169 <!--COMMENTS:Surface.copy--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
170 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
171
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
172
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
173 <a name="Surface.fill">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
174 <big><b>Surface.fill</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
175 <i>fill Surface with a solid color</i><br>
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents: 810
diff changeset
176 <tt>Surface.fill(color, rect=None, special_flags=0): return Rect</tt><br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
177 <p>Fill the Surface with a solid color. If no rect argument is given the entire Surface will be filled. The rect argument will limit the fill to a specific area. The fill will also be contained by the Surface clip area. </p>
862
57ac2edacc4d Mask can now get bounding rects of set bits.
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
178 <p>The color argument can be either a <tt>RGB</tt> sequence, a <tt>RGBA</tt> sequence or a mapped color index. If using <tt>RGBA</tt>, the Alpha <tt>(A</tt> part of <tt>RGBA)</tt> is ignored unless the surface uses per pixel alpha (Surface has the <tt>SRCALPHA</tt> flag). </p>
1221
25886fe3a0e8 Bugfix and test for transform.threshold, updated docs (thanks Nirav), added basic tagging to run_tests.py/test_runner.py.
akalias
parents: 1137
diff changeset
179 <p>An optional special_flags is for passing in new in <tt>1.8.0:</tt> <tt>BLEND_ADD</tt>, <tt>BLEND_SUB</tt>, <tt>BLEND_MULT</tt>, <tt>BLEND_MIN</tt>, <tt>BLEND_MAX</tt> new in <tt>1.8.1:</tt> <tt>BLEND_RGBA_ADD</tt>, <tt>BLEND_RGBA_SUB</tt>, <tt>BLEND_RGBA_MULT</tt>, <tt>BLEND_RGBA_MIN</tt>, <tt>BLEND_RGBA_MAX</tt> <tt>BLEND_RGB_ADD</tt>, <tt>BLEND_RGB_SUB</tt>, <tt>BLEND_RGB_MULT</tt>, <tt>BLEND_RGB_MIN</tt>, <tt>BLEND_RGB_MAX</tt> With other special blitting flags perhaps added in the future. </p>
710
28bbafc4d9de More documentation fixes from Dan Richter
pygame
parents: 678
diff changeset
180 <p>This will return the affected Surface area. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
181 <!--COMMENTS:Surface.fill--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
182 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
183
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
184
1525
48ab3db38416 add Surface.scroll method
Lenard Lindstrom <len-l@telus.net>
parents: 1524
diff changeset
185 <a name="Surface.scroll">
48ab3db38416 add Surface.scroll method
Lenard Lindstrom <len-l@telus.net>
parents: 1524
diff changeset
186 <big><b>Surface.scroll</big></b><br><ul>
48ab3db38416 add Surface.scroll method
Lenard Lindstrom <len-l@telus.net>
parents: 1524
diff changeset
187 <i>Shift the surface image in place</i><br>
48ab3db38416 add Surface.scroll method
Lenard Lindstrom <len-l@telus.net>
parents: 1524
diff changeset
188 <tt>Surface.scroll(dx=0, dy=0): return None</tt><br>
48ab3db38416 add Surface.scroll method
Lenard Lindstrom <len-l@telus.net>
parents: 1524
diff changeset
189 <p>Move the image by dx pixels right and dy pixels down. dx and dy may be negative for left and up scrolls respectively. Areas of the surface that are not overwritten retain their original pixel values. Scrolling is contained by the Surface clip area. It is safe to have dx and dy values that exceed the surface size. </p>
1849
301bc61643a9 merged changes from trunk
lorenz
parents: 1839
diff changeset
190 <p>New in Pygame <tt>1.9</tt> </p>
1525
48ab3db38416 add Surface.scroll method
Lenard Lindstrom <len-l@telus.net>
parents: 1524
diff changeset
191 <!--COMMENTS:Surface.scroll--> &nbsp;<br>
48ab3db38416 add Surface.scroll method
Lenard Lindstrom <len-l@telus.net>
parents: 1524
diff changeset
192 <br></ul>
48ab3db38416 add Surface.scroll method
Lenard Lindstrom <len-l@telus.net>
parents: 1524
diff changeset
193
48ab3db38416 add Surface.scroll method
Lenard Lindstrom <len-l@telus.net>
parents: 1524
diff changeset
194
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
195 <a name="Surface.set_colorkey">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
196 <big><b>Surface.set_colorkey</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
197 <i>Set the transparent colorkey</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
198 <tt>Surface.set_colorkey(Color, flags=0): return None</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
199 <tt>Surface.set_colorkey(None): return None</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
200 <p>Set the current color key for the Surface. When blitting this Surface onto a destination, and pixels that have the same color as the colorkey will be transparent. The color can be an <tt>RGB</tt> color or a mapped color integer. If None is passed, the colorkey will be unset. </p>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
201 <p>The colorkey will be ignored if the Surface is formatted to use per pixel alpha values. The colorkey can be mixed with the full Surface alpha value. </p>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
202 <p>The optional flags argument can be set to <tt>pygame.RLEACCEL</tt> to provide better performance on non accelerated displays. An <tt>RLEACCEL</tt> Surface will be slower to modify, but quicker to blit as a source. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
203 <!--COMMENTS:Surface.set_colorkey--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
204 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
205
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
206
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
207 <a name="Surface.get_colorkey">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
208 <big><b>Surface.get_colorkey</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
209 <i>Get the current transparent colorkey</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
210 <tt>Surface.get_colorkey(): return RGB or None</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
211 <p>Return the current colorkey value for the Surface. If the colorkey is not set then None is returned. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
212 <!--COMMENTS:Surface.get_colorkey--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
213 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
214
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
215
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
216 <a name="Surface.set_alpha">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
217 <big><b>Surface.set_alpha</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
218 <i>set the alpha value for the full Surface image</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
219 <tt>Surface.set_alpha(value, flags=0): return None</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
220 <tt>Surface.set_alpha(None): return None</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
221 <p>Set the current alpha value fo r the Surface. When blitting this Surface onto a destination, the pixels will be drawn slightly transparent. The alpha value is an integer from 0 to 255, 0 is fully transparent and 255 is fully opaque. If None is passed for the alpha value, then the Surface alpha will be disabled. </p>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
222 <p>This value is different than the per pixel Surface alpha. If the Surface format contains per pixel alphas, then this alpha value will be ignored. If the Surface contains per pixel alphas, setting the alpha value to None will disable the per pixel transparency. </p>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
223 <p>The optional flags argument can be set to <tt>pygame.RLEACCEL</tt> to provide better performance on non accelerated displays. An <tt>RLEACCEL</tt> Surface will be slower to modify, but quicker to blit as a source. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
224 <!--COMMENTS:Surface.set_alpha--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
225 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
226
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
227
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
228 <a name="Surface.get_alpha">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
229 <big><b>Surface.get_alpha</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
230 <i>get the current Surface transparency value</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
231 <tt>Surface.get_alpha(): return int_value or None</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
232 <p>Return the current alpha value for the Surface. If the alpha value is not set then None is returned. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
233 <!--COMMENTS:Surface.get_alpha--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
234 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
235
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
236
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
237 <a name="Surface.lock">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
238 <big><b>Surface.lock</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
239 <i>lock the Surface memory for pixel access</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
240 <tt>Surface.lock(): return None</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
241 <p>Lock the pixel data of a Surface for access. On accelerated Surfaces, the pixel data may be stored in volatile video memory or nonlinear compressed forms. When a Surface is locked the pixel memory becomes available to access by regular software. Code that reads or writes pixel values will need the Surface to be locked. </p>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
242 <p>Surfaces should not remain locked for more than necessary. <tt>A</tt> locked Surface can often not be displayed or managed by Pygame. </p>
651
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
243 <p>Not all Surfaces require locking. The <tt><a href="surface.html#Surface.mustlock">Surface.mustlock</a> - <font size=-1>test if the Surface requires locking</font></tt> method can determine if it is actually required. There is no performance penalty for locking and unlocking a Surface that does not need it. </p>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
244 <p>All pygame functions will automatically lock and unlock the Surface data as needed. If a section of code is going to make calls that will repeatedly lock and unlock the Surface many times, it can be helpful to wrap the block inside a lock and unlock pair. </p>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
245 <p>It is safe to nest locking and unlocking calls. The surface will only be unlocked after the final lock is released. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
246 <!--COMMENTS:Surface.lock--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
247 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
248
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
249
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
250 <a name="Surface.unlock">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
251 <big><b>Surface.unlock</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
252 <i>unlock the Surface memory from pixel access</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
253 <tt>Surface.unlock(): return None</tt><br>
651
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
254 <p>Unlock the Surface pixel data after it has been locked. The unlocked Surface can once again be drawn and managed by Pygame. See the <tt><a href="surface.html#Surface.lock">Surface.lock</a> - <font size=-1>lock the Surface memory for pixel access</font></tt> documentation for more details. </p>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
255 <p>All pygame functions will automatically lock and unlock the Surface data as needed. If a section of code is going to make calls that will repeatedly lock and unlock the Surface many times, it can be helpful to wrap the block inside a lock and unlock pair. </p>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
256 <p>It is safe to nest locking and unlocking calls. The surface will only be unlocked after the final lock is released. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
257 <!--COMMENTS:Surface.unlock--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
258 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
259
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
260
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
261 <a name="Surface.mustlock">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
262 <big><b>Surface.mustlock</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
263 <i>test if the Surface requires locking</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
264 <tt>Surface.mustlock(): return bool</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
265 <p>Returns True if the Surface is required to be locked to access pixel data. Usually pure software Surfaces do not require locking. This method is rarely needed, since it is safe and quickest to just lock all Surfaces as needed. </p>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
266 <p>All pygame functions will automatically lock and unlock the Surface data as needed. If a section of code is going to make calls that will repeatedly lock and unlock the Surface many times, it can be helpful to wrap the block inside a lock and unlock pair. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
267 <!--COMMENTS:Surface.mustlock--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
268 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
269
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
270
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
271 <a name="Surface.get_locked">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
272 <big><b>Surface.get_locked</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
273 <i>test if the Surface is current locked</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
274 <tt>Surface.get_locked(): return bool</tt><br>
1137
ec3ced33488f Reworked locking code to be more strict about locking.
marcus
parents: 1038
diff changeset
275 <p>Returns True when the Surface is locked. It doesn't matter how many times the Surface is locked. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
276 <!--COMMENTS:Surface.get_locked--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
277 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
278
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
279
1137
ec3ced33488f Reworked locking code to be more strict about locking.
marcus
parents: 1038
diff changeset
280 <a name="Surface.get_locks">
ec3ced33488f Reworked locking code to be more strict about locking.
marcus
parents: 1038
diff changeset
281 <big><b>Surface.get_locks</big></b><br><ul>
ec3ced33488f Reworked locking code to be more strict about locking.
marcus
parents: 1038
diff changeset
282 <i>Gets the locks for the Surface</i><br>
ec3ced33488f Reworked locking code to be more strict about locking.
marcus
parents: 1038
diff changeset
283 <tt>Surface.get_locks(): return tuple</tt><br>
ec3ced33488f Reworked locking code to be more strict about locking.
marcus
parents: 1038
diff changeset
284 <p>Returns the currently existing locks for the Surface. </p>
ec3ced33488f Reworked locking code to be more strict about locking.
marcus
parents: 1038
diff changeset
285 <!--COMMENTS:Surface.get_locks--> &nbsp;<br>
ec3ced33488f Reworked locking code to be more strict about locking.
marcus
parents: 1038
diff changeset
286 <br></ul>
ec3ced33488f Reworked locking code to be more strict about locking.
marcus
parents: 1038
diff changeset
287
ec3ced33488f Reworked locking code to be more strict about locking.
marcus
parents: 1038
diff changeset
288
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
289 <a name="Surface.get_at">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
290 <big><b>Surface.get_at</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
291 <i>get the color value at a single pixel</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
292 <tt>Surface.get_at((x, y)): return Color</tt><br>
1839
02c1e8e9c102 merged changes from trunk to math_module branch
lorenz
parents: 1781
diff changeset
293 <p>Return a copy of the <tt>RGBA</tt> Color value at the given pixel. If the Surface has no per pixel alpha, then the alpha value will always be 255 (opaque). If the pixel position is outside the area of the Surface an IndexError exception will be raised. </p>
02c1e8e9c102 merged changes from trunk to math_module branch
lorenz
parents: 1781
diff changeset
294 <p>Getting and setting pixels one at a time is generally too slow to be used in a game or realtime situation. It is better to use methods which operate on many pixels at a time like with the blit, fill and draw methods - or by using surfarray/PixelArray. </p>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
295 <p>This function will temporarily lock and unlock the Surface as needed. </p>
1839
02c1e8e9c102 merged changes from trunk to math_module branch
lorenz
parents: 1781
diff changeset
296 <p>Returning a Color instead of tuple, New in pygame <tt>1.9.0</tt>. Use <tt>tuple(surf.get_at((x,y)))</tt> if you want a tuple, and not a Color. This should only matter if you want to use the color as a key in a dict. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
297 <!--COMMENTS:Surface.get_at--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
298 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
299
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
300
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
301 <a name="Surface.set_at">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
302 <big><b>Surface.set_at</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
303 <i>set the color value for a single pixel</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
304 <tt>Surface.set_at((x, y), Color): return None</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
305 <p>Set the <tt>RGBA</tt> or mapped integer color value for a single pixel. If the Surface does not have per pixel alphas, the alpha value is ignored. Settting pixels outside the Surface area or outside the Surface clipping will have no effect. </p>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
306 <p>Getting and setting pixels one at a time is generally too slow to be used in a game or realtime situation. </p>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
307 <p>This function will temporarily lock and unlock the Surface as needed. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
308 <!--COMMENTS:Surface.set_at--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
309 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
310
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
311
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
312 <a name="Surface.get_palette">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
313 <big><b>Surface.get_palette</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
314 <i>get the color index palette for an 8bit Surface</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
315 <tt>Surface.get_palette(): return [RGB, RGB, RGB, ...]</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
316 <p>Return a list of up to 256 color elements that represent the indexed colors used in an 8bit Surface. The returned list is a copy of the palette, and changes will have no effect on the Surface. </p>
1839
02c1e8e9c102 merged changes from trunk to math_module branch
lorenz
parents: 1781
diff changeset
317 <p>Returning a list of Color(with length 3) instances instead of tuples, New in pygame <tt>1.9.0</tt> </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
318 <!--COMMENTS:Surface.get_palette--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
319 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
320
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
321
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
322 <a name="Surface.get_palette_at">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
323 <big><b>Surface.get_palette_at</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
324 <i>get the color for a single entry in a palette</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
325 <tt>Surface.get_palette_at(index): return RGB</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
326 <p>Returns the red, green, and blue color values for a single index in a Surface palette. The index should be a value from 0 to 255. </p>
1839
02c1e8e9c102 merged changes from trunk to math_module branch
lorenz
parents: 1781
diff changeset
327 <p>Returning Color(with length 3) instance instead of a tuple, New in pygame <tt>1.9.0</tt> </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
328 <!--COMMENTS:Surface.get_palette_at--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
329 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
330
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
331
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
332 <a name="Surface.set_palette">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
333 <big><b>Surface.set_palette</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
334 <i>set the color palette for an 8bit Surface</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
335 <tt>Surface.set_palette([RGB, RGB, RGB, ...]): return None</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
336 <p>Set the full palette for an 8bit Surface. This will replace the colors in the existing palette. <tt>A</tt> partial palette can be passed and only the first colors in the original palette will be changed. </p>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
337 <p>This function has no effect on a Surface with more than 8bits per pixel. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
338 <!--COMMENTS:Surface.set_palette--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
339 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
340
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
341
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
342 <a name="Surface.set_palette_at">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
343 <big><b>Surface.set_palette_at</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
344 <i>set the color for a single index in an 8bit Surface palette</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
345 <tt>Surface.set_at(index, RGB): return None</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
346 <p>Set the palette value for a single entry in a Surface palette. The index should be a value from 0 to 255. </p>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
347 <p>This function has no effect on a Surface with more than 8bits per pixel. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
348 <!--COMMENTS:Surface.set_palette_at--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
349 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
350
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
351
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
352 <a name="Surface.map_rgb">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
353 <big><b>Surface.map_rgb</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
354 <i>convert a color into a mapped color value</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
355 <tt>Surface.map_rgb(Color): return mapped_int</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
356 <p>Convert an <tt>RGBA</tt> color into the mapped integer value for this Surface. The returned integer will contain no more bits than the bit depth of the Surface. Mapped color values are not often used inside Pygame, but can be passed to most functions that require a Surface and a color. </p>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
357 <p>See the Surface object documentation for more information about colors and pixel formats. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
358 <!--COMMENTS:Surface.map_rgb--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
359 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
360
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
361
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
362 <a name="Surface.unmap_rgb">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
363 <big><b>Surface.unmap_rgb</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
364 <i>convert a mapped integer color value into a Color</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
365 <tt>Surface.map_rgb(mapped_int): return Color</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
366 <p>Convert an mapped integer color into the <tt>RGB</tt> color components for this Surface. Mapped color values are not often used inside Pygame, but can be passed to most functions that require a Surface and a color. </p>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
367 <p>See the Surface object documentation for more information about colors and pixel formats. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
368 <!--COMMENTS:Surface.unmap_rgb--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
369 <br></ul>
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 <a name="Surface.set_clip">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
373 <big><b>Surface.set_clip</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
374 <i>set the current clipping area of the Surface</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
375 <tt>Surface.set_clip(rect): return None</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
376 <tt>Surface.set_clip(None): return None</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
377 <p>Each Surface has an active clipping area. This is a rectangle that represents the only pixels on the Surface that can be modified. If None is passed for the rectangle the full Surface will be available for changes. </p>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
378 <p>The clipping area is always restricted to the area of the Surface itself. If the clip rectangle is too large it will be shrunk to fit inside the Surface. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
379 <!--COMMENTS:Surface.set_clip--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
380 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
381
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
382
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
383 <a name="Surface.get_clip">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
384 <big><b>Surface.get_clip</big></b><br><ul>
1036
e0f8354aa687 Some documentation updates... mainly updating sprite docs. More to do...
Rene Dudfield <renesd@gmail.com>
parents: 974
diff changeset
385 <i>get the current clipping area of the Surface</i><br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
386 <tt>Surface.get_clip(): return Rect</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
387 <p>Return a rectangle of the current clipping area. The Surface will always return a valid rectangle that will never be outside the bounds of the image. If the Surface has had None set for the clipping area, the Surface will return a rectangle with the full area of the Surface. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
388 <!--COMMENTS:Surface.get_clip--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
389 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
390
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
391
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
392 <a name="Surface.subsurface">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
393 <big><b>Surface.subsurface</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
394 <i>create a new surface that references its parent</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
395 <tt>Surface.subsurface(Rect): return Surface</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
396 <p>Returns a new Surface that shares its pixels with its new parent. The new Surface is considered a child of the original. Modifications to either Surface pixels will effect each other. Surface information like clipping area and color keys are unique to each Surface. </p>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
397 <p>The new Surface will inherit the palette, color key, and alpha settings from its parent. </p>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
398 <p>It is possible to have any number of subsurfaces and subsubsurfaces on the parent. It is also possible to subsurface the display Surface if the display mode is not hardware accelerated. </p>
651
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
399 <p>See the <tt><a href="surface.html#Surface.get_offset">Surface.get_offset</a> - <font size=-1>find the position of a child subsurface inside a parent</font></tt>, <tt><a href="surface.html#Surface.get_parent">Surface.get_parent</a> - <font size=-1>find the parent of a subsurface</font></tt> to learn more about the state of a subsurface. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
400 <!--COMMENTS:Surface.subsurface--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
401 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
402
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
403
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
404 <a name="Surface.get_parent">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
405 <big><b>Surface.get_parent</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
406 <i>find the parent of a subsurface</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
407 <tt>Surface.get_parent(): return Surface</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
408 <p>Returns the parent Surface of a subsurface. If this is not a subsurface then None will be returned. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
409 <!--COMMENTS:Surface.get_parent--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
410 <br></ul>
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 <a name="Surface.get_abs_parent">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
414 <big><b>Surface.get_abs_parent</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
415 <i>find the top level parent of a subsurface</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
416 <tt>Surface.get_abs_parent(): return Surface</tt><br>
756
333b0c31e389 New docs, with bug fixes from doc comments.
Rene Dudfield <renesd@gmail.com>
parents: 710
diff changeset
417 <p>Returns the parent Surface of a subsurface. If this is not a subsurface then this surface will be returned. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
418 <!--COMMENTS:Surface.get_abs_parent--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
419 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
420
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
421
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
422 <a name="Surface.get_offset">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
423 <big><b>Surface.get_offset</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
424 <i>find the position of a child subsurface inside a parent</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
425 <tt>Surface.get_offset(): return (x, y)</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
426 <p>Get the offset position of a child subsurface inside of a parent. If the Surface is not a subsurface this will return (0, 0). </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
427 <!--COMMENTS:Surface.get_offset--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
428 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
429
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
430
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
431 <a name="Surface.get_abs_offset">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
432 <big><b>Surface.get_abs_offset</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
433 <i>find the absolute position of a child subsurface inside its top level parent</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
434 <tt>Surface.get_abs_offset(): return (x, y)</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
435 <p>Get the offset position of a child subsurface inside of its top level parent Surface. If the Surface is not a subsurface this will return (0, 0). </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
436 <!--COMMENTS:Surface.get_abs_offset--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
437 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
438
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
439
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
440 <a name="Surface.get_size">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
441 <big><b>Surface.get_size</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
442 <i>get the dimensions of the Surface</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
443 <tt>Surface.get_size(): return (width, height)</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
444 <p>Return the width and height of the Surface in pixels. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
445 <!--COMMENTS:Surface.get_size--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
446 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
447
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
448
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
449 <a name="Surface.get_width">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
450 <big><b>Surface.get_width</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
451 <i>get the width of the Surface</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
452 <tt>Surface.get_width(): return width</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
453 <p>Return the width of the Surface in pixels. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
454 <!--COMMENTS:Surface.get_width--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
455 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
456
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
457
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
458 <a name="Surface.get_height">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
459 <big><b>Surface.get_height</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
460 <i>get the height of the Surface</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
461 <tt>Surface.get_height(): return height</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
462 <p>Return the height of the Surface in pixels. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
463 <!--COMMENTS:Surface.get_height--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
464 <br></ul>
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 <a name="Surface.get_rect">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
468 <big><b>Surface.get_rect</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
469 <i>get the rectangular area of the Surface</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
470 <tt>Surface.get_rect(**kwargs): return Rect</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
471 <p>Returns a new rectangle covering the entire surface. This rectangle will always start at 0, 0 with a width. and height the same size as the image. </p>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
472 <p>You can pass keyword argument values to this function. These named values will be applied to the attributes of the Rect before it is returned. An example would be <tt>'mysurf.get_rect(center=(100,100))'</tt> to create a rectangle for the Surface centered at a given position. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
473 <!--COMMENTS:Surface.get_rect--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
474 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
475
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
476
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
477 <a name="Surface.get_bitsize">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
478 <big><b>Surface.get_bitsize</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
479 <i>get the bit depth of the Surface pixel format</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
480 <tt>Surface.get_bitsize(): return int</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
481 <p>Returns the number of bits used to represent each pixel. This value may not exactly fill the number of bytes used per pixel. For example a 15 bit Surface still requires a full 2 bytes. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
482 <!--COMMENTS:Surface.get_bitsize--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
483 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
484
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
485
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
486 <a name="Surface.get_bytesize">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
487 <big><b>Surface.get_bytesize</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
488 <i>get the bytes used per Surface pixel</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
489 <tt>Surface.get_bytesize(): return int</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
490 <p>Return the number of bytes used per pixel. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
491 <!--COMMENTS:Surface.get_bytesize--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
492 <br></ul>
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 <a name="Surface.get_flags">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
496 <big><b>Surface.get_flags</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
497 <i>get the additional flags used for the Surface</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
498 <tt>Surface.get_flags(): return int</tt><br>
756
333b0c31e389 New docs, with bug fixes from doc comments.
Rene Dudfield <renesd@gmail.com>
parents: 710
diff changeset
499 <p>Returns a set of current Surface features. Each feature is a bit in the flags bitmask. Typical flags are <tt>HWSURFACE</tt>, <tt>RLEACCEL</tt>, <tt>SRCALPHA</tt>, and <tt>SRCCOLORKEY</tt>. </p>
333b0c31e389 New docs, with bug fixes from doc comments.
Rene Dudfield <renesd@gmail.com>
parents: 710
diff changeset
500 <p>Here is a more complete list of flags. <tt>A</tt> full list can be found in <tt>SDL_video.h</tt> </p>
333b0c31e389 New docs, with bug fixes from doc comments.
Rene Dudfield <renesd@gmail.com>
parents: 710
diff changeset
501 <pre> SWSURFACE 0x00000000 # Surface is in system memory
333b0c31e389 New docs, with bug fixes from doc comments.
Rene Dudfield <renesd@gmail.com>
parents: 710
diff changeset
502 HWSURFACE 0x00000001 # Surface is in video memory
333b0c31e389 New docs, with bug fixes from doc comments.
Rene Dudfield <renesd@gmail.com>
parents: 710
diff changeset
503 ASYNCBLIT 0x00000004 # Use asynchronous blits if possible
333b0c31e389 New docs, with bug fixes from doc comments.
Rene Dudfield <renesd@gmail.com>
parents: 710
diff changeset
504 </pre><p>Available for <tt><a href="display.html#pygame.display.set_mode">pygame.display.set_mode</a> - <font size=-1>initialize a window or screen for display</font></tt> </p>
333b0c31e389 New docs, with bug fixes from doc comments.
Rene Dudfield <renesd@gmail.com>
parents: 710
diff changeset
505 <pre> ANYFORMAT 0x10000000 # Allow any video depth/pixel-format
333b0c31e389 New docs, with bug fixes from doc comments.
Rene Dudfield <renesd@gmail.com>
parents: 710
diff changeset
506 HWPALETTE 0x20000000 # Surface has exclusive palette
333b0c31e389 New docs, with bug fixes from doc comments.
Rene Dudfield <renesd@gmail.com>
parents: 710
diff changeset
507 DOUBLEBUF 0x40000000 # Set up double-buffered video mode
333b0c31e389 New docs, with bug fixes from doc comments.
Rene Dudfield <renesd@gmail.com>
parents: 710
diff changeset
508 FULLSCREEN 0x80000000 # Surface is a full screen display
333b0c31e389 New docs, with bug fixes from doc comments.
Rene Dudfield <renesd@gmail.com>
parents: 710
diff changeset
509 OPENGL 0x00000002 # Create an OpenGL rendering context
333b0c31e389 New docs, with bug fixes from doc comments.
Rene Dudfield <renesd@gmail.com>
parents: 710
diff changeset
510 OPENGLBLIT 0x0000000A # Create an OpenGL rendering context
333b0c31e389 New docs, with bug fixes from doc comments.
Rene Dudfield <renesd@gmail.com>
parents: 710
diff changeset
511 # and use it for blitting. Obsolete.
333b0c31e389 New docs, with bug fixes from doc comments.
Rene Dudfield <renesd@gmail.com>
parents: 710
diff changeset
512 RESIZABLE 0x00000010 # This video mode may be resized
333b0c31e389 New docs, with bug fixes from doc comments.
Rene Dudfield <renesd@gmail.com>
parents: 710
diff changeset
513 NOFRAME 0x00000020 # No window caption or edge frame
333b0c31e389 New docs, with bug fixes from doc comments.
Rene Dudfield <renesd@gmail.com>
parents: 710
diff changeset
514 </pre><p>Used internally (read-only) </p>
333b0c31e389 New docs, with bug fixes from doc comments.
Rene Dudfield <renesd@gmail.com>
parents: 710
diff changeset
515 <pre> HWACCEL 0x00000100 # Blit uses hardware acceleration
333b0c31e389 New docs, with bug fixes from doc comments.
Rene Dudfield <renesd@gmail.com>
parents: 710
diff changeset
516 SRCCOLORKEY 0x00001000 # Blit uses a source color key
333b0c31e389 New docs, with bug fixes from doc comments.
Rene Dudfield <renesd@gmail.com>
parents: 710
diff changeset
517 RLEACCELOK 0x00002000 # Private flag
333b0c31e389 New docs, with bug fixes from doc comments.
Rene Dudfield <renesd@gmail.com>
parents: 710
diff changeset
518 RLEACCEL 0x00004000 # Surface is RLE encoded
333b0c31e389 New docs, with bug fixes from doc comments.
Rene Dudfield <renesd@gmail.com>
parents: 710
diff changeset
519 SRCALPHA 0x00010000 # Blit uses source alpha blending
333b0c31e389 New docs, with bug fixes from doc comments.
Rene Dudfield <renesd@gmail.com>
parents: 710
diff changeset
520 PREALLOC 0x01000000 # Surface uses preallocated memory
333b0c31e389 New docs, with bug fixes from doc comments.
Rene Dudfield <renesd@gmail.com>
parents: 710
diff changeset
521 </pre>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
522 <!--COMMENTS:Surface.get_flags--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
523 <br></ul>
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 <a name="Surface.get_pitch">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
527 <big><b>Surface.get_pitch</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
528 <i>get the number of bytes used per Surface row</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
529 <tt>Surface.get_pitch(): return int</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
530 <p>Return the number of bytes separating each row in the Surface. Surfaces in video memory are not always linearly packed. Subsurfaces will also have a larger pitch than their real width. </p>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
531 <p>This value is not needed for normal Pygame usage. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
532 <!--COMMENTS:Surface.get_pitch--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
533 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
534
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
535
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
536 <a name="Surface.get_masks">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
537 <big><b>Surface.get_masks</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
538 <i>the bitmasks needed to convert between a color and a mapped integer</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
539 <tt>Surface.get_masks(): return (R, G, B, A)</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
540 <p>Returns the bitmasks used to isolate each color in a mapped integer. </p>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
541 <p>This value is not needed for normal Pygame usage. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
542 <!--COMMENTS:Surface.get_masks--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
543 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
544
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
545
1234
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1221
diff changeset
546 <a name="Surface.set_masks">
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1221
diff changeset
547 <big><b>Surface.set_masks</big></b><br><ul>
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1221
diff changeset
548 <i>set the bitmasks needed to convert between a color and a mapped integer</i><br>
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1221
diff changeset
549 <tt>Surface.set_masks((r,g,b,a)): return None</tt><br>
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1221
diff changeset
550 <p>This is not needed for normal Pygame usage. New in pygame <tt>1.8.1</tt> </p>
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1221
diff changeset
551 <!--COMMENTS:Surface.set_masks--> &nbsp;<br>
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1221
diff changeset
552 <br></ul>
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1221
diff changeset
553
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1221
diff changeset
554
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
555 <a name="Surface.get_shifts">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
556 <big><b>Surface.get_shifts</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
557 <i>the bit shifts needed to convert between a color and a mapped integer</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
558 <tt>Surface.get_shifts(): return (R, G, B, A)</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
559 <p>Returns the pixel shifts need to convert between each color and a mapped integer. </p>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
560 <p>This value is not needed for normal Pygame usage. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
561 <!--COMMENTS:Surface.get_shifts--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
562 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
563
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
564
1234
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1221
diff changeset
565 <a name="Surface.set_shifts">
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1221
diff changeset
566 <big><b>Surface.set_shifts</big></b><br><ul>
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1221
diff changeset
567 <i>sets the bit shifts needed to convert between a color and a mapped integer</i><br>
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1221
diff changeset
568 <tt>Surface.get_shifts((r,g,b,a)): return None</tt><br>
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1221
diff changeset
569 <p>This is not needed for normal Pygame usage. New in pygame <tt>1.8.1</tt> </p>
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1221
diff changeset
570 <!--COMMENTS:Surface.set_shifts--> &nbsp;<br>
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1221
diff changeset
571 <br></ul>
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1221
diff changeset
572
2ad2aa11e514 Added Surface.set_masks and .set_shifts useful for using data in
Rene Dudfield <renesd@gmail.com>
parents: 1221
diff changeset
573
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
574 <a name="Surface.get_losses">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
575 <big><b>Surface.get_losses</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
576 <i>the significant bits used to convert between a color and a mapped integer</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
577 <tt>Surface.get_losses(): return (R, G, B, A)</tt><br>
957
a1b08375b132 Added display.set_mode() resolution enhancement as posted by Lorenz Quack.
marcus
parents: 862
diff changeset
578 <p>Return the least significant number of bits stripped from each color in a mapped integer. </p>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
579 <p>This value is not needed for normal Pygame usage. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
580 <!--COMMENTS:Surface.get_losses--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
581 <br></ul>
862
57ac2edacc4d Mask can now get bounding rects of set bits.
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
582
57ac2edacc4d Mask can now get bounding rects of set bits.
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
583
957
a1b08375b132 Added display.set_mode() resolution enhancement as posted by Lorenz Quack.
marcus
parents: 862
diff changeset
584 <a name="Surface.get_bounding_rect">
a1b08375b132 Added display.set_mode() resolution enhancement as posted by Lorenz Quack.
marcus
parents: 862
diff changeset
585 <big><b>Surface.get_bounding_rect</big></b><br><ul>
a1b08375b132 Added display.set_mode() resolution enhancement as posted by Lorenz Quack.
marcus
parents: 862
diff changeset
586 <i>find the smallest rect containing data</i><br>
a1b08375b132 Added display.set_mode() resolution enhancement as posted by Lorenz Quack.
marcus
parents: 862
diff changeset
587 <tt>Surface.get_bounding_rect(min_alpha = 1): return Rect</tt><br>
a1b08375b132 Added display.set_mode() resolution enhancement as posted by Lorenz Quack.
marcus
parents: 862
diff changeset
588 <p>Returns the smallest rectangular region that contains all the pixels in the surface that have an alpha value greater than or equal to the minimum alpha value. </p>
a1b08375b132 Added display.set_mode() resolution enhancement as posted by Lorenz Quack.
marcus
parents: 862
diff changeset
589 <p>This function will temporarily lock and unlock the Surface as needed. </p>
a1b08375b132 Added display.set_mode() resolution enhancement as posted by Lorenz Quack.
marcus
parents: 862
diff changeset
590 <p>New in pygame <tt>1.8</tt>. </p>
a1b08375b132 Added display.set_mode() resolution enhancement as posted by Lorenz Quack.
marcus
parents: 862
diff changeset
591 <!--COMMENTS:Surface.get_bounding_rect--> &nbsp;<br>
a1b08375b132 Added display.set_mode() resolution enhancement as posted by Lorenz Quack.
marcus
parents: 862
diff changeset
592 <br></ul>
a1b08375b132 Added display.set_mode() resolution enhancement as posted by Lorenz Quack.
marcus
parents: 862
diff changeset
593
a1b08375b132 Added display.set_mode() resolution enhancement as posted by Lorenz Quack.
marcus
parents: 862
diff changeset
594
862
57ac2edacc4d Mask can now get bounding rects of set bits.
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
595 <a name="Surface.get_buffer">
57ac2edacc4d Mask can now get bounding rects of set bits.
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
596 <big><b>Surface.get_buffer</big></b><br><ul>
57ac2edacc4d Mask can now get bounding rects of set bits.
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
597 <i>acquires a buffer object for the pixels of the Surface.</i><br>
57ac2edacc4d Mask can now get bounding rects of set bits.
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
598 <tt>Surface.get_buffer(): return BufferProxy</tt><br>
57ac2edacc4d Mask can now get bounding rects of set bits.
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
599 <p>Return a buffer object for the pixels of the Surface. The buffer can be used for direct pixel access and manipulation. </p>
57ac2edacc4d Mask can now get bounding rects of set bits.
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
600 <p>This method implicitly locks the Surface. The lock will be released, once the returned BufferProxy object is deleted. </p>
57ac2edacc4d Mask can now get bounding rects of set bits.
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
601 <p>New in pygame <tt>1.8</tt>. </p>
57ac2edacc4d Mask can now get bounding rects of set bits.
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
602 <!--COMMENTS:Surface.get_buffer--> &nbsp;<br>
57ac2edacc4d Mask can now get bounding rects of set bits.
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
603 <br></ul>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
604 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
605
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
606 </body></html>