Created
January 8, 2019 01:31
-
-
Save mohsenheydari/56bf9322958f38993ccf5c8b31d0206f to your computer and use it in GitHub Desktop.
Draw Tic Tac Toe grid lines
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
drawGrid(){ | |
let offset = 5; | |
let lineLenght = this.canvas.width - offset; | |
this.ctx.lineWidth = this.gridLineWidth; | |
this.ctx.lineCap = 'round'; | |
this.ctx.strokeStyle = this.gridLineStyle; | |
this.ctx.beginPath(); | |
//Horizontal lines | |
for (let y = 1;y <= 2;y++) { | |
this.ctx.moveTo(offset, y * this.cellSize); | |
this.ctx.lineTo(lineLenght, y * this.cellSize); | |
} | |
//Vertical lines | |
for (let x = 1;x <= 2;x++) { | |
this.ctx.moveTo(x * this.cellSize, offset); | |
this.ctx.lineTo(x * this.cellSize, lineLenght); | |
} | |
this.ctx.stroke(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment