How do I use RGB in Python?
The first step in using RGB in Python is importing the library you’ll need for it. You’ll want to import the pygame library and then import the pygame.rgb sub-library from that. Now that you have it imported, you can start making things happen! The first thing to know about RGB is that, in Python, it’s represented by a tuple of three integers. The first value represents the red light, the second value represents green light, and the third represents blue light. So if you want your color to be all red, you would write:
(rgb(255, 0, 0))
If you want a yellow color with some red and some green in it:
(rgb(255, 255, 0))
If you want a purple with some red and blue in it:
(rgb(128, 0, 128))