text
stringlengths
0
3.52k
A block of Python code is set out as shown here:
Preface xi
Note that keywords are shown in bold font.
In some cases something of particular interest may be highlighted with colour:
Any command line or user input is shown in italics and coloured purple; for example:
Or
Example Code and Sample Solutions
The examples used in this book (along with sample solutions for the exercises at the end of most chapters) are available in a GitHub repository. GitHub provides a web interface to Git, as well as a server environment hosting Git.
Git is a version control system typically used to manage source code 铿乴es (such as those used to create systems in programming languages such as Python but also Java, C#, C++, Scala etc.). Systems such as Git are very useful for collaborative development as they allow multiple people to work on an implementation and to merge their work together. They also provide a useful historical view of the code (which also allows developers to roll back changes if modi铿乧ations prove to be unsuitable).
If you already have Git installed on your computer then you can clone (obtain a copy of) the repository locally using:
xii Preface
If you do not have Git then you can obtain a zip 铿乴e of the examples using
You can of course install Git yourself if you wish. To do this see https://git-scm. com/downloads. Versions of the Git client for Mac OS, Windows and Linux/Unix are available here.
However, many IDEs such as PyCharm come with Git support and so offer another approach to obtaining a Git repository.
For more information on Git see http://git-scm.com/doc. This Git guide provides a very good primer and is highly recommended.
Acknowledgements I would like to thank Phoebe Hunt for creating the pixel images used for the StarshipMeteors game in Chap. 8.
Contents
Introduction 1
Introduction 1
Part I Computer Graphics
Introduction to Computer Graphics 5
Introduction 5
Background 6
The Graphical Computer Era 6
Interactive and Non Interactive Graphics 7
Pixels 8
Bit Map Versus Vector Graphics 10
Buffering 10
Python and Computer Graphics 10
References 11
Online Resources 11
Python Turtle Graphics 13
Introduction 13
The Turtle Graphics Library 13
The Turtle Module 13
Basic Turtle Graphics 14
Drawing Shapes 17
Filling Shapes 19
Other Graphics Libraries 19
3D Graphics 20
PyOpenGL 20
Online Resources 21
Exercises 21
xiii
xiv Contents
Part III Testing
xviii Contents
Working with PyTest 179
Parameterised Tests 183
Online Resources 185
Exercises 185
Mocking for Testing 187
Introduction 187