[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[pygame] chewy changes to cvs



well, i made more 'breaking' changes to cvs. here's the snip from
the WHATSNEW file...

Nov 28, 2000
 Surface.convert() better handles surface flags
 All color arguments (and returns) are RGBA format [BREAK]
 Removed Surface.map_rgba and unmap_rgba [BREAK]
 Added a default font, used by passing None as font file
 pygame.font.font changed to pygame.font.new_font() [BREAK]


the main change is the use of RGBA sequences for all color
arguments. The RGBA arguments are simply a sequence of 3
or 4 numeric values. The alpha argument is always optional
and defaults to 255 (opaque) when not given. functions that
return RGBA (get_at, get_colorkey) will always return RGBA
as a 4-item tuple, regardless if the surface is using
per-pixel alpha. (again, the alpha will default to 255)

i benchmarked the "stars" example which does nothing but
make calls to Surface.set_at(). These types of programs will
see the biggest performance differences in using prepacked
colors and RGB[A] sequences. i was surprised to find that
stars.py using RGBA only lost about 1fps on my test machine,
that turns out to be around 3%. because the speed is so close,
there won't be any need to make functions with dual-interfaces
taking either packed-colors or RGBAs.
this is a big win, since RGBA is much clearer than using map_rgb
to get mysterious intergers, and the performance difference seems
negligable. even 8bit ran at a similar speed, but i didn't bench
8bit, sorry.

also, since RGBA can handle the optional alpha, there is no need
for the map_rgba() and unmap_rgba() functions. they were removed
since map_rgb() and unmap_rgb() can handle everything now. actually,
at this point there is very little need for the map/unmap functions,
but we'll certainly leave them in for completeness. (for now...)


on another note, there is now a standard TTF font object that
gets copied into the pygame package directory. when creating a
font you can pass "None" as the filename and pygame will use
that default font. i think this will help out a lot, since many
times i just want to display some text on the screen, not worry
about what and where my TTF files are.

also note that creating fonts is now done with new_font(), this
matches the rest of the constructor functions. stay tuned later
tonight as we start try to find a better naming scheme for all
these constructor-ish functions.

as always, the documentation and examples are up to date with
these changes. you may find old paragraphs in the docs explaining
why RGB values need to be packed before use, but the function
prototypes and reference should all be correct.


____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org