diff options
author | tomsmeding <tom.smeding@gmail.com> | 2018-02-22 21:04:04 +0100 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2018-02-22 21:04:04 +0100 |
commit | 24b57ecbe4e5d9e9d9b01ad6399c18625d8d03b6 (patch) | |
tree | 225f2a43d23f21db4a8af707fe6d1001cd866cde | |
parent | b1b3cf82c0d0ccd6429145334c964e336858274a (diff) |
-rw-r--r-- | index.html | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -120,6 +120,9 @@ function boardY(idx){ return (~~(idx/currentGame.size)+0.5)*CELL_WID; } +var _redrawBoard_cache_board=null; +var _redrawBoard_cache_canvas=null; + function redrawBoard(){ if(currentGame==null){ interfaceSwitch("connect"); @@ -127,6 +130,12 @@ function redrawBoard(){ } var G=currentGame; + var GboardJSON=JSON.stringify(G.board); + + if(_redrawBoard_cache_board&&GboardJSON==_redrawBoard_cache_board){ + ctx.putImageData(_redrawBoard_cache_canvas,0,0); + return; + } var bsz=G.size*CELL_WID; if(cvs.width!=bsz||cvs.height!=bsz){cvs.width=bsz; cvs.height=bsz;} @@ -164,6 +173,9 @@ function redrawBoard(){ ctx.arc(boardX(i),boardY(i),STONE_SIZE,0,2*Math.PI,true); ctx.fill(); } + + _redrawBoard_cache_board=GboardJSON; + _redrawBoard_cache_canvas=ctx.getImageData(0,0,cvs.width,cvs.height); } function interfaceGameState(state){ |