PycturesPython 2D and 3D graphics, drawn in your web browser

Every scene below is a short Python program. Click one and it runs live in your browser, with its code beside it. Python gets the web's 2D canvas and three.js 3D, with the names JavaScript uses.

pip install pycturesStar on GitHubDocs
Solar System

Solar System3D

Planets in turning groups, a moon, a light at the sun and 2,000 stars.

Star Catcher

Star Catcher2D

A 2D game with emoji sprites, a score and lives.

Space Rocks

Space Rocks2D

Steer a ship and shoot the rocks, which break in two.

Brick Breaker

Brick Breaker2D

A bat, a ball and a wall of bricks.

Bat and Ball

Bat and Ball2D

One player against the computer. First to 5 wins.

Snake

Snake2D

A game on a grid: eat the apples and grow. Your best score is kept.

High Score

High Score2D

Catch the star as often as you can in 10 seconds. The best score is still there next time: save() and load().

Top Scores

Top Scores2D

Every game is written into a database, and the best five are shown: open_database().

Cube Spiral

Cube Spiral3D

400 cubes in a rainbow spiral, turning.

Cube Dodge

Cube Dodge3D

A 3D game with shadows, fog and the keyboard.

Bouncing Balls

Bouncing Balls2D

A 2D animation with trails and hsl() colours.

Textured Cube

Textured Cube3D

A picture from a file, wrapped round a turning crate.

Torus Knot

Torus Knot3D

One shape, lit, turning.

Live Chart

Live Chart2D

A line chart of a made-up sensor, updating as you watch.

Wave Grid

Wave Grid3D

225 cubes rising and falling like water.

Starfield

Starfield2D

Fly through 300 stars.

Lit Scene

Lit Scene3D

Shapes on a floor, with a spotlight and shadows.

Spiral Garden

Spiral Garden2D

200 dots placed on the golden angle, turning slowly.

From JavaScript: 3D

From JavaScript: 3D3D

The classic three.js spinning cube, line for line in Python.

From JavaScript: 2D

From JavaScript: 2D2D

A canvas example written the way JavaScript writes it.

Typing

Typing2D

Type and your words appear, with a box drawn to fit them.

Night Sky

Night Sky2D

A whole picture from the plain drawing functions: stars, a moon, a hill and a house.

Hello

Hello2D

The smallest scene: a background and one circle.

Moving

Moving2D

A circle crossing the picture: update(dt) and one number.

Follow

Follow2D

A circle you move.

First Game

First Game2D

Catch the falling stars in the basket: sprites, touches() and a score.

Ring

Ring2D

Twelve circles in a ring.