Color input is inconsistent

Issue #45 open
René Dudfield created an issue

== John, 2010-05-09 21:11:41 -0700

{{{ I'm using Pygame 1.9 with Python 3.1. The inconsistency with color input is slightly irritating. For example, Pygame.Color() accepts a variety of different input types. It accepts HTML style colors, tuples of integers, and hexadecimals. This is nice, but other parts of Pygame code don't use this. For example, Surface.fill() only accepts a tuple or a Color instance. I can't use the hexadecimal styles. I myself often make the mistake of using the wrong style of color and need to look up the documentation. I think consistency is extremely important for any software, especially a library for an elegant language like Python. }}}

Comments (4)

  1. René Dudfield reporter

    Marking as an enhancement proposal.

    It would be nice to be able to do things like this:


    I've often wanted this feature myself, and others have suggested it before.

    This needs some thought, and a lot of testing to see what side effects this could have. Also, we need to decide on scheduling if this is a much wanted feature or not, and how much work it would take to implement/test.

  2. Lenard Lindstrom

    This request would take significant refactoring, particularly in pygame.base and pygame.color and pygame.pixelarray. The simplest approach is to add '<name>' and '#<hex>' handling to _RGBAFromColorObj. Then anything in Pygame that accepts a color value would also take a string. It would also mean

    pixel_array[...] = 'black'

    would be allowed. I recall some objection to that, but if it is not a problem I can tackle this issue.


  3. Log in to comment