2011-06-18 10 views
2

HTML5メーターで様々なサイズの画像/アイコンenter image description hereを使用してさまざまな時点でタグを付けたいとします。今私はスパンタグを使用して、それをメーターの様々な部分に置くことによってそれを行うことができます。キャンバスを使用したHTML5 Meter/ProgressBarタグのマーケティング

別の方法がありますか?キャンバス要素を使用することができるかどうかは不思議だった。

答えて

2

キャンバスやWebGLでは間違いなく簡単です。

キャンバス例えば、imagesがフィールドimagex持つオブジェクトの配列であり、そしてyと仮定:

context.fillRect(0, 0, 100, 10); // Progressbar background. Alternatively, you could stroke it (draw a border). 
context.fillRect(0, 0, 10, 10); // Draw the current progress. I've hard coded it to 10% here. 
for (var i = 0; i < images.length; i++) 
{ 
    var a = images[i]; // I'm lazy 
    context.fillRect(a.x - 1, 0, 2, a.y); // less code than stroking 
    context.drawImage(a, a.x, a.y); 
} 
関連する問題