使用Canvas在HTML5 Meter / ProgressBar标记上标记

|| 我想在HTML5 Meter上使用大小不同的图像/图标在各个点进行标记。现在,我可以通过将其放置在仪表的各个部分来使用span标签。 还有其他选择吗?我想知道是否可以使用canvas元素这样做。     
已邀请:
        使用canvas或WebGL肯定会更容易。 以Canvas为例,假设
images
是具有字段
image
x
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);
}
    

要回复问题请先登录注册