点评 : 这篇文章主要介绍了使用 html5 制作 Laden 图的示例, 需要的朋友可以参考下
<! DocType html>
<html>
<kopf>
<title> </title>
</head>
<body>
<canvas id = "canvas"> </canvas> </p> <p> <Script>
var lade = Funktion (Canvas, Optionen) {
this.canvas = document.getElementById (Canvas);
this.options = Optionen;
}; </p> <p> lade.prototype = {
Konstruktor: Laden,
Show: function () {
var canvas = this.canvas,
begin = this.options.begin,
old = this.options.old,
linewidth = this.options.linewidth,,
canvascenter = {x: canvas.width / 2, y: canvas.height / 2},
ctx = canvas.getContext ("2d"),
color = this.options.color,
num = this.options.num,,
Winkel = 0,,
linecap = this.options.lineCap,,
Const_pi = math.pi * (360 / num) / 180;
window.timer = setInterval (function () {
ctx.clearRect (0, 0, canvas.width, canvas.height);
für (var i = 0; i <num; i += 1) {
ctx.beginPath ();
ctx.strokestyle = color [num - 1 - i];
ctx.linewidth = linewidth;
ctx.lineecap = linecap;
ctx.moveto (canvascenter.x + math.cos (const_pi * i + Winkel) * begin, canvascenter.y + math.sin (const_pi * i + Winkel) * begin);
ctx.lineto (canvascenter.x + math.cos (const_pi * i + Winkel) * alt, canvascenter.y + math.sin (const_pi * i + Winkel) * alt);
ctx.stroke ();
ctx.closepath ();
}
Winkel += const_pi;
console.log (Winkel)
}, 50);
},
ausblenden: function () {
ClearInterval (Fenster.Timer);
}
}; </p> <p> (function () {
var options = {
Num: 8,
Beginnen Sie: 20,
Alt: 40,
Linienbreite: 10,
Linecap: "Round",
Farbe: ["RGB (0, 0, 0)", "RGB (20, 20, 20)", "RGB (40, 40, 40)", "RGB (60, 60, 60)", "RGB (80, 80, 80)", "RGB (100, 100, 100)", RGB (120, 120, 120), 120, 120), 120, 120), ", 120)", ", 120", ", 120)", ", 120)", ",", 120) ",", ", 120)", ",", ", 120)", ",", ", 120)", ",", "," ",", "" "," des 120 "," ",", "dem 12)", "des 12)"
};
var loading = neu laden ("Canvas", Optionen);
loading.show ();
} ());
</script>
</body>
</html>
效果图 :