Tangram and other Dissection Puzzles


Clicking on the icon will pop up a frame for the Tangram puzzle. According to Wikipedia, Tangram is a dissection puzzle consisting of seven pieces which fit together to form a shape of some sort. This program implements Tangram and other dissection puzzles.

Browsers are not friendly to Java. If your browser refuses to execute the program, you can execute it with a command similar to the following:

javaws http://web.cecs.pdx.edu/~antoy/private/tangram-dir/tangram.jnlp

You may also have to include the server web.cecs.pdx.edu in the exception site list of the Java control panel. This program is signed, self-certified and sandboxed.

This document takes some liberty with the terminology. Each piece of Tangram is called a tan and a configuration of pieces is called a tangram (lower case). In this document, the words "tan" and "tangram" denote a piece and a configuration of a dissecting puzzle of the program whether or not the puzzle is Tangram.


The graphical interface contains 3 main areas: the menu (top of the interface, Fig. 1), the Control (left, Fig. 2) and the Playboard (right, Fig. 3).

Figure 1. The menu.

Figure 2. The Control.

Figure 3. The Playboard.

[goal view]
Figure 4. The goal view.

The Control contains 4 buttons and a small black area with a white shape centered inside. The black area is the goal view and the white shape inside it is a tangram referred to as the current goal. The buttons select the current goal and some options about it.

The colored polygons in the Playboard are the tans. The tans can be dragged, rotated and flipped with the mouse. The purpose of a game is to arrange the tans in a shape similar to the tangram shown by the current goal.


Changing the Tangram

There is a small database of tangrams for any puzzle. Two buttons, Prev Goal and Next Goal, move the current goal through the database.

Solving the current goal

The Easy button of the Control produces a representation of the current goal, at natural size, on the Playboard. In contrast to the tans on the Playboard, this representation of the tangram cannot be moved.

The button labeled Solve shows the solution of the game in the current goal.

Managing the tangram database

Tangrams can be added to and deleted from the database. To delete the current goal choose the delete item in the Goals menu entry. The "initial" tangram of a set cannot be deleted.

To add a new tangram, place the tans in the desired configuration and choose the add item in the Goals menu entry. The newly added tangram is placed after the current goal and it becomes the new current goal.

Every configuration of tans can be made into a tangram. But configurations with overlapping tans should be avoided. The Easy option does not handle these configurations correctly.

The database of tangrams may be permanently saved to disk. This feature is affected by how the program is started and by the permission to write on the local disk. To save the database choose the save item in the Goals menu entry. The choice may be disabled or fail depending on the above conditions.

Manipulating the tans

The tans can partially or totally overlap. Any mouse click on a tan brings it to the top.

The mouse enables the following actions. See the "Using keyboard keys" section below for some alternatives to mouse actions.

Mouse action Tan behavior
left down bring to top
any drag move
right click rotate counterclockwise
middle click rotate clockwise
left double click flip
A rotation is always by 45 degrees.

The corners of the tans attract each other when they are in proximity. This feature eases the placement of tans. This feature may preclude some small movements that would put two corners a few pixels apart.


The menu affects global actions and setting of the program.

Several sets of tans may be available in the program. A set of tans can be selected with the Open item in the File menu entry.

The program default settings, except for the configuration of the tans, can be restored with the Default item in the File menu entry.

The Easy option is local to the current tangram. The menu allows setting this option permanently with the Always easy item in the Options menu entry.

An audible sound can be produced when the corners of two tans touch, i.e., the tans fall in place. By default, the sound is disabled. It can be enabled by toggling the Quiet item in the Options menu entry.

The Goals menu entry supports the manipulations of tangrams as discussed earlier.

The Help menu entry provides information about the program.

Using keyboard keys

Some frequent menu and mouse actions can be obtained with keyboard keys. Menu entries and button labels display the key for obtaining the corresponding action.

In particular, the tans can be moved using only the left button. When the left button is down on a Tan, the keys enable the following actions.

Key Tan behavior
R rotate counterclockwise
T rotate clockwise
F flip

The case, i.e., upper vs. lower, of a key is irrelevant.

New Puzzles

A Puzzle is a set of tans and its database of tangrams. It is possible to add new puzzles without changing and recompiling the program. Adding a puzzle entails creating a text file with extensions xml and placing it in the directory res/xml. This directory contains several puzzle files. The definition of a puzzle file is not yet documented, but the content and format, which can be inspected with a text editor, are relatively self-explanatory.

TODO, bugs

Diplaying tangrams

It takes a considerably long time to display some tangrams in the goal view. Probably the time goes into scaling the image 4:1. Maybe there is a better way to achieve the effect.

Adding tangrams

Tangrams with overlapping tans should be detected and rejected, since the easy silouette is incorrectly computed for these tangrams.


Philippe Moutou contributed the machine executable definition, in the form of an XML document, of many puzzles and suggested several improvements to an earlier version of this program. Harold Fuchs (London, England) helped with the terminology.

Copyright © 1996-2017 by S. Antoy.
Version 0.86 of 7/23/2008.