Port colorfilters2js.pl to Python. Slight differences in output code formatting, but is otherwise consistent. Ping #18152