Check out Grant Acedrex, our featured variant for April, 2024.

Query String Parameters for showpiece.php

This is a PHP script for displaying individual piece images with some modifications, such as padding, resizing, or recoloring. You tell it what to display by means of query string parameters. If you are reading this help text, then you did not provide the proper paramters for displaying an image.

Parameters for Indicating the Source Image

A source image may be indicated by indicating a relative path on the website with a file name.

image
The relative path and file name of an image.

An image may also be indicated by means of a Game Courier set. This is useful when corresponding images in different sets have different file names, and you want to provide the choice of different piece sets in an Interactive Diagram. Game Courier itself, already having access to its sets, does not need to use these parameters.

set
Names the Game Courier set to use, which will normally be the basename of the PHP file the set is defined in.
piece
Names the label used in the set for the piece to display. Since Interactive Diagrams do not natively support Game Courier sets, it will do some conversions on this value if you provide it for an Interactive Diagram. If its value does not match any piece label, it will inspect it for a prefixed w, W, b, or B, then cut that off, cut off any extension, and make it all uppercase for w or W or all lowercase for b or B.
flip
Optional Boolean flag to indicate whether to get filenames for pieces from the $flipped array instead of the $pieces array in a set file. Defaults to false.

Parameters for padding, cropping or resizing

size
How wide and tall (in pixels) that the output image should be. For a GIF or PNG with a dimension smaller than size, it will be padded to the specified size. This will add extra space around the piece image without enlarging it. Game Courier uses this for the Square CSS display method, because the way it handles resizing requires the pieces to all have uniform dimensions. For an SVG, it will rescale it to a PNG of the specified size. If left unset, the piece will not change in size, and an SVG will remain an SVG.
optimize
A Boolean to indicate whether to crop off the non-visible part of an image.

Parameters for Recoloring

To recolor a piece, it needs to know two colors.

originalcolor
The color that the piece is already colored.
color
The color to replace the original color with.

In some cases, such as with the Interactive Diagram, the query string may need to be prepared before it's known which side the piece belongs to. In that case, these parameters may be used instead of the ones mentioned above to designate colors for the pieces on each side.

originalblack
The color that the Black pieces are already colored.
originalwhite
The color that the White pieces are already colored.
black
The color to replace the original color of the Black pieces with.
white
The color to replace the original color of the White pieces with.