-
Notifications
You must be signed in to change notification settings - Fork 0
/
frame3.html
62 lines (53 loc) · 1.35 KB
/
frame3.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>viewport size example</title>
<style>
</style>
<script type="text/javascript">
/* ==================== SCRIPTS ==================== */
window.onload = function() {
draw();
}
function draw() {
var canvas = document.getElementById('canvassample');
if ( ! canvas || ! canvas.getContext ) {
return false;
}
var ctx = canvas.getContext('2d');
for (x = 0; x <= canvas.width; x+=20) {
for (y = 0; y <= canvas.height; y+=20) {
if (x % 100 === 0 || y % 100 === 0) {
ctx.save();
ctx.fillStyle = 'red';
ctx.fillRect(x,y,5,5);
ctx.restore();
} else {
ctx.save();
ctx.fillStyle = 'lightgreen';
ctx.fillRect(x,y,5,5);
ctx.restore();
}
}
}
ctx.strokeRect(0, 0, 100, 100);
ctx.strokeRect(0, 0, canvas.width, canvas.height);
ctx.font = '10pt monospace';
ctx.fillText('100px', 30, 115);
ctx.translate(110, 0);
ctx.rotate(0.5 * Math.PI);
ctx.fillText('100px', 30, 0);
ctx.restore();
}
function back() {
document.location.href = 'frame2.html';
}
/* ==================== SCRIPTS ==================== */
</script>
</head>
<body>
<button onclick="back()">back</button><br/>
<canvas id="canvassample" width="300" height="400"></canvas>
</body>
</html>