回答編集履歴
1
説明 追記
answer
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
<script>
|
|
9
9
|
//改行させるためのファンクション
|
|
10
10
|
function fillTextLine (context, text, x, y) {
|
|
11
|
-
var textList = text.split('\n');
|
|
11
|
+
var textList = text.split('\n');//\nで分割して配列にします。
|
|
12
12
|
var lineHeight = context.measureText("あ").width;// あ はフォントのサイズを取得するのに利用しているだけです。
|
|
13
|
-
textList.forEach(function(text, i) {
|
|
13
|
+
textList.forEach(function(text, i) {//配列を順番に読み出して、y(高さ)を計算しながら描画していきます。
|
|
14
14
|
context.fillText(text, x, y+lineHeight*i);
|
|
15
15
|
});
|
|
16
16
|
};
|