現在Canvasを勉強しています
今作ろうとしているものが
ランダムにカラーと座標とサイズを決めた円を50個描画する
というこのなのですが一回しか描画できません
どこを改善すればいいのでしょうか?
JavaScript
1 2<!doctype html> 3<html> 4<head> 5 <meta charset="utf-8"> 6</head> 7<body bgcolor="#000"> 8 <canvas height="600" width="800" id = "mycanvas"></canvas> 9<script> 10 var canvas = document.getElementById('mycanvas'); 11 var ctx = canvas.getContext('2d'); 12 var r = Math.floor(Math.random() * (256)); 13 var g = Math.floor(Math.random() * (256)); 14 var b = Math.floor(Math.random() * (256)); 15 var y = Math.floor(Math.random() * (550)); 16 var x = Math.floor(Math.random() * (750)); 17 var pi = Math.floor(Math.random() * (50)); 18 for(var i = 0; i < 50; i++){ 19 ctx.fillStyle = 'rgb(' + r + ',' + g + ',' + b + ')'; 20 ctx.arc(x,y,pi,10/180*Math.PI,360/180*Math.PI); 21 ctx.fill(); 22 } 23 24</script> 25 26</body> 27</html> 28
回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/07/22 11:49