Raspberry_Pi_Education_Manual

Notes:

You should now have a display on the screen, which has a surface of 500 x 500 tiny dots, or “ pixels ”. That’s a grand total of 250,000 pixels. Let’s change all 250,000 pixels to a deep blue colour using that “deepblue” tuple we created.

Tip...

>>> surface.fill(deepblue)

Pixel is the short form of

You have filled the surface with the blue colour, but nothing will happen on screen. The computer does not know you have finished drawing things to the surface, so it doesn’t do anything just yet. Let’s tell PyGame that it can update the display with this command:

“picture element”. In programming, a pixel can be set to any colour you like, and your “screen” is made up of many rows and columns of them, packed so close together that they blur into one another

>>> pygame.display.update ()

Update your screen to make the deep blue fill you created appear.

and look like a single picture.

You’ll now have a blue surface in your displayed window. So, that was either fun, okay or really dull. Let’s hope it was at least okay.

How about using the other colour? Type:

>>> surface.fill(mintcream) >>> pygame.display.update ()

Hey... that’s rather plain.

Update your screen again to make the your mint cream fill appear.

Experiments in Python

75

Made with FlippingBook flipbook maker