Created
December 24, 2018 00:24
-
-
Save sumedhe/05b8fe16dab359819df796d4a426a68d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| (function(){ | |
| var canvas = document.getElementById('rectmap'); | |
| var recSize = 10; | |
| gap = 1; | |
| boardWidth = 100, | |
| boardHeight = 100; | |
| if (canvas.getContext){ | |
| var ctx = canvas.getContext('2d'); | |
| drawBoard(ctx, boardWidth, boardHeight, recSize); | |
| } | |
| // Draw board | |
| function drawBoard(canvasContext, width, height, recSize) { | |
| var i, j; | |
| for(i = 0; i < width; ++i) { | |
| for(j = 0; j < height; ++j) { | |
| drawHexagon( | |
| ctx, | |
| i * (recSize + gap), | |
| j * (recSize + gap), | |
| recSize, | |
| "red" | |
| ); | |
| } | |
| } | |
| } | |
| // Draw Hexagon | |
| function drawHexagon(canvasContext, x, y, recSize, color) { | |
| canvasContext.fillStyle = color; | |
| canvasContext.fillRect(x, y, recSize, recSize); | |
| } | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment