jfrech.com
jblog
table of contents

Colored Rectangles

2016-01-30, post № 102

programming, Pygame, Python, #color, #mouse, #mouse controlled, #polygons, #rect, #rectangle, #rects

This program lets you spawn in a rectangle with a randomly assigned color. This rectangle will then slowly move towards the screen’s edge, eventually fading away.

Controls

  • Left click spawns in a new rectangle at current mouse position,
  • ‘Space’ takes a screenshot.
colored-rectangles-1.png
colored-rectangles-2.png
colored-rectangles-4.png
Source code: colored-rectangles.py