グリッド形状 | ||
横 | ||
縦 | ||
辺長 | ||
ヘックス方向 | 横 | 縦 |
ソースからGridMaker.jsをコピーし、ヘックスシートを表示したいHTMLで読み込んでください。
次に次のようにcanvasを記述してください。動的に書き換える必要がなければタグを記述するだけで描画されます。
<canvas class="HexGrid" width=640px height=480px data-stroke=25 [data-vertical]>
class:HexSheetを指定します。
width:canvasの幅を指定します。
height:canvasの高さを指定します。
data-stroke:ヘックスの1辺の長さ(ピクセル)を指定します。
data-vertical:記述した場合、縦方向のヘックスを描画します。
(例:<canvas class="HexGrid" width=300px height=200px data-stroke=15 data-vertical>)
スクェアシートの場合はdata-verticalの指定がありません。
(例:<canvas class="SquareGrid" width=300px height=200px data-stroke=30;)
<div id="HexArea" style="width:300px; height:200px;"> <canvas id="HexGridIcon" class="HexGrid" width=300px height=200px data-stroke=25 data-vertical></canvas> </div> <script type="text/javascript"> HexSheet.calcBasePosition(25, 40, 32, "vertical"); HexSheet.drawCharacter(1, 1, "reimu", "200.png", "HexArea", "vertical"); </script>
<div id="SquareArea" style="width:300px; height:200px;"> <canvas id="SquareGridIcon" class="SquareGrid GridAndIcon" width=300px height=200px data-stroke=30></canvas> </div> <script type="text/javascript"> SquareSheet.calcBasePosition(30, 40, 32); SquareSheet.drawCharacter(1, 1, "reimu", "200.png", "SquareArea"); </script>