PySoy: Color Names Dict
completed by: Nikolay Lazarov
mentors: Amaury Medeiros, Arc Riley, Tony Young, David Czech, Mayank Singh
Color objects can be created using standard web color names (and a few more) from Genie dictionaries embedded in libsoy's source code. If you know the name of a color you want you can use it like this:
>>> import soy >>> soy.atoms.Color('firebrick').hex '#b22222ff'
There is currently no way to get a list of supported colors nor add new colors a game developer may want to use repeatedly. This problem can be solved by exposing the internal dict used to store these colors to Python.
Write a new PySoy class
soy._GeeMap which implements the
Python Mapping Protocol
such that it acts similar to a Python Dict. Keys for this should always be
strings, Python value type should be passable with a constructor argument and
must be a subclass of
soy._G (ie, a PySoy Type).
There are examples of this already including
though this will be more generic for re-use. Mentor will provide a good deal
of guidance on this. A good deal of this new class can and should be copied
from existing working code.
Once done, add a
Color.names read-only property which returns
an instance of
soy._GeeMap wrapping the color name dict. This dict
should then be usable to add, remove, and modify colors in it.
While working on this task you should join and remain in #PySoy on Freenode to get help, feedback, and guidance from mentors and other developers. Code updates which may affect your work are also announced here as they happen.
As you complete each piece of this task (the code compiles),
commit your work and post
the resulting changeset url to this task. Remember to
hg pull -u
often and before every commit to minimize change conflicts.