On Nov 30, 8:04 pm, John Machin <[EMAIL PROTECTED]> wrote:
> On Nov 30, 4:39 pm, ZelluX <[EMAIL PROTECTED]> wrote:
>
> > Convert RGB colors to the closest ANSI colors. For example, given RGB
> > color FF0000, it should print [31m.
>
> Maybe ... but you could write it yourself quickly enough; the code is
> a trivial loop over a list of the RGB values of the 8 possible
> colours, and would fit easily on a 24x80 terminal :-) Why don't you
> have a try at it and come back if you have any problems?
>

Ummm actually once you have got your rgb value as an integer (or a
tuple of 3 integers) -- in the example, 0xff0000 or (0xff, 0, 0) --
the answer can be obtained in one line with operations no more
complicated than shifting, masking, and addition.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to