[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] BUG:? color incompatibility in pygame 1.8.1release versus 1.7.1release
According the the pygame.color.Color doc string the alpha portion is
optional: "With the hex color formatting you may optionally include an
alpha value, the formatting is 0xRRGGBBAA. You may also specify a hex
formatted color by starting the string with a '#'." In Pygame a three
element color is understood to have an alpha of 255. This is the case
elsewhere in the package. It is consistent with non per-pixel alpha
colors. A zero alpha is not:
>>> s = pygame.Surface((1, 1), pygame.SRCALPHA, 32)
>>> s.get_at((0, 0))
(0, 0, 0, 0)
>>> s.fill((1, 2, 3))
<rect(0, 0, 1, 1)>
>>> s.get_at((0, 0))
(1, 2, 3, 255)
Also in the doc string: "The color name used is case insensitive and
whitespace is ignored."
pygame.color.Color("red")
(255, 0, 0, 255)
pygame.color.Color("Red")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: invalid color name
So case insensitivity in color names is gone as well.
Finally the add, multiply and subtract functions are missing from the pygame.color module. These are now operations on the new Color type. Yet existing game code would still use them. And the functions worked with any integer sequence type.
Lenard
claudio canepa wrote:
color incompatibility in pygame 1.8.1release versus 1.7.1release
>>> import pygame
>>> print pygame.version.ver
1.8.1release
>>> c=pygame.color.Color('#000000')
>>> print c
(0, 0, 0, 0)
>>>
>>> import pygame
>>> print pygame.version.ver
1.7.1release
>>> c = pygame.color.Color('#000000')
>>> print c
(0, 0, 0, 255)
>>>