Programming Visual Illusions for Everyone

This is the companion website to:

Programming Visual Illusions for Everyone


by Marco Bertamini

Hello. If you find visual illusions fascinating Programming Visual Illusions for Everyone is a book for you. I provide some background, some history and some theories about visual illusions, and I discuss in some detail twelve of my favourite illusions. Some are about surfaces, some are about apparent size of objects, some are about colour and some involve movement. But this is only one of the aims of the book. The other aim is to show you how you can create these effects on any computer.

The book includes a brief introduction to a powerful programming language called Python. No previous experience with programming is necessary. I starts from the basic concepts. I also introduce a package called PsychoPy that makes it easy to draw on a computer screen. It is perfectly ok if you have never heard the names Python or PsychoPy before. Python is a modern and easy-to-read language, and PsychoPy takes care of all the graphical aspects of drawing on a screen and also interacting with a computer. By the way, both Python and PsychoPy are absolutely free.

The first Chapter is about Illusions. The second Chapter is about Python. I have used Python as a tool extensively but I am not a professional programmer. This book does not contain a full tutorial, but it provides enough information to start. It is a bit like one of those phrase books for when you go to a foreign country and you want to be able to say at least "I would like an ice cream please". The refined ice-cream with fresh local ingredients, just like the illusions in this book, can be quite an experience.

The third Chapter explains how to open a window, set up the coordinates of a space in which to draw, and show on the screen simple shapes. We learn to create these objects and what properties they have. This approach is powerful if you want to control the images on the screen, change them in various ways, and it also allows the user to interact with the program for instance using the mouse.

Chapter four describes a program to draw a Kanizsa square (an illusory surface). After that we see several more illusions. Many key references for these illusions are provided in a list of references at the back (if you would like to read more and delve into the science).

Is this a book about illusions or about programming? It is both!