-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathtext.html
68 lines (57 loc) · 1.9 KB
/
text.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
63
64
65
66
67
68
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Canvas Text</title>
<style type="text/css" title="text/css">
<!--
body { background-color: #bbb; }
#c { border: 1px solid black; background-color: #ccc; }
-->
</style>
</head>
<body>
<canvas id="c" width="650" height="390"></canvas>
<script type="text/javascript" language="javascript1.5">
<!--
var c = document.getElementById('c').getContext('2d');
var w = document.getElementById('c').width;
var h = document.getElementById('c').height;
c.translate(100, 100);
c.rotate(10 * Math.PI/180);
c.scale(2, 2);
//c.transform(6, 0, 0, 6, 100, 100);
c.font = '36px Helvetica';
c.save();
var msg = 'Hello World';
c.fillStyle = '#ddd';
c.fillText(msg, 0, 0);
for(var i = 0; i < msg.length; i += 1)
{
c.fillStyle = '#bbb';
c.fillText(msg[i], 0, 0);
c.beginPath();
c.rect(0, 0, c.measureText(msg[i]).width, -36);
c.strokeStyle = '#999';
c.stroke();
c.translate(c.measureText(msg[i]).width, 0);
}
/*
c.beginPath();
c.rect(0, 0, c.measureText("Hello World").width + c.measureText("!").width + c.measureText("!").width + c.measureText("!").width, -12);
c.closePath();
c.fillStyle = 'white';
c.fill();
c.beginPath();
c.rect(0, 0, c.measureText("Hello World!!!").width, 2);
c.closePath();
c.fillStyle = 'red';
c.fill();
c.fillStyle = 'black';
c.fillText("Hello World!!!", 0, 0);
*/
//-->
</script>
</body>
</html>