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