@@ -34,6 +34,7 @@ const stubSvg = fs.readFileSync('stubs/stub.svg', { encoding: 'utf-8' })
34
34
35
35
const renderSVG = ( board , {
36
36
marks = [ ] ,
37
+ scale,
37
38
arrows = [ ] ,
38
39
bgColor,
39
40
marksSize,
@@ -59,14 +60,14 @@ const renderSVG = (board, {
59
60
svgElements . push ( makeSquare ( { x, y, squareSize, squareId, color } ) )
60
61
61
62
if ( piece ) {
62
- svgElements . push ( makePiece ( { x, y, piece } ) )
63
+ svgElements . push ( makePiece ( { x, y, piece, scale } ) )
63
64
}
64
65
65
66
if ( marks . includes ( squareId ) ) {
66
67
svgElements . push (
67
68
piece
68
- ? makeCross ( { x, y, crossColor } )
69
- : makeDot ( { x, y, squareSize, marksSize, marksColor } ) ,
69
+ ? makeCross ( { x, y, crossColor, scale } )
70
+ : makeDot ( { x, y, squareSize, marksSize, marksColor, scale } ) ,
70
71
)
71
72
}
72
73
}
@@ -101,6 +102,7 @@ const renderSVG = (board, {
101
102
}
102
103
103
104
return stubSvg
105
+ . split ( '{{fullWidth}}' ) . join ( squareSize * 8 + boardPadding * 2 )
104
106
. split ( '{{bg}}' ) . join ( bgColor )
105
107
. split ( '{{board}}' ) . join ( svgElements . join ( '' ) )
106
108
}
@@ -116,22 +118,22 @@ app.get('/:fen.jpeg', (req, res) => {
116
118
text_color : textColor = TEXT_COLOR ,
117
119
cross_color : crossColor = CROSS_COLOR ,
118
120
marks_color : marksColor = MARKS_COLOR ,
119
- square_size : squareSize = SQUARE_SIZE ,
120
121
b_cell_color : bCellColor = B_CELL_COLOR ,
121
122
w_cell_color : wCellColor = W_CELL_COLOR ,
122
- board_padding : boardPadding = BOARD_PADDING ,
123
123
} = req . query
124
124
const { fen = 'rnbkqbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBKQBNR' } = req . params
125
125
126
+ const boardPadding = boardSize / 26
127
+ const squareSize = boardPadding * 3
128
+ const scale = boardSize / 390
126
129
const marks = marksList . split ( ',' )
127
130
const whiteBottom = ! ! Number ( rotate )
128
131
129
132
res . contentType ( 'image/jpeg' )
130
133
131
- console . log ( fen )
132
-
133
134
const svg = renderSVG ( Board . load ( fen ) , {
134
135
marks,
136
+ scale,
135
137
arrows,
136
138
bgColor,
137
139
marksSize,
@@ -152,6 +154,7 @@ app.get('/:fen.jpeg', (req, res) => {
152
154
153
155
loadSVGFromString ( svg , ( objects , info ) => {
154
156
const ctx = canvas . getContext ( '2d' )
157
+ console . log ( info )
155
158
const scaleX = info . width ? ( boardSize / info . width ) : 1
156
159
const scaleY = info . height ? ( boardSize / info . height ) : 1
157
160
0 commit comments