How to insert diagrams

How to insert diagrams

Postby admin » Mon Aug 10, 2009 4:38 am

Shortly after upgrading to phpBB 3.05 I wrote a custom BBCode which now allows the insertion of diagrams into posts. The usage is very simple. On the posting page you will notice a "diagram" button; click the button and then paste the desired FEN string! The result will be a diagram like this one:



Similarly, I created a "solution" button: if the solution is inserted within the 'solution' tags, then it will be initially hidden from the reader, but just a click away when he decides to see it, saving some real estate on the page at the same time. Example below:

Solution: show
This is the solution!
Last edited by Cornel on Sun Aug 23, 2009 9:07 am, edited 3 times in total.
User avatar
admin
Site Admin
 
Posts: 15
Joined: Fri Apr 13, 2007 5:42 am
Location: Toronto, Canada

Re: How to insert diagrams

Postby Cornel » Wed Feb 17, 2010 7:46 am

The PHP script used here is based on the PHPdiag script written by Joost de Heer in 2002 (http://www.pairlist.net/pipermail/retro ... 00134.html). Several years ago I extended the script for personal use and added more features, many of them being available within this forum. In the near future, more capabilities will be added, together with improvements of the existing ones (i.e. letters and numbers). Below are brief descriptions and usage instructions.

1. CHESSBOARD SIZE

Any [m]*[n] rectangular shape is supported. There is just one restriction: all files must have the same number of squares. For example:

5x3: Input: 5/5/5

3x4: Input: 3/3/3/3


2. SPECIAL CHESSBOARDS

Special attributes of the chessboard are handled via parameters (a name/value pair appended to the FFEN string).
Parameter name: sb
Valid values: h, v, i, e, b, nc, r

2.1 Horizontal Cylinder (sb=h)
3x3 horizontal cylinder: Input: 3/3/3&sb=h


2.2 Vertical Cylinder (sb=v)
3x3 vertical cylinder: Input: 3/3/3&sb=v


2.3 Rotated Board (sb=i)
3x3 rotated board: Input: 3/3/3&sb=i


2.4 Empty Board (sb=e)
3x3 empty board: Input: 3/3/3&sb=e


2.5 Extra Border (sb=b)
3x3 extra border: Input: 3/3/3&sb=b


2.6 No Piece Count (sb=nc)
1x1 no piece count: Input: Q&sb=nc


2.7 Combinations

3x3 anchor ring: Input: 3/3/3&sb=hv


3x3 rotated, extra border, no piece count: Input: 3/3/3&sb=ibnc


3. PIECES

Both normal and fairy pieces are supported.

3.1 Normal Pieces
Normal chess pieces are specified by using the letters K (King), Q (Queen), R (Rook), B (Bishop), N (Knight) and P (Pawn) (lower case letters for black pieces and upper case letters for white pieces). For Knight, s and, respectively, S can also be used.
Input: pnbrqks/PNBRQKS


3.2 Neutral Pieces
A neutral pieces is specified by adding the prefix "-".
Input: -p-n-b-r-q-k/-P-N-B-R-Q-K


3.3 Imitator
Input: x/X&sb=nc


3.4 Other Fairy Pieces
Fairy pieces are entered by adding the prefix "*", followed by either 1, 2, or 3, to specify the rotation (90, 180 and 270 degrees CCW).
Input: *1p*2n*3b*1r*2q*3k/*3P*2N*1B-*3R-*2Q-*1K


4. COLORS

4.1 Special Squares (default color)
Any square on the board can be highlighted by using a special parameter.
Parameter name: ssq
Valid values: a FEN-like string, in which the square to be highlighted is indicated by using the letter "s".

Input: 3/3/3&ssq=1s1/2s/3


4.2 Special Squares - User defined color
The default color of the special squares can be replaced by any user defined color, using the 24-bit per pixel RGB color model representation, in which the RGB values are specified using three 8-bit unsigned integers (0 through 255) representing the intensities of Red, Green, and Blue.
Parameter name: ssc
Valid values: as per the convention known as full-range RGB, from (0,0,0) to (255,255,255)
Input: 3/3/3&ssq=1s1/2s/3&ssc=255,0,100


4.3 Dark Squares - User defined color
Similarly, the default color of the dark squares can be changed.
Parameter name: dsc
Valid values: as per the convention known as full-range RGB, from (0,0,0) to (255,255,255)
Input: 3/3/3&dsc=100,250,100


4.4 Light Squares - User defined color
Similarly, the default color of the light squares can be changed.
Parameter name: lsc
Valid values: as per the convention known as full-range RGB, from (0,0,0) to (255,255,255)
Input: 3/3/3&lsc=255,255,170


4.5 Combinations
For example:
Input: 3/3/3&dsc=255,255,170&lsc=255,255,170&ssq=3/1s1/3


5. GRIDS AND LINES

5.1 Standard Grid

Default Color
Parameter name: g
Valid values: s
Input: 8/8/8/8/8/8/8/8&g=s


User Defined Color
The default color of the grid lines can be changed via a dedicated parameter.
Parameter name: lc
Valid values: as per the convention known as full-range RGB, from (0,0,0) to (255,255,255)
Input: 8/8/8/8/8/8/8/8&g=s&ssc=255,0,100


5.2 Irregular Grids
Irregular grids can be specified by using a special parameter.
Parameter name: gl
Valid values: Pairs of Cartesian coordinates, separated by "/"
Let the chessboard be a plane, with the origin (the point where abscissa (the x-coordinate) and ordinate (the y-coordinate) met) at the upper-left corner. In this plane, each point is defined by two projections, one on to the x-axis and one on to the y-axis, and is written as an ordered pair of real numbers: x, y. A grid line is thus written as two pairs of real numbers: x1,y1,x2,y2.
Input: 8/8/8/8/8/8/8/8&gl=4,0,4,8/0,3,8,3


5.3. Lines
Examples:
Input: 3/3/3&gl=1,1,2,1/1,2,2,2/1,1,1,2/2,1,2,2


Input: 3/3/3&gl=1,1,2,1/1,2,2,2/1,1,1,2/2,1,2,2/1,1,2,2/2,1,1,2


Input: 3/3/3&gl=1,1,2,1/1,2,2,2/1,1,1,2/2,1,2,2/1.25,1,1.25,2/1.5,1,1.5,2/1.75,1,1.75,2


Input: 1R1/R2/3&gl=1.5,0.4,0.5,1.4/1.5,0.6,0.5,1.6&lc=0,0,0


5.4 Brush Size
The default width of all lines is two pixels. This can be modified via another special parameter.
Parameter name: bt
Valid values: Integers
Input: 3/3/3&gl=1,1,2,1/1,2,2,2/1,1,1,2/2,1,2,2&bt=5


6. LETTERS AND NUMBERS
In the current version, letters and numbers can also be entered by using the "sb" parameter and a FEN-like string. Only letters and numbers can be displayed on the chessboard - the combination of letters, numbers and chess pieces will be possible in the next version of the script.
Parameter name: sb
Valid values: r

6.1 Letters
Input: abc1/1def/ghi1/1jkl&sb=ncbr


The letters can also be rotated, by adding the prefix "*", followed by either 1, 2, or 3, to specify the rotation (90, 180 and 270 degrees CCW).
Input: 1a1/*1a1*3a/1*2a1&sb=ncbre


6.2 Numbers
Numbers are entered by adding the prefix "!"
Input: 8/8/3!14/2!2!3!45/1!0!9!8!7!52/8/8/8&sb=ncbre


The numbers can also be rotated, by adding the prefix "*", followed by either 1, 2, or 3, to specify the rotation (90, 180 and 270 degrees CCW).
Input: 1!21/!*121!*32/1!*221&sb=ncbre
Cornel
User avatar
Cornel
Site Admin
 
Posts: 758
Joined: Mon Aug 10, 2009 5:10 am
Location: Toronto, Canada


Return to Board Announcements

Who is online

Users browsing this forum: No registered users and 1 guest

cron