回答編集履歴
1
svg
test
CHANGED
@@ -1 +1,51 @@
|
|
1
1
|
cavasはラスタデータなのでベクタデータのsvgを利用ください
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
# sample
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
```javascript
|
10
|
+
|
11
|
+
<script>
|
12
|
+
|
13
|
+
window.addEventListener('DOMContentLoaded', function(e){
|
14
|
+
|
15
|
+
var canvas = document.getElementById('canvas');
|
16
|
+
|
17
|
+
var ctx = canvas.getContext("2d");
|
18
|
+
|
19
|
+
ctx.font = "italic bold 30px 'MS Pゴシック'";
|
20
|
+
|
21
|
+
ctx.fillText("ラベル1", 10, 30);
|
22
|
+
|
23
|
+
var svg=document.getElementById('svg');
|
24
|
+
|
25
|
+
var text=document.createElementNS('http://www.w3.org/2000/svg','text');
|
26
|
+
|
27
|
+
text.textContent="ラベル2";
|
28
|
+
|
29
|
+
text.setAttribute('x','0');
|
30
|
+
|
31
|
+
text.setAttribute('y','30');
|
32
|
+
|
33
|
+
text.setAttribute('style','font-size:30px;font-style: italic;font-weight:bold;font-family:"MS Pゴシック"');
|
34
|
+
|
35
|
+
svg.appendChild(text);
|
36
|
+
|
37
|
+
});
|
38
|
+
|
39
|
+
</script>
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
<div id="content">
|
44
|
+
|
45
|
+
<canvas id="canvas" width="150" height="50"></canvas>
|
46
|
+
|
47
|
+
<svg id="svg" width="150" height="50"></svg>
|
48
|
+
|
49
|
+
</div>
|
50
|
+
|
51
|
+
```
|