カテゴリー:
strokeStyleプロパティ
閲覧数:399 配信日:2015-11-21 09:19
遭遇例
▼index.html
<canvas id="canv" width="500px" height="500px"></canvas>
<script>var ctx = document.getElementById("canv").getContext('2d');</script>
▼render.js
var COLOR_LINE = "#FFFFFF";
ctx.strokeStyle = COLOR_LINE;
確認例
#0000CD色で線を引く
▼index.html
<canvas id="canv" width="500px" height="500px"></canvas>
<script>
var COL = 8;
var RECT_CANV = {
x: 0,
y: 0,
w: 500,
h: 500
};
var CELL_SIZE = RECT_CANV.w / COL | 0;
var COLOR_LINE = "#0000CD";
var ctx = document.getElementById("canv").getContext('2d');
for (var x = 0; x < COL; x++) {
for (var y = 0; y < COL; y++) {
ctx.strokeStyle = COLOR_LINE;
ctx.strokeRect(x * CELL_SIZE, y * CELL_SIZE, CELL_SIZE, CELL_SIZE);
}
}
</script>