ChessMap – A New JavaScript Project

Code I’d originally written in PostScript would parse a text file containing all the moves of a chess game, and print out pages that looked like this:

These are the four Postscript files and 16 functions which I will now attempt to rewrite in Javascript:


ChessPage.ps

  • Main
    • CreateGameArray
    • CreateBoardArray
    • ShowPage
    • DrawBoard
    • ChangeBoard

ReadGame.ps

  • CreateGameArray
    • ParseTextLine
      • ParseMove
        • XtractCoords
          • LastTwo
  • CreatBoardArray
    • ParseLine
      • ParseMoveX

DrawBoard.ps

  • DrawBoard
  • DrawMove
    • DrawPiece

HexCode.ps

Bezier Miter Join

When line segments join at sharp angles “spikes” are produced. This test image shows at which range they are cut off.

miterjoin

%!PS BezierMiterJoin.ps
2 2 scale
20 20 translate
/a 10 def
0 20 280 {
    /x exch def
    0 0 moveto
    x 300 lineto
    100 200 200 100 300 0 curveto
    } for
10 setlinewidth
strokepath
0 setlinewidth
stroke showpage

Cascade

# CASCADE
#set whatever "•[-{wordset} 0-9]*∂t"
set whatever "•[-{wordset}., ''&]*∂t" #NEED THE TAB?

find /{whatever}/
set theString "`catenate §`"

loop
    find /{whatever}/
    if "`catenate §`" == "∂t"
        replace § "{theString}"
    else
        set theString "`catenate §`"
        replace § "*"
        end
    if "{theString}" == ""
        break
        end
    end
Create your own website, free on WordPress.com.Create your own website.
Start free