This example use Unicode chess characters. Look the print screen, at the background of these characters on the board. Normaly the color inside are the same as the font, because only the line of font drawing. So to have white inside pawns, we have to print the characters in white background using a non antialliasing printing (so we get black pixels for black colored characters), and we have to use flood fil in a pixel outside the chess character to fill the square with desired color.
for each board we feed a Forsyth–Edwards Notation (FEN) a string which define a board position.
Just copy this and paste to a module a empty code block.
for each board we feed a Forsyth–Edwards Notation (FEN) a string which define a board position.
Just copy this and paste to a module a empty code block.
Font "Arial Unicode MS"
if not Fontname$="Arial Unicode MS" then
font "DejaVu Sans"
End if
ChColor$=fontname$
Font "Verdana" : Cls 15 : Pen 0 : Form 40,32 : Gradient 3,5
Def White$="PNBRQK", Black$="pnbrqk", WhiteDisp$="♙♘♗♖♕♔"
Def BlackDisp$="♟♞♝♜♛♚", empty$="12345678"
Dim emptydisp$(1 to 8)
For i=1 to 8 :emptydisp$(i)=string$(" ",i):Next
Def board$, status$, oldI
Dim line$()
Double
OldI=Italic
Italic 1
Pen 14 {
Report 2, "Chess Board Example"
}
Italic OldI
Normal
SetBoard("rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR w KQkq c6 0 2")
DrawBoard(1000, 2000, 600, 15)
SetBoard("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1")
DrawBoard(11500, 2000, 300, 15)
SetBoard("rnbqkbnr/pp1ppppp/2p5/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1")
DrawBoard(11500, 8000, 180, 15)
// wait for key
Push Key$
Drop
Cls
End
Sub DrawBoard(leftmargin, topmargin, squarewidth, labelcolor)
Refresh 10000
local boolean a=true, z=bold : bold 0
Local l=squarewidth, k=2*l, k1=k*.85, N1=6, N=6, M=4, B=k*8, B1
Local d=0
Repeat
N=N1
N1+=.25
Until K1<size.Y("A", "Arial", N1)
topmargin-=l
leftmargin-=l
move leftmargin+l,topmargin+l
B1=(l div 300)*twipsX
step -B1,-B1
B+=B1*2
Width b1 div 2+1 {
color #666688 , 1{
Polygon 0, B, 0, 0, B, -B, 0, 0, -B
}
}
M=N*.65
For i=1 to 9
d=leftmargin
move d, topmargin
if i<9 then
step 0, k
Pen labelcolor{Legend str$(9-i,""), "Arial", M,0,2}
step 0, -k
else
N=M
End if
For j=1 to 8
If i<9 then
step l, l
color #666688,1 {
fill k,k, 15
}
step -l, -l
\\ Last parameter is 0 For no antialliasing
Legend mid$(line$(i),j,1), chColor$, N, 0, 2,0
step l-twipsX*2, l-twipsX*2
if not a then floodfill ,,#666688 else floodfill , , #ccddff
a~
else
step k, k
pen labelcolor {
Legend mid$(line$(i),j,1), chColor$, N, 0, 2
}
End If
d+=k
move d, topmargin
Next
a~ : topmargin+=k
Next
bold z
Refresh 60
End Sub
Sub SetBoard(chessboard$)
board$=leftpart$(chessboard$," ")
status$=rightpart$(chessboard$," ")
nl$={
}
For i=1 to 6
board$=replace$(mid$(White$,i,1),mid$(WhiteDisp$,i,1), board$)
board$=replace$(mid$(Black$,i,1),mid$(BlackDisp$,i,1), board$)
Next
For j=1 to 8
board$=replace$(str$(j,""),emptydisp$(j), board$)
Next
line$()=piece$(board$,"/")
Dim line$(1 to 9)
line$(9)="abcdefgh"
End SubΚαι εδώ η εικόνα (Windows 10 Pro)
Δεν υπάρχουν σχόλια:
Δημοσίευση σχολίου
You can feel free to write any suggestion, or idea on the subject.